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
0982bb4e
Commit
0982bb4e
authored
Jul 23, 2018
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add roadmap_layout to users
Source roadmap layout setting from database Persist value during roadmap#show
parent
10c3bae8
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
166 additions
and
3 deletions
+166
-3
db/schema.rb
db/schema.rb
+1
-0
ee/app/controllers/groups/roadmap_controller.rb
ee/app/controllers/groups/roadmap_controller.rb
+11
-0
ee/app/helpers/roadmaps_helper.rb
ee/app/helpers/roadmaps_helper.rb
+7
-0
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+8
-0
ee/app/views/groups/roadmap/show.html.haml
ee/app/views/groups/roadmap/show.html.haml
+1
-2
ee/app/views/shared/epic/_search_bar.html.haml
ee/app/views/shared/epic/_search_bar.html.haml
+1
-1
ee/changelogs/unreleased/6293-persisted-roadmap-preset.yml
ee/changelogs/unreleased/6293-persisted-roadmap-preset.yml
+5
-0
ee/db/migrate/20180723081631_add_roadmap_layout_to_users.rb
ee/db/migrate/20180723081631_add_roadmap_layout_to_users.rb
+11
-0
ee/spec/helpers/roadmaps_helper_spec.rb
ee/spec/helpers/roadmaps_helper_spec.rb
+37
-0
ee/spec/models/ee/user_spec.rb
ee/spec/models/ee/user_spec.rb
+18
-0
ee/spec/requests/groups/roadmap_controller_spec.rb
ee/spec/requests/groups/roadmap_controller_spec.rb
+66
-0
No files found.
db/schema.rb
View file @
0982bb4e
...
...
@@ -2789,6 +2789,7 @@ ActiveRecord::Schema.define(version: 20180803001726) do
t
.
integer
"accepted_term_id"
t
.
string
"feed_token"
t
.
boolean
"private_profile"
t
.
integer
"roadmap_layout"
,
limit:
2
end
add_index
"users"
,
[
"admin"
],
name:
"index_users_on_admin"
,
using: :btree
...
...
ee/app/controllers/groups/roadmap_controller.rb
View file @
0982bb4e
module
Groups
class
RoadmapController
<
Groups
::
ApplicationController
before_action
:group
before_action
:persist_roadmap_layout
,
only:
[
:show
]
def
show
# show roadmap for a group
@epics_count
=
EpicsFinder
.
new
(
current_user
,
group_id:
@group
.
id
).
execute
.
count
end
private
def
persist_roadmap_layout
return
unless
current_user
return
unless
User
.
roadmap_layouts
[
params
[
:layout
]]
return
if
current_user
.
roadmap_layout
==
params
[
:layout
]
Users
::
UpdateService
.
new
(
current_user
,
user:
current_user
,
roadmap_layout:
params
[
:layout
]).
execute
end
end
end
ee/app/helpers/roadmaps_helper.rb
0 → 100644
View file @
0982bb4e
# frozen_string_literal: true
module
RoadmapsHelper
def
roadmap_layout
current_user
&
.
roadmap_layout
||
params
[
:layout
].
presence
||
EE
::
User
::
DEFAULT_ROADMAP_LAYOUT
end
end
ee/app/models/ee/user.rb
View file @
0982bb4e
...
...
@@ -7,6 +7,8 @@ module EE
extend
ActiveSupport
::
Concern
include
AuditorUserHelper
DEFAULT_ROADMAP_LAYOUT
=
'MONTHS'
.
freeze
included
do
EMAIL_OPT_IN_SOURCE_ID_GITLAB_COM
=
1
...
...
@@ -35,6 +37,8 @@ module EE
has_many
:protected_branch_unprotect_access_levels
,
dependent: :destroy
,
class_name:
::
ProtectedBranch
::
UnprotectAccessLevel
# rubocop:disable Cop/ActiveRecordDependent
scope
:excluding_guests
,
->
{
joins
(
:members
).
where
(
'members.access_level > ?'
,
::
Gitlab
::
Access
::
GUEST
).
distinct
}
enum
roadmap_layout:
{
WEEKS
:
1
,
MONTHS
:
4
,
QUARTERS
:
12
}
end
module
ClassMethods
...
...
@@ -102,5 +106,9 @@ module EE
params:
{
search:
search
,
sort:
'name_asc'
})
.
execute
end
def
roadmap_layout
super
||
DEFAULT_ROADMAP_LAYOUT
end
end
end
ee/app/views/groups/roadmap/show.html.haml
View file @
0982bb4e
...
...
@@ -2,7 +2,6 @@
-
@no_container
=
true
-
@content_wrapper_class
=
"group-epics-roadmap-wrapper"
-
@content_class
=
"group-epics-roadmap"
-
preset_layout
=
params
[
:layout
].
present?
?
params
[
:layout
]
:
"MONTHS"
-
breadcrumb_title
_
(
"Epics Roadmap"
)
-
has_filters_applied
=
params
[
:label_name
].
present?
||
params
[
:author_username
].
present?
||
params
[
:search
].
present?
...
...
@@ -10,6 +9,6 @@
-
if
@epics_count
!=
0
=
render
'shared/epic/search_bar'
,
type: :epics
,
hide_sort_dropdown:
true
,
show_roadmap_presets:
true
#js-roadmap
{
data:
{
epics_path:
group_epics_path
(
@group
,
format: :json
),
group_id:
@group
.
id
,
empty_state_illustration:
image_path
(
'illustrations/epics/roadmap.svg'
),
has_filters_applied:
"#{has_filters_applied}"
,
new_epic_endpoint:
group_epics_path
(
@group
),
preset_type:
preset
_layout
}
}
#js-roadmap
{
data:
{
epics_path:
group_epics_path
(
@group
,
format: :json
),
group_id:
@group
.
id
,
empty_state_illustration:
image_path
(
'illustrations/epics/roadmap.svg'
),
has_filters_applied:
"#{has_filters_applied}"
,
new_epic_endpoint:
group_epics_path
(
@group
),
preset_type:
roadmap
_layout
}
}
-
else
=
render
'shared/empty_states/roadmap'
ee/app/views/shared/epic/_search_bar.html.haml
View file @
0982bb4e
...
...
@@ -2,7 +2,7 @@
-
hide_sort_dropdown
=
local_assigns
.
fetch
(
:hide_sort_dropdown
,
false
)
-
show_roadmap_presets
=
local_assigns
.
fetch
(
:show_roadmap_presets
,
false
)
-
full_path
=
@project
.
present?
?
@project
.
full_path
:
@group
.
full_path
-
preset_layout
=
params
[
:layout
].
present?
?
params
[
:layout
]
:
"MONTHS"
-
preset_layout
=
roadmap_layout
-
is_quarters
=
preset_layout
==
"QUARTERS"
-
is_months
=
preset_layout
==
"MONTHS"
-
is_weeks
=
preset_layout
==
"WEEKS"
...
...
ee/changelogs/unreleased/6293-persisted-roadmap-preset.yml
0 → 100644
View file @
0982bb4e
---
title
:
Persist Epic Roadmap timescale choice
merge_request
:
6637
author
:
type
:
added
ee/db/migrate/20180723081631_add_roadmap_layout_to_users.rb
0 → 100644
View file @
0982bb4e
# frozen_string_literal: true
class
AddRoadmapLayoutToUsers
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
change
add_column
:users
,
:roadmap_layout
,
:integer
,
limit:
2
end
end
ee/spec/helpers/roadmaps_helper_spec.rb
0 → 100644
View file @
0982bb4e
# frozen_string_literal: true
require
'spec_helper'
describe
RoadmapsHelper
do
describe
'#roadmap_layout'
do
before
do
allow
(
helper
).
to
receive
(
:current_user
)
{
user
}
end
context
'guest'
do
let
(
:user
)
{
nil
}
it
'is sourced from params if exists'
do
allow
(
helper
).
to
receive
(
:params
).
and_return
(
layout:
'WEEKS'
)
expect
(
helper
.
roadmap_layout
).
to
eq
(
'WEEKS'
)
end
it
'returns default if params do not exist'
do
allow
(
helper
).
to
receive
(
:params
).
and_return
({})
expect
(
helper
.
roadmap_layout
).
to
eq
(
'MONTHS'
)
end
end
context
'logged in'
do
let
(
:user
)
{
double
(
:user
)
}
it
'is sourced from User#roadmap_layout'
do
allow
(
helper
).
to
receive
(
:params
).
and_return
(
layout:
'WEEKS'
)
expect
(
user
).
to
receive
(
:roadmap_layout
).
and_return
(
'QUARTERS'
)
expect
(
helper
.
roadmap_layout
).
to
eq
(
'QUARTERS'
)
end
end
end
end
ee/spec/models/ee/user_spec.rb
View file @
0982bb4e
...
...
@@ -218,4 +218,22 @@ describe EE::User do
end
end
end
describe
'#roadmap_layout'
do
context
'not set'
do
subject
{
build
(
:user
,
roadmap_layout:
nil
)
}
it
'returns default value'
do
expect
(
subject
.
roadmap_layout
).
to
eq
(
EE
::
User
::
DEFAULT_ROADMAP_LAYOUT
)
end
end
context
'set'
do
subject
{
build
(
:user
,
roadmap_layout:
'QUARTERS'
)
}
it
'returns set value'
do
expect
(
subject
.
roadmap_layout
).
to
eq
(
'QUARTERS'
)
end
end
end
end
ee/spec/requests/groups/roadmap_controller_spec.rb
0 → 100644
View file @
0982bb4e
# frozen_string_literal: true
require
'rails_helper'
describe
Groups
::
RoadmapController
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
,
:public
)
}
before
do
stub_licensed_features
(
epics:
true
)
end
describe
'GET /groups/*namespace_id/-/roadmap'
do
let
(
:layout
)
{
'WEEKS'
}
context
'guest'
do
it
'renders without persisting layout'
do
expect
do
get
group_roadmap_path
(
group
,
layout:
layout
)
end
.
not_to
change
{
user
.
reload
.
roadmap_layout
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
end
context
'logged in'
do
before
do
allow
(
Users
::
UpdateService
).
to
receive
(
:new
).
and_call_original
group
.
add_maintainer
(
user
)
login_as
user
end
context
'not specifying layout'
do
it
'renders without persisting layout'
do
expect
(
Users
::
UpdateService
).
not_to
receive
(
:new
).
with
(
user
,
user:
user
,
roadmap_layout:
a_kind_of
(
String
))
expect
do
get
group_roadmap_path
(
group
)
end
.
not_to
change
{
user
.
reload
.
roadmap_layout
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
end
context
'specifying invalid layout'
do
it
'renders without persisting layout'
do
expect
(
Users
::
UpdateService
).
not_to
receive
(
:new
).
with
(
user
,
user:
user
,
roadmap_layout:
a_kind_of
(
String
))
get
group_roadmap_path
(
group
,
layout:
'FOO'
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
end
context
'specifying layout'
do
it
'persists roadmap_layout if different than current layout'
do
expect
(
Users
::
UpdateService
).
to
receive
(
:new
).
with
(
user
,
user:
user
,
roadmap_layout:
layout
).
once
.
and_call_original
expect
do
get
group_roadmap_path
(
group
,
layout:
layout
)
get
group_roadmap_path
(
group
,
layout:
layout
)
end
.
to
change
{
user
.
reload
.
roadmap_layout
}.
to
(
layout
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
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