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
af6c01fb
Commit
af6c01fb
authored
Jun 22, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow users to subscribe to group labels on group labels page
parent
b7ea3ce4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
16 deletions
+68
-16
app/helpers/labels_helper.rb
app/helpers/labels_helper.rb
+7
-6
app/views/shared/_label.html.haml
app/views/shared/_label.html.haml
+10
-10
spec/features/groups/labels/subscription_spec.rb
spec/features/groups/labels/subscription_spec.rb
+51
-0
No files found.
app/helpers/labels_helper.rb
View file @
af6c01fb
...
...
@@ -134,20 +134,21 @@ module LabelsHelper
end
def
label_subscription_status
(
label
,
project
)
return
'project-level'
if
label
.
subscribed?
(
current_user
,
project
)
return
'group-level'
if
label
.
subscribed?
(
current_user
)
return
'project-level'
if
label
.
subscribed?
(
current_user
,
project
)
'unsubscribed'
end
def
group_label_unsubscribe_path
(
label
,
project
)
case
label_subscription_status
(
label
,
project
)
when
'project-level'
then
toggle_subscription_namespace_project_label_path
(
@project
.
namespace
,
@project
,
label
)
when
'group-level'
then
toggle_subscription_group_label_path
(
label
.
group
,
label
)
def
toggle_subscription_label_path
(
label
,
project
)
if
label
.
is_a?
(
GroupLabel
)
toggle_subscription_group_label_path
(
label
.
group
,
label
)
else
toggle_subscription_namespace_project_label_path
(
project
.
namespace
,
project
,
label
)
end
end
def
label_subscription_toggle_button_text
(
label
,
project
)
def
label_subscription_toggle_button_text
(
label
,
project
=
nil
)
label
.
subscribed?
(
current_user
,
project
)
?
'Unsubscribe'
:
'Subscribe'
end
...
...
app/views/shared/_label.html.haml
View file @
af6c01fb
...
...
@@ -17,13 +17,13 @@
%li
=
link_to_label
(
label
,
subject:
subject
)
do
view open issues
-
if
current_user
&&
defined?
(
@project
)
-
if
current_user
%li
.label-subscription
-
if
label
.
is_a?
(
ProjectLabel
)
%a
.js-subscribe-button.label-subscribe-button
{
role:
'button'
,
href:
'#'
,
data:
{
status:
status
,
url:
toggle_subscription_
namespace_project_label_path
(
@project
.
namespace
,
@project
,
label
)
}
}
-
if
defined?
(
@group
)
||
label
.
is_a?
(
ProjectLabel
)
%a
.js-subscribe-button.label-subscribe-button
{
role:
'button'
,
href:
'#'
,
data:
{
status:
status
,
url:
toggle_subscription_
label_path
(
label
,
@project
)
}
}
%span
=
label_subscription_toggle_button_text
(
label
,
@project
)
-
else
%a
.js-unsubscribe-button.label-subscribe-button
{
role:
'button'
,
href:
'#'
,
class:
(
'hidden'
if
status
.
unsubscribed?
),
data:
{
url:
group_label_unsubscribe
_path
(
label
,
@project
)
}
}
%a
.js-unsubscribe-button.label-subscribe-button
{
role:
'button'
,
href:
'#'
,
class:
(
'hidden'
if
status
.
unsubscribed?
),
data:
{
url:
toggle_subscription_label
_path
(
label
,
@project
)
}
}
%span
Unsubscribe
%a
.js-subscribe-button.label-subscribe-button
{
role:
'button'
,
href:
'#'
,
class:
(
'hidden'
unless
status
.
unsubscribed?
),
data:
{
url:
toggle_subscription_namespace_project_label_path
(
@project
.
namespace
,
@project
,
label
)
}
}
%span
Subscribe at project level
...
...
@@ -42,14 +42,14 @@
=
link_to_label
(
label
,
subject:
subject
,
css_class:
'btn btn-transparent btn-action'
)
do
view open issues
-
if
current_user
&&
defined?
(
@project
)
-
if
current_user
.label-subscription.inline
-
if
label
.
is_a?
(
ProjectLabel
)
%button
.js-subscribe-button.label-subscribe-button.btn.btn-default
{
type:
'button'
,
data:
{
status:
status
,
url:
toggle_subscription_
namespace_project_label_path
(
@project
.
namespace
,
@project
,
label
)
}
}
-
if
defined?
(
@group
)
||
label
.
is_a?
(
ProjectLabel
)
%button
.js-subscribe-button.label-subscribe-button.btn.btn-default
{
type:
'button'
,
data:
{
status:
status
,
url:
toggle_subscription_
label_path
(
label
,
@project
)
}
}
%span
=
label_subscription_toggle_button_text
(
label
,
@project
)
=
icon
(
'spinner spin'
,
class:
'label-subscribe-button-loading'
)
-
else
%button
.js-unsubscribe-button.label-subscribe-button.btn.btn-default
{
type:
'button'
,
class:
(
'hidden'
if
status
.
unsubscribed?
),
data:
{
url:
group_label_unsubscribe
_path
(
label
,
@project
)
}
}
%button
.js-unsubscribe-button.label-subscribe-button.btn.btn-default
{
type:
'button'
,
class:
(
'hidden'
if
status
.
unsubscribed?
),
data:
{
url:
toggle_subscription_label
_path
(
label
,
@project
)
}
}
%span
Unsubscribe
=
icon
(
'spinner spin'
,
class:
'label-subscribe-button-loading'
)
...
...
@@ -76,8 +76,8 @@
%span
.sr-only
Delete
=
icon
(
'trash-o'
)
-
if
current_user
&&
defined?
(
@project
)
-
if
label
.
is_a?
(
ProjectLabel
)
-
if
current_user
-
if
defined?
(
@group
)
||
label
.
is_a?
(
ProjectLabel
)
:javascript
new
gl
.
ProjectLabelSubscription
(
'
##{dom_id(label)} .label-subscription
'
);
-
else
...
...
spec/features/groups/labels/subscription_spec.rb
0 → 100644
View file @
af6c01fb
require
'spec_helper'
feature
'Labels subscription'
,
feature:
true
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
let!
(
:feature
)
{
create
(
:group_label
,
group:
group
,
title:
'feature'
)
}
context
'when signed in'
do
before
do
group
.
add_developer
(
user
)
gitlab_sign_in
user
end
scenario
'users can subscribe/unsubscribe to labels'
,
js:
true
do
visit
group_labels_path
(
group
)
expect
(
page
).
to
have_content
(
'feature'
)
within
"#group_label_
#{
feature
.
id
}
"
do
expect
(
page
).
not_to
have_button
'Unsubscribe'
click_button
'Subscribe'
expect
(
page
).
not_to
have_button
'Subscribe'
expect
(
page
).
to
have_button
'Unsubscribe'
click_button
'Unsubscribe'
expect
(
page
).
to
have_button
'Subscribe'
expect
(
page
).
not_to
have_button
'Unsubscribe'
end
end
end
context
'when not signed in'
do
it
'users can not subscribe/unsubscribe to labels'
do
visit
group_labels_path
(
group
)
expect
(
page
).
to
have_content
'feature'
expect
(
page
).
not_to
have_button
(
'Subscribe'
)
end
end
def
click_link_on_dropdown
(
text
)
find
(
'.dropdown-group-label'
).
click
page
.
within
(
'.dropdown-group-label'
)
do
find
(
'a.js-subscribe-button'
,
text:
text
).
click
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