BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
ad1c186e
Commit
ad1c186e
authored
Dec 12, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'sophie-h/gitlab-ce-patch-15' into 'master'
Hide issues and MRs in labels list if disabled See merge request gitlab-org/gitlab-ce!15863
parents
b655a4a7
7ccd6a51
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
171 additions
and
0 deletions
+171
-0
labels_helper.rb
app/helpers/labels_helper.rb
+7
-0
_label.html.haml
app/views/shared/_label.html.haml
+6
-0
sophie-h-gitlab-ce-patch-15.yml
changelogs/unreleased/sophie-h-gitlab-ce-patch-15.yml
+5
-0
user_sees_links_to_issuables.rb
spec/features/groups/labels/user_sees_links_to_issuables.rb
+15
-0
user_sees_links_to_issuables.rb
.../features/projects/labels/user_sees_links_to_issuables.rb
+75
-0
labels_helper_spec.rb
spec/helpers/labels_helper_spec.rb
+63
-0
No files found.
app/helpers/labels_helper.rb
View file @
ad1c186e
module
LabelsHelper
module
LabelsHelper
include
ActionView
::
Helpers
::
TagHelper
include
ActionView
::
Helpers
::
TagHelper
def
show_label_issuables_link?
(
label
,
issuables_type
,
current_user:
nil
,
project:
nil
)
return
true
if
label
.
is_a?
(
GroupLabel
)
return
true
unless
project
project
.
feature_available?
(
issuables_type
,
current_user
)
end
# Link to a Label
# Link to a Label
#
#
# label - Label object to link to
# label - Label object to link to
...
...
app/views/shared/_label.html.haml
View file @
ad1c186e
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
-
status
=
label_subscription_status
(
label
,
@project
).
inquiry
if
current_user
-
status
=
label_subscription_status
(
label
,
@project
).
inquiry
if
current_user
-
subject
=
local_assigns
[
:subject
]
-
subject
=
local_assigns
[
:subject
]
-
toggle_subscription_path
=
toggle_subscription_label_path
(
label
,
@project
)
if
current_user
-
toggle_subscription_path
=
toggle_subscription_label_path
(
label
,
@project
)
if
current_user
-
show_label_merge_requests_link
=
show_label_issuables_link?
(
label
,
:merge_requests
,
project:
@project
)
-
show_label_issues_link
=
show_label_issuables_link?
(
label
,
:issues
,
project:
@project
)
%li
{
id:
label_css_id
,
data:
{
id:
label
.
id
}
}
%li
{
id:
label_css_id
,
data:
{
id:
label
.
id
}
}
=
render
"shared/label_row"
,
label:
label
=
render
"shared/label_row"
,
label:
label
...
@@ -12,9 +14,11 @@
...
@@ -12,9 +14,11 @@
=
icon
(
'caret-down'
)
=
icon
(
'caret-down'
)
.dropdown-menu.dropdown-menu-align-right
.dropdown-menu.dropdown-menu-align-right
%ul
%ul
-
if
show_label_merge_requests_link
%li
%li
=
link_to_label
(
label
,
subject:
subject
,
type: :merge_request
)
do
=
link_to_label
(
label
,
subject:
subject
,
type: :merge_request
)
do
View merge requests
View merge requests
-
if
show_label_issues_link
%li
%li
=
link_to_label
(
label
,
subject:
subject
)
do
=
link_to_label
(
label
,
subject:
subject
)
do
View open issues
View open issues
...
@@ -38,8 +42,10 @@
...
@@ -38,8 +42,10 @@
=
link_to
'Delete'
,
destroy_label_path
(
label
),
title:
'Delete'
,
method: :delete
,
data:
{
confirm:
'Remove this label? Are you sure?'
}
=
link_to
'Delete'
,
destroy_label_path
(
label
),
title:
'Delete'
,
method: :delete
,
data:
{
confirm:
'Remove this label? Are you sure?'
}
.pull-right.hidden-xs.hidden-sm.hidden-md
.pull-right.hidden-xs.hidden-sm.hidden-md
-
if
show_label_merge_requests_link
=
link_to_label
(
label
,
subject:
subject
,
type: :merge_request
,
css_class:
'btn btn-transparent btn-action btn-link'
)
do
=
link_to_label
(
label
,
subject:
subject
,
type: :merge_request
,
css_class:
'btn btn-transparent btn-action btn-link'
)
do
view merge requests
view merge requests
-
if
show_label_issues_link
=
link_to_label
(
label
,
subject:
subject
,
css_class:
'btn btn-transparent btn-action btn-link'
)
do
=
link_to_label
(
label
,
subject:
subject
,
css_class:
'btn btn-transparent btn-action btn-link'
)
do
view open issues
view open issues
...
...
changelogs/unreleased/sophie-h-gitlab-ce-patch-15.yml
0 → 100644
View file @
ad1c186e
---
title
:
Hide link to issues/MRs from labels list if issues/MRs are disabled.
merge_request
:
15863
author
:
Sophie Herold
type
:
fixed
spec/features/groups/labels/user_sees_links_to_issuables.rb
0 → 100644
View file @
ad1c186e
require
'spec_helper'
feature
'Groups > Labels > User sees links to issuables'
do
set
(
:group
)
{
create
(
:group
,
:public
)
}
before
do
create
(
:group_label
,
group:
group
,
title:
'bug'
)
visit
group_labels_path
(
group
)
end
scenario
'shows links to MRs and issues'
do
expect
(
page
).
to
have_link
(
'view merge requests'
)
expect
(
page
).
to
have_link
(
'view open issues'
)
end
end
spec/features/projects/labels/user_sees_links_to_issuables.rb
0 → 100644
View file @
ad1c186e
require
'spec_helper'
feature
'Projects > Labels > User sees links to issuables'
do
set
(
:user
)
{
create
(
:user
)
}
before
do
label
# creates the label
project
.
add_developer
(
user
)
sign_in
user
visit
project_labels_path
(
project
)
end
context
'with a project label'
do
let
(
:label
)
{
create
(
:label
,
project:
project
,
title:
'bug'
)
}
context
'when merge requests and issues are enabled for the project'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
scenario
'shows links to MRs and issues'
do
expect
(
page
).
to
have_link
(
'view merge requests'
)
expect
(
page
).
to
have_link
(
'view open issues'
)
end
end
context
'when issues are disabled for the project'
do
let
(
:project
)
{
create
(
:project
,
:public
,
issues_access_level:
ProjectFeature
::
DISABLED
)
}
scenario
'shows links to MRs but not to issues'
do
expect
(
page
).
to
have_link
(
'view merge requests'
)
expect
(
page
).
not_to
have_link
(
'view open issues'
)
end
end
context
'when merge requests are disabled for the project'
do
let
(
:project
)
{
create
(
:project
,
:public
,
merge_requests_access_level:
ProjectFeature
::
DISABLED
)
}
scenario
'shows links to issues but not to MRs'
do
expect
(
page
).
not_to
have_link
(
'view merge requests'
)
expect
(
page
).
to
have_link
(
'view open issues'
)
end
end
end
context
'with a group label'
do
set
(
:group
)
{
create
(
:group
)
}
let
(
:label
)
{
create
(
:group_label
,
group:
group
,
title:
'bug'
)
}
context
'when merge requests and issues are enabled for the project'
do
let
(
:project
)
{
create
(
:project
,
:public
,
namespace:
group
)
}
scenario
'shows links to MRs and issues'
do
expect
(
page
).
to
have_link
(
'view merge requests'
)
expect
(
page
).
to
have_link
(
'view open issues'
)
end
end
context
'when issues are disabled for the project'
do
let
(
:project
)
{
create
(
:project
,
:public
,
namespace:
group
,
issues_access_level:
ProjectFeature
::
DISABLED
)
}
scenario
'shows links to MRs and issues'
do
expect
(
page
).
to
have_link
(
'view merge requests'
)
expect
(
page
).
to
have_link
(
'view open issues'
)
end
end
context
'when merge requests are disabled for the project'
do
let
(
:project
)
{
create
(
:project
,
:public
,
namespace:
group
,
merge_requests_access_level:
ProjectFeature
::
DISABLED
)
}
scenario
'shows links to MRs and issues'
do
expect
(
page
).
to
have_link
(
'view merge requests'
)
expect
(
page
).
to
have_link
(
'view open issues'
)
end
end
end
end
spec/helpers/labels_helper_spec.rb
View file @
ad1c186e
require
'spec_helper'
require
'spec_helper'
describe
LabelsHelper
do
describe
LabelsHelper
do
describe
'#show_label_issuables_link?'
do
shared_examples
'a valid response to show_label_issuables_link?'
do
|
issuables_type
,
when_enabled
=
true
,
when_disabled
=
false
|
let
(
:context_project
)
{
project
}
context
"when asking for a
#{
issuables_type
}
link"
do
subject
{
show_label_issuables_link?
(
label
,
issuables_type
,
project:
context_project
)
}
context
"when
#{
issuables_type
}
are enabled for the project"
do
let
(
:project
)
{
create
(
:project
,
"
#{
issuables_type
}
_access_level"
:
ProjectFeature
::
ENABLED
)
}
it
{
is_expected
.
to
be
(
when_enabled
)
}
end
context
"when
#{
issuables_type
}
are disabled for the project"
do
let
(
:project
)
{
create
(
:project
,
:public
,
"
#{
issuables_type
}
_access_level"
:
ProjectFeature
::
DISABLED
)
}
it
{
is_expected
.
to
be
(
when_disabled
)
}
end
end
end
context
'with a project label'
do
let
(
:label
)
{
create
(
:label
,
project:
project
,
title:
'bug'
)
}
context
'when asking for an issue link'
do
it_behaves_like
'a valid response to show_label_issuables_link?'
,
:issues
end
context
'when asking for a merge requests link'
do
it_behaves_like
'a valid response to show_label_issuables_link?'
,
:merge_requests
end
end
context
'with a group label'
do
set
(
:group
)
{
create
(
:group
)
}
let
(
:label
)
{
create
(
:group_label
,
group:
group
,
title:
'bug'
)
}
context
'when asking for an issue link'
do
context
'in the context of a project'
do
it_behaves_like
'a valid response to show_label_issuables_link?'
,
:issues
,
true
,
true
end
context
'in the context of a group'
do
let
(
:context_project
)
{
nil
}
it_behaves_like
'a valid response to show_label_issuables_link?'
,
:issues
,
true
,
true
end
end
context
'when asking for a merge requests link'
do
context
'in the context of a project'
do
it_behaves_like
'a valid response to show_label_issuables_link?'
,
:merge_requests
,
true
,
true
end
context
'in the context of a group'
do
let
(
:context_project
)
{
nil
}
it_behaves_like
'a valid response to show_label_issuables_link?'
,
:merge_requests
,
true
,
true
end
end
end
end
describe
'link_to_label'
do
describe
'link_to_label'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:label
)
{
create
(
:label
,
project:
project
)
}
let
(
:label
)
{
create
(
:label
,
project:
project
)
}
...
...
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