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
77b5fbe7
Commit
77b5fbe7
authored
Oct 13, 2020
by
Axel García
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide required data for board labels
parent
c914239d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
17 deletions
+69
-17
app/assets/javascripts/boards/index.js
app/assets/javascripts/boards/index.js
+3
-0
app/helpers/boards_helper.rb
app/helpers/boards_helper.rb
+20
-1
spec/helpers/boards_helper_spec.rb
spec/helpers/boards_helper_spec.rb
+46
-16
No files found.
app/assets/javascripts/boards/index.js
View file @
77b5fbe7
...
@@ -87,6 +87,9 @@ export default () => {
...
@@ -87,6 +87,9 @@ export default () => {
groupId
:
Number
(
$boardApp
.
dataset
.
groupId
),
groupId
:
Number
(
$boardApp
.
dataset
.
groupId
),
rootPath
:
$boardApp
.
dataset
.
rootPath
,
rootPath
:
$boardApp
.
dataset
.
rootPath
,
canUpdate
:
$boardApp
.
dataset
.
canUpdate
,
canUpdate
:
$boardApp
.
dataset
.
canUpdate
,
labelsFetchPath
:
$boardApp
.
dataset
.
labelsFetchPath
,
labelsManagePath
:
$boardApp
.
dataset
.
labelsManagePath
,
labelsFilterBasePath
:
$boardApp
.
dataset
.
labelsFilterBasePath
,
},
},
store
,
store
,
apolloProvider
,
apolloProvider
,
...
...
app/helpers/boards_helper.rb
View file @
77b5fbe7
...
@@ -18,7 +18,10 @@ module BoardsHelper
...
@@ -18,7 +18,10 @@ module BoardsHelper
time_tracking_limit_to_hours:
Gitlab
::
CurrentSettings
.
time_tracking_limit_to_hours
.
to_s
,
time_tracking_limit_to_hours:
Gitlab
::
CurrentSettings
.
time_tracking_limit_to_hours
.
to_s
,
recent_boards_endpoint:
recent_boards_path
,
recent_boards_endpoint:
recent_boards_path
,
parent:
current_board_parent
.
model_name
.
param_key
,
parent:
current_board_parent
.
model_name
.
param_key
,
group_id:
@group
&
.
id
group_id:
@group
&
.
id
,
labels_filter_base_path:
build_issue_link_base
,
labels_fetch_path:
labels_fetch_path
,
labels_manage_path:
labels_manage_path
}
}
end
end
...
@@ -38,6 +41,22 @@ module BoardsHelper
...
@@ -38,6 +41,22 @@ module BoardsHelper
end
end
end
end
def
labels_fetch_path
if
board
.
group_board?
group_labels_path
(
@group
,
format: :json
,
only_group_labels:
true
,
include_ancestor_groups:
true
)
else
project_labels_path
(
@project
,
format: :json
,
include_ancestor_groups:
true
)
end
end
def
labels_manage_path
if
board
.
group_board?
group_labels_path
(
@group
)
else
project_labels_path
(
@project
)
end
end
def
board_base_url
def
board_base_url
if
board
.
group_board?
if
board
.
group_board?
group_boards_url
(
@group
)
group_boards_url
(
@group
)
...
...
spec/helpers/boards_helper_spec.rb
View file @
77b5fbe7
...
@@ -34,28 +34,58 @@ RSpec.describe BoardsHelper do
...
@@ -34,28 +34,58 @@ RSpec.describe BoardsHelper do
end
end
describe
'#board_data'
do
describe
'#board_data'
do
let
(
:user
)
{
create
(
:user
)
}
let
_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:board
)
{
create
(
:board
,
project:
project
)
}
let
_it_be
(
:board
)
{
create
(
:board
,
project:
project
)
}
before
do
context
'project_board'
do
assign
(
:board
,
board
)
before
do
assign
(
:project
,
project
)
assign
(
:project
,
project
)
assign
(
:board
,
board
)
allow
(
helper
).
to
receive
(
:current_user
)
{
user
}
allow
(
helper
).
to
receive
(
:current_user
)
{
user
}
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:create_non_backlog_issues
,
board
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:create_non_backlog_issues
,
board
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:admin_issue
,
board
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:admin_issue
,
board
).
and_return
(
true
)
end
end
it
'returns a board_lists_path as lists_endpoint'
do
it
'returns a board_lists_path as lists_endpoint'
do
expect
(
helper
.
board_data
[
:lists_endpoint
]).
to
eq
(
board_lists_path
(
board
))
expect
(
helper
.
board_data
[
:lists_endpoint
]).
to
eq
(
board_lists_path
(
board
))
end
end
it
'returns board type as parent'
do
it
'returns board type as parent'
do
expect
(
helper
.
board_data
[
:parent
]).
to
eq
(
'project'
)
expect
(
helper
.
board_data
[
:parent
]).
to
eq
(
'project'
)
end
it
'returns can_update for user permissions on the board'
do
expect
(
helper
.
board_data
[
:can_update
]).
to
eq
(
'true'
)
end
it
'returns required label endpoints'
do
expect
(
helper
.
board_data
[
:labels_fetch_path
]).
to
eq
(
"/
#{
project
.
full_path
}
/-/labels.json?include_ancestor_groups=true"
)
expect
(
helper
.
board_data
[
:labels_manage_path
]).
to
eq
(
"/
#{
project
.
full_path
}
/-/labels"
)
end
end
end
it
'returns can_update for user permissions on the board'
do
context
'group board'
do
expect
(
helper
.
board_data
[
:can_update
]).
to
eq
(
'true'
)
let_it_be
(
:group
)
{
create
(
:group
,
path:
'base'
)
}
let_it_be
(
:board
)
{
create
(
:board
,
group:
group
)
}
before
do
assign
(
:group
,
group
)
assign
(
:board
,
board
)
allow
(
helper
).
to
receive
(
:current_user
)
{
user
}
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:create_non_backlog_issues
,
board
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:admin_issue
,
board
).
and_return
(
true
)
end
it
'returns correct path for base group'
do
expect
(
helper
.
build_issue_link_base
).
to
eq
(
'/base/:project_path/issues'
)
end
it
'returns required label endpoints'
do
expect
(
helper
.
board_data
[
:labels_fetch_path
]).
to
eq
(
"/groups/base/-/labels.json?include_ancestor_groups=true&only_group_labels=true"
)
expect
(
helper
.
board_data
[
:labels_manage_path
]).
to
eq
(
"/groups/base/-/labels"
)
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