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
Show 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 () => {
groupId
:
Number
(
$boardApp
.
dataset
.
groupId
),
rootPath
:
$boardApp
.
dataset
.
rootPath
,
canUpdate
:
$boardApp
.
dataset
.
canUpdate
,
labelsFetchPath
:
$boardApp
.
dataset
.
labelsFetchPath
,
labelsManagePath
:
$boardApp
.
dataset
.
labelsManagePath
,
labelsFilterBasePath
:
$boardApp
.
dataset
.
labelsFilterBasePath
,
},
store
,
apolloProvider
,
...
...
app/helpers/boards_helper.rb
View file @
77b5fbe7
...
...
@@ -18,7 +18,10 @@ module BoardsHelper
time_tracking_limit_to_hours:
Gitlab
::
CurrentSettings
.
time_tracking_limit_to_hours
.
to_s
,
recent_boards_endpoint:
recent_boards_path
,
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
...
...
@@ -38,6 +41,22 @@ module BoardsHelper
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
if
board
.
group_board?
group_boards_url
(
@group
)
...
...
spec/helpers/boards_helper_spec.rb
View file @
77b5fbe7
...
...
@@ -34,12 +34,13 @@ RSpec.describe BoardsHelper do
end
describe
'#board_data'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:board
)
{
create
(
:board
,
project:
project
)
}
let
_it_be
(
:user
)
{
create
(
:user
)
}
let
_it_be
(
:board
)
{
create
(
:board
,
project:
project
)
}
context
'project_board'
do
before
do
assign
(
:board
,
board
)
assign
(
:project
,
project
)
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
)
...
...
@@ -57,6 +58,35 @@ RSpec.describe BoardsHelper do
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
context
'group board'
do
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
describe
'#current_board_json'
do
...
...
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