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
e3925530
Commit
e3925530
authored
Jul 12, 2019
by
Winnie Hellmann
Committed by
Jan Provaznik
Jul 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move current issue board serialization to core
parent
be996ebc
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
67 additions
and
40 deletions
+67
-40
app/helpers/boards_helper.rb
app/helpers/boards_helper.rb
+5
-1
app/serializers/current_board_entity.rb
app/serializers/current_board_entity.rb
+8
-0
app/serializers/current_board_serializer.rb
app/serializers/current_board_serializer.rb
+0
-0
ee/app/helpers/ee/boards_helper.rb
ee/app/helpers/ee/boards_helper.rb
+6
-27
ee/app/serializers/ee/current_board_entity.rb
ee/app/serializers/ee/current_board_entity.rb
+15
-0
ee/app/views/shared/boards/_switcher.html.haml
ee/app/views/shared/boards/_switcher.html.haml
+1
-1
ee/spec/helpers/boards_helper_spec.rb
ee/spec/helpers/boards_helper_spec.rb
+2
-9
spec/fixtures/api/schemas/current-board.json
spec/fixtures/api/schemas/current-board.json
+16
-0
spec/helpers/boards_helper_spec.rb
spec/helpers/boards_helper_spec.rb
+14
-2
No files found.
app/helpers/boards_helper.rb
View file @
e3925530
...
...
@@ -99,8 +99,12 @@ module BoardsHelper
recent_project_boards_path
(
@project
)
if
current_board_parent
.
is_a?
(
Project
)
end
def
serializer
CurrentBoardSerializer
.
new
end
def
current_board_json
board
.
to
_json
serializer
.
represent
(
board
).
as
_json
end
end
...
...
ee/
app/serializers/current_board_entity.rb
→
app/serializers/current_board_entity.rb
View file @
e3925530
...
...
@@ -3,10 +3,6 @@
class
CurrentBoardEntity
<
Grape
::
Entity
expose
:id
expose
:name
expose
:milestone_id
expose
:weight
expose
:label_ids
expose
:milestone
,
using:
BoardMilestoneEntity
expose
:assignee
,
using:
BoardAssigneeEntity
expose
:labels
,
using:
BoardLabelEntity
end
CurrentBoardEntity
.
prepend
(
EE
::
CurrentBoardEntity
)
ee/
app/serializers/current_board_serializer.rb
→
app/serializers/current_board_serializer.rb
View file @
e3925530
File moved
ee/app/helpers/ee/boards_helper.rb
View file @
e3925530
...
...
@@ -4,10 +4,6 @@ module EE
module
BoardsHelper
extend
::
Gitlab
::
Utils
::
Override
def
parent
@group
||
@project
end
override
:board_list_data
def
board_list_data
super
.
merge
(
list_milestone_path:
board_milestones_path
(
board
,
:json
),
...
...
@@ -21,44 +17,27 @@ module EE
!
@project
.
feature_available?
(
:issue_board_focus_mode
)))
data
=
{
recent_boards_endpoint:
recent_boards_path
,
board_milestone_title:
board
.
milestone
&
.
name
,
board_milestone_id:
board
.
milestone_id
,
board_assignee_username:
board
.
assignee
&
.
username
,
label_ids:
board
.
label_ids
,
labels:
board
.
labels
.
to_json
(
only:
[
:id
,
:title
,
:color
,
:text_color
]
),
board_weight:
board
.
weight
,
focus_mode_available:
parent
.
feature_available?
(
:issue_board_focus_mode
),
weight_feature_available:
parent
.
feature_available?
(
:issue_weights
).
to_s
,
focus_mode_available:
current_board_
parent
.
feature_available?
(
:issue_board_focus_mode
),
weight_feature_available:
current_board_
parent
.
feature_available?
(
:issue_weights
).
to_s
,
show_promotion:
show_feature_promotion
,
scoped_labels:
parent
.
feature_available?
(
:scoped_labels
)
&
.
to_s
,
scoped_labels:
current_board_
parent
.
feature_available?
(
:scoped_labels
)
&
.
to_s
,
scoped_labels_documentation_link:
help_page_path
(
'user/project/labels.md'
,
anchor:
'scoped-labels'
)
}
super
.
merge
(
data
)
end
override
:recent_boards_path
def
recent_boards_path
parent
.
is_a?
(
Group
)
?
recent_group_boards_path
(
@group
)
:
recent_project_boards_path
(
@project
)
end
def
serializer
CurrentBoardSerializer
.
new
end
def
current_board
board
=
@board
||
@boards
.
first
serializer
.
represent
(
board
).
as_json
end
return
recent_group_boards_path
(
@group
)
if
current_board_parent
.
is_a?
(
Group
)
override
:boards_link_text
def
boards_link_text
if
parent
.
multiple_issue_boards_available?
s_
(
"IssueBoards|Boards"
)
else
s_
(
"IssueBoards|Board"
)
end
super
end
end
end
ee/app/serializers/ee/current_board_entity.rb
0 → 100644
View file @
e3925530
# frozen_string_literal: true
module
EE
module
CurrentBoardEntity
extend
ActiveSupport
::
Concern
prepended
do
expose
:milestone_id
expose
:weight
expose
:label_ids
expose
:milestone
,
using:
BoardMilestoneEntity
expose
:assignee
,
using:
BoardAssigneeEntity
expose
:labels
,
using:
BoardLabelEntity
end
end
end
ee/app/views/shared/boards/_switcher.html.haml
View file @
e3925530
...
...
@@ -2,7 +2,7 @@
-
milestone_filter_opts
=
{
format: :json
}
-
milestone_filter_opts
=
milestone_filter_opts
.
merge
(
only_group_milestones:
true
)
if
board
.
group_board?
#js-multiple-boards-switcher
.inline.boards-switcher
{
data:
{
current_board:
current_board
.
to_json
,
#js-multiple-boards-switcher
.inline.boards-switcher
{
data:
{
current_board:
current_board
_json
.
to_json
,
milestone_path:
milestones_filter_path
(
milestone_filter_opts
),
board_base_url:
board_base_url
,
has_missing_boards:
(
!
multiple_boards_available?
&&
current_board_parent
.
boards
.
size
>
1
).
to_s
,
...
...
ee/spec/helpers/boards_helper_spec.rb
View file @
e3925530
...
...
@@ -16,8 +16,8 @@ describe BoardsHelper do
end
end
describe
'#current_board'
do
let
(
:board_json
)
{
helper
.
current_board
}
describe
'#current_board
_json
'
do
let
(
:board_json
)
{
helper
.
current_board
_json
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:label1
)
{
create
(
:label
,
name:
"feijoa"
)
}
let
(
:label2
)
{
create
(
:label
,
name:
"pineapple"
)
}
...
...
@@ -29,12 +29,5 @@ describe BoardsHelper do
expect
(
board_json
).
to
match_schema
(
'current-board'
,
dir:
'ee'
)
end
it
'can serialise with a basic set of attributes'
do
board
=
create
(
:board
,
project:
project
)
assign
(
:board
,
board
)
expect
(
board_json
).
to
match_schema
(
'current-board'
,
dir:
'ee'
)
end
end
end
spec/fixtures/api/schemas/current-board.json
0 → 100644
View file @
e3925530
{
"type"
:
"object"
,
"allOf"
:
[
{
"$ref"
:
"board.json"
},
{
"required"
:
[
"id"
,
"name"
],
"properties"
:
{
"id"
:
{
"type"
:
"integer"
},
"name"
:
{
"type"
:
"string"
}
}
}
]
}
spec/helpers/boards_helper_spec.rb
View file @
e3925530
require
'spec_helper'
describe
BoardsHelper
do
set
(
:project
)
{
create
(
:project
)
}
describe
'#build_issue_link_base'
do
context
'project board'
do
it
'returns correct path for project board'
do
@project
=
create
(
:project
)
@project
=
project
@board
=
create
(
:board
,
project:
@project
)
expect
(
build_issue_link_base
).
to
eq
(
"/
#{
@project
.
namespace
.
path
}
/
#{
@project
.
path
}
/issues"
)
...
...
@@ -31,7 +33,6 @@ describe BoardsHelper do
describe
'#board_data'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:board
)
{
create
(
:board
,
project:
project
)
}
before
do
...
...
@@ -46,4 +47,15 @@ describe BoardsHelper do
expect
(
helper
.
board_data
[
:lists_endpoint
]).
to
eq
(
board_lists_path
(
board
))
end
end
describe
'#current_board_json'
do
let
(
:board_json
)
{
helper
.
current_board_json
}
it
'can serialise with a basic set of attributes'
do
board
=
create
(
:board
,
project:
project
)
assign
(
:board
,
board
)
expect
(
board_json
).
to
match_schema
(
'current-board'
)
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