Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
61462b0b
Commit
61462b0b
authored
Jun 05, 2019
by
Martin Wortschack
Committed by
Mayra Cabrera
Jun 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add skeleton for onboarding helper
- Add controller - Add specs - Mount app - Add specs
parent
43f3274e
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
209 additions
and
7 deletions
+209
-7
app/controllers/dashboard/projects_controller.rb
app/controllers/dashboard/projects_controller.rb
+15
-6
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+1
-0
app/views/layouts/application.html.haml
app/views/layouts/application.html.haml
+2
-0
ee/app/assets/javascripts/main.js
ee/app/assets/javascripts/main.js
+3
-0
ee/app/assets/javascripts/onboarding/onboarding_helper/components/app.vue
...vascripts/onboarding/onboarding_helper/components/app.vue
+7
-0
ee/app/assets/javascripts/onboarding/onboarding_helper/index.js
.../assets/javascripts/onboarding/onboarding_helper/index.js
+23
-0
ee/app/controllers/ee/dashboard/projects_controller.rb
ee/app/controllers/ee/dashboard/projects_controller.rb
+28
-0
ee/app/controllers/explore/onboarding_controller.rb
ee/app/controllers/explore/onboarding_controller.rb
+3
-1
ee/app/views/shared/_onboarding_guide.html.haml
ee/app/views/shared/_onboarding_guide.html.haml
+6
-0
ee/spec/controllers/ee/dashboard/projects_controller_spec.rb
ee/spec/controllers/ee/dashboard/projects_controller_spec.rb
+77
-0
ee/spec/controllers/explore/onboarding_controller_spec.rb
ee/spec/controllers/explore/onboarding_controller_spec.rb
+44
-0
No files found.
app/controllers/dashboard/projects_controller.rb
View file @
61462b0b
...
@@ -6,18 +6,14 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
...
@@ -6,18 +6,14 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
prepend_before_action
(
only:
[
:index
])
{
authenticate_sessionless_user!
(
:rss
)
}
prepend_before_action
(
only:
[
:index
])
{
authenticate_sessionless_user!
(
:rss
)
}
before_action
:set_non_archived_param
before_action
:set_non_archived_param
before_action
:projects
,
only:
[
:index
]
before_action
:default_sorting
before_action
:default_sorting
skip_cross_project_access_check
:index
,
:starred
skip_cross_project_access_check
:index
,
:starred
def
index
def
index
@projects
=
load_projects
(
params
.
merge
(
non_public:
true
))
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
do
format
.
html
do
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/40260
render_projects
Gitlab
::
GitalyClient
.
allow_n_plus_1_calls
do
render
end
end
end
format
.
atom
do
format
.
atom
do
load_events
load_events
...
@@ -51,6 +47,17 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
...
@@ -51,6 +47,17 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
private
private
def
projects
@projects
||=
load_projects
(
params
.
merge
(
non_public:
true
))
end
def
render_projects
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/40260
Gitlab
::
GitalyClient
.
allow_n_plus_1_calls
do
render
end
end
def
default_sorting
def
default_sorting
params
[
:sort
]
||=
'latest_activity_desc'
params
[
:sort
]
||=
'latest_activity_desc'
@sort
=
params
[
:sort
]
@sort
=
params
[
:sort
]
...
@@ -81,3 +88,5 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
...
@@ -81,3 +88,5 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
Events
::
RenderService
.
new
(
current_user
).
execute
(
@events
,
atom_request:
request
.
format
.
atom?
)
Events
::
RenderService
.
new
(
current_user
).
execute
(
@events
,
atom_request:
request
.
format
.
atom?
)
end
end
end
end
Dashboard
::
ProjectsController
.
prepend
(
EE
::
Dashboard
::
ProjectsController
)
app/helpers/projects_helper.rb
View file @
61462b0b
...
@@ -243,6 +243,7 @@ module ProjectsHelper
...
@@ -243,6 +243,7 @@ module ProjectsHelper
# TODO: Remove this method when removing the feature flag
# TODO: Remove this method when removing the feature flag
# https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/11209#note_162234863
# https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/11209#note_162234863
# make sure to remove from the EE specific controller as well: ee/app/controllers/ee/dashboard/projects_controller.rb
def
show_projects?
(
projects
,
params
)
def
show_projects?
(
projects
,
params
)
Feature
.
enabled?
(
:project_list_filter_bar
)
||
!!
(
params
[
:personal
]
||
params
[
:name
]
||
any_projects?
(
projects
))
Feature
.
enabled?
(
:project_list_filter_bar
)
||
!!
(
params
[
:personal
]
||
params
[
:name
]
||
any_projects?
(
projects
))
end
end
...
...
app/views/layouts/application.html.haml
View file @
61462b0b
...
@@ -10,4 +10,6 @@
...
@@ -10,4 +10,6 @@
=
render
'layouts/page'
,
sidebar:
sidebar
,
nav:
nav
=
render
'layouts/page'
,
sidebar:
sidebar
,
nav:
nav
=
footer_message
=
footer_message
=
render_if_exists
"shared/onboarding_guide"
=
yield
:scripts_body
=
yield
:scripts_body
ee/app/assets/javascripts/main.js
View file @
61462b0b
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
initEETrialBanner
from
'
ee/ee_trial_banner
'
;
import
initEETrialBanner
from
'
ee/ee_trial_banner
'
;
import
trackNavbarEvents
from
'
ee/event_tracking/navbar
'
;
import
trackNavbarEvents
from
'
ee/event_tracking/navbar
'
;
import
initOnboarding
from
'
ee/onboarding/onboarding_helper
'
;
$
(()
=>
{
$
(()
=>
{
/**
/**
...
@@ -12,4 +13,6 @@ $(() => {
...
@@ -12,4 +13,6 @@ $(() => {
initEETrialBanner
();
initEETrialBanner
();
trackNavbarEvents
();
trackNavbarEvents
();
initOnboarding
();
});
});
ee/app/assets/javascripts/onboarding/onboarding_helper/components/app.vue
0 → 100644
View file @
61462b0b
<
script
>
export
default
{};
</
script
>
<
template
>
<div></div>
</
template
>
ee/app/assets/javascripts/onboarding/onboarding_helper/index.js
0 → 100644
View file @
61462b0b
import
Vue
from
'
vue
'
;
import
OnboardingApp
from
'
./components/app.vue
'
;
export
default
function
()
{
const
el
=
document
.
getElementById
(
'
js-onboarding-helper
'
);
if
(
!
el
)
{
return
false
;
}
return
new
Vue
({
el
,
components
:
{
OnboardingApp
,
},
render
(
h
)
{
return
h
(
OnboardingApp
,
{
props
:
{},
});
},
});
}
ee/app/controllers/ee/dashboard/projects_controller.rb
0 → 100644
View file @
61462b0b
# frozen_string_literal: true
module
EE
module
Dashboard
module
ProjectsController
extend
ActiveSupport
::
Concern
extend
::
Gitlab
::
Utils
::
Override
private
override
:render_projects
def
render_projects
if
show_onboarding_welcome_page?
redirect_to
explore_onboarding_index_path
else
super
end
end
def
show_onboarding_welcome_page?
return
false
unless
::
Gitlab
.
com?
return
false
if
cookies
[
'onboarding_dismissed'
]
==
'true'
::
Feature
.
enabled?
(
:user_onboarding
)
&&
!
show_projects?
(
projects
,
params
)
end
end
end
end
ee/app/controllers/explore/onboarding_controller.rb
View file @
61462b0b
...
@@ -11,7 +11,9 @@ class Explore::OnboardingController < Explore::ApplicationController
...
@@ -11,7 +11,9 @@ class Explore::OnboardingController < Explore::ApplicationController
def
set_project!
def
set_project!
@project
=
get_onboarding_demo_project
@project
=
get_onboarding_demo_project
render_404
unless
@project
&&
can?
(
current_user
,
:read_project
,
@project
)
return
render_404
unless
@project
&&
can?
(
current_user
,
:read_project
,
@project
)
session
[
:onboarding_project
]
=
{
project_full_path:
@project
.
web_url
,
project_name:
@project
.
name
}
end
end
def
get_onboarding_demo_project
def
get_onboarding_demo_project
...
...
ee/app/views/shared/_onboarding_guide.html.haml
0 → 100644
View file @
61462b0b
-
onboarding_project
=
session
[
:onboarding_project
]
-
return
unless
onboarding_project
#js-onboarding-helper
{
data:
{
project_full_path:
onboarding_project
[
:project_full_path
],
project_name:
onboarding_project
[
:project_name
]
}
}
#js-onboarding-action-popover
ee/spec/controllers/ee/dashboard/projects_controller_spec.rb
0 → 100644
View file @
61462b0b
# frozen_string_literal: true
require
'spec_helper'
describe
Dashboard
::
ProjectsController
do
include
ExternalAuthorizationServiceHelpers
let
(
:user
)
{
create
(
:user
)
}
describe
'GET #index'
do
before
do
sign_in
(
user
)
end
context
'onboarding welcome page'
do
before
do
allow
(
Gitlab
).
to
receive
(
:com?
)
{
true
}
end
shared_examples
'200 status'
do
it
'renders the index template'
do
get
:index
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
render_template
(
:index
)
end
end
context
'when the feature is enabled'
do
before
do
stub_feature_flags
(
user_onboarding:
true
)
end
context
'and the user does not have projects'
do
before
do
stub_feature_flags
(
project_list_filter_bar:
false
)
end
it
'renders the welcome page if it has not dismissed onboarding'
do
allow
(
controller
).
to
receive
(
:cookies
).
and_return
({
'onboarding_dismissed'
=>
'false'
})
get
:index
expect
(
response
).
to
redirect_to
(
explore_onboarding_index_path
)
end
it
'renders the index template if it has dismissed the onboarding'
do
allow
(
controller
).
to
receive
(
:cookies
).
and_return
({
'onboarding_dismissed'
=>
'true'
})
get
:index
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
render_template
(
:index
)
end
end
context
'and the user has projects'
do
let
(
:project
)
{
create
(
:project
)
}
before
do
project
.
add_developer
(
user
)
end
it_behaves_like
'200 status'
end
end
context
'when the feature is disabled'
do
before
do
stub_feature_flags
(
user_onboarding:
false
)
end
it_behaves_like
'200 status'
end
end
end
end
ee/spec/controllers/explore/onboarding_controller_spec.rb
0 → 100644
View file @
61462b0b
# frozen_string_literal: true
require
'spec_helper'
describe
Explore
::
OnboardingController
do
let
(
:user
)
{
create
(
:user
,
username:
'gitlab-org'
)
}
let
(
:project
)
{
create
(
:project
,
path:
'gitlab-ce'
,
namespace:
user
.
namespace
)
}
before
do
allow
(
Gitlab
).
to
receive
(
:com?
)
{
true
}
sign_in
(
user
)
project
.
add_guest
(
user
)
end
describe
'GET #index'
do
context
'when the feature is enabled'
do
before
do
stub_feature_flags
(
user_onboarding:
true
)
end
it
'renders index with 200 status code and sets the session variable if the user is authenticated'
do
get
:index
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
render_template
(
:index
)
expect
(
session
[
:onboarding_project
]).
to
eq
({
project_full_path:
project
.
web_url
,
project_name:
project
.
name
})
end
end
context
'when the feature is disabled'
do
before
do
stub_feature_flags
(
user_onboarding:
false
)
end
it
'returns 404'
do
get
:index
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
session
[
:onboarding_project
]).
to
be_nil
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment