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
355389d0
Commit
355389d0
authored
Oct 19, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable subscribing to group-level labels
parent
aa781489
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
20 deletions
+27
-20
app/assets/stylesheets/pages/labels.scss
app/assets/stylesheets/pages/labels.scss
+7
-0
app/controllers/groups/labels_controller.rb
app/controllers/groups/labels_controller.rb
+1
-4
app/helpers/labels_helper.rb
app/helpers/labels_helper.rb
+14
-7
app/views/shared/_label.html.haml
app/views/shared/_label.html.haml
+4
-4
config/routes/group.rb
config/routes/group.rb
+1
-5
No files found.
app/assets/stylesheets/pages/labels.scss
View file @
355389d0
...
@@ -223,6 +223,13 @@
...
@@ -223,6 +223,13 @@
}
}
.label-subscribe-button
{
.label-subscribe-button
{
.label-subscribe-button-icon
{
&
[
disabled
]
{
opacity
:
0
.5
;
pointer-events
:
none
;
}
}
.label-subscribe-button-loading
{
.label-subscribe-button-loading
{
display
:
none
;
display
:
none
;
}
}
...
...
app/controllers/groups/labels_controller.rb
View file @
355389d0
class
Groups::LabelsController
<
Groups
::
ApplicationController
class
Groups::LabelsController
<
Groups
::
ApplicationController
include
ToggleSubscriptionAction
before_action
:label
,
only:
[
:edit
,
:update
,
:destroy
]
before_action
:label
,
only:
[
:edit
,
:update
,
:destroy
,
:toggle_subscription
]
before_action
:authorize_admin_labels!
,
only:
[
:new
,
:create
,
:edit
,
:update
,
:destroy
]
before_action
:authorize_admin_labels!
,
only:
[
:new
,
:create
,
:edit
,
:update
,
:destroy
]
before_action
:save_previous_label_path
,
only:
[
:edit
]
before_action
:save_previous_label_path
,
only:
[
:edit
]
...
@@ -71,7 +69,6 @@ class Groups::LabelsController < Groups::ApplicationController
...
@@ -71,7 +69,6 @@ class Groups::LabelsController < Groups::ApplicationController
def
label
def
label
@label
||=
@group
.
labels
.
find
(
params
[
:id
])
@label
||=
@group
.
labels
.
find
(
params
[
:id
])
end
end
alias_method
:subscribable_resource
,
:label
def
label_params
def
label_params
params
.
require
(
:label
).
permit
(
:title
,
:description
,
:color
)
params
.
require
(
:label
).
permit
(
:title
,
:description
,
:color
)
...
...
app/helpers/labels_helper.rb
View file @
355389d0
...
@@ -68,11 +68,12 @@ module LabelsHelper
...
@@ -68,11 +68,12 @@ module LabelsHelper
end
end
end
end
def
toggle_subscription_label_path
(
label
)
def
toggle_subscription_data
(
label
)
case
label
return
unless
label
.
is_a?
(
ProjectLabel
)
when
GroupLabel
then
toggle_subscription_group_label_path
(
label
.
group
,
label
)
when
ProjectLabel
then
toggle_subscription_namespace_project_label_path
(
label
.
project
.
namespace
,
label
.
project
,
label
)
{
end
url:
toggle_subscription_namespace_project_label_path
(
label
.
project
.
namespace
,
label
.
project
,
label
)
}
end
end
def
render_colored_label
(
label
,
label_suffix
=
''
,
tooltip:
true
)
def
render_colored_label
(
label
,
label_suffix
=
''
,
tooltip:
true
)
...
@@ -148,11 +149,17 @@ module LabelsHelper
...
@@ -148,11 +149,17 @@ module LabelsHelper
end
end
def
label_subscription_status
(
label
)
def
label_subscription_status
(
label
)
label
.
subscribed?
(
current_user
)
?
'subscribed'
:
'unsubscribed'
case
label
when
GroupLabel
then
'Subscribing to group labels is currently not supported.'
when
ProjectLabel
then
label
.
subscribed?
(
current_user
)
?
'subscribed'
:
'unsubscribed'
end
end
end
def
label_subscription_toggle_button_text
(
label
)
def
label_subscription_toggle_button_text
(
label
)
label
.
subscribed?
(
current_user
)
?
'Unsubscribe'
:
'Subscribe'
case
label
when
GroupLabel
then
'Subscribing to group labels is currently not supported.'
when
ProjectLabel
then
label
.
subscribed?
(
current_user
)
?
'Unsubscribe'
:
'Subscribe'
end
end
end
def
label_deletion_confirm_text
(
label
)
def
label_deletion_confirm_text
(
label
)
...
...
app/views/shared/_label.html.haml
View file @
355389d0
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
=
link_to_label
(
label
,
subject:
@project
)
do
=
link_to_label
(
label
,
subject:
@project
)
do
=
pluralize
open_issues_count
,
'open issue'
=
pluralize
open_issues_count
,
'open issue'
-
if
current_user
-
if
current_user
%li
.label-subscription
{
data:
{
url:
toggle_subscription_label_path
(
label
)
}
}
%li
.label-subscription
{
data:
toggle_subscription_data
(
label
)
}
%a
.js-subscribe-button.label-subscribe-button.subscription-status
{
role:
"button"
,
href:
"#"
,
data:
{
toggle:
"tooltip"
,
status:
label_subscription_status
(
label
)
}
}
%a
.js-subscribe-button.label-subscribe-button.subscription-status
{
role:
"button"
,
href:
"#"
,
data:
{
toggle:
"tooltip"
,
status:
label_subscription_status
(
label
)
}
}
%span
=
label_subscription_toggle_button_text
(
label
)
%span
=
label_subscription_toggle_button_text
(
label
)
-
if
can?
(
current_user
,
:admin_label
,
label
)
-
if
can?
(
current_user
,
:admin_label
,
label
)
...
@@ -34,10 +34,10 @@
...
@@ -34,10 +34,10 @@
=
pluralize
open_issues_count
,
'open issue'
=
pluralize
open_issues_count
,
'open issue'
-
if
current_user
-
if
current_user
.label-subscription.inline
{
data:
{
url:
toggle_subscription_label_path
(
label
)
}
}
.label-subscription.inline
{
data:
toggle_subscription_data
(
label
)
}
%button
.js-subscribe-button.label-subscribe-button.btn.btn-transparent.btn-action.subscription-status
{
type:
"button"
,
title:
label_subscription_toggle_button_text
(
label
),
data:
{
toggle:
"tooltip"
,
status:
label_subscription_status
(
label
)
}
}
%button
.js-subscribe-button.label-subscribe-button.btn.btn-transparent.btn-action.subscription-status
{
type:
"button"
,
title:
label_subscription_toggle_button_text
(
label
),
data:
{
toggle:
"tooltip"
,
status:
label_subscription_status
(
label
)
}
}
%span
.sr-only
=
label_subscription_toggle_button_text
(
label
)
%span
.sr-only
=
label_subscription_toggle_button_text
(
label
)
=
icon
(
'eye'
,
class:
'label-subscribe-button-icon'
)
=
icon
(
'eye'
,
class:
'label-subscribe-button-icon'
,
disabled:
label
.
is_a?
(
GroupLabel
)
)
=
icon
(
'spinner spin'
,
class:
'label-subscribe-button-loading'
)
=
icon
(
'spinner spin'
,
class:
'label-subscribe-button-loading'
)
-
if
can?
(
current_user
,
:admin_label
,
label
)
-
if
can?
(
current_user
,
:admin_label
,
label
)
...
@@ -48,6 +48,6 @@
...
@@ -48,6 +48,6 @@
%span
.sr-only
Delete
%span
.sr-only
Delete
=
icon
(
'trash-o'
)
=
icon
(
'trash-o'
)
-
if
current_user
-
if
current_user
&&
label
.
is_a?
(
ProjectLabel
)
:javascript
:javascript
new
Subscription
(
'
##{dom_id(label)} .label-subscription
'
);
new
Subscription
(
'
##{dom_id(label)} .label-subscription
'
);
config/routes/group.rb
View file @
355389d0
...
@@ -29,10 +29,6 @@ resources :groups, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ } do
...
@@ -29,10 +29,6 @@ resources :groups, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ } do
resource
:avatar
,
only:
[
:destroy
]
resource
:avatar
,
only:
[
:destroy
]
resources
:milestones
,
constraints:
{
id:
/[^\/]+/
},
only:
[
:index
,
:show
,
:update
,
:new
,
:create
]
resources
:milestones
,
constraints:
{
id:
/[^\/]+/
},
only:
[
:index
,
:show
,
:update
,
:new
,
:create
]
resources
:labels
,
except:
[
:show
],
constraints:
{
id:
/\d+/
}
do
resources
:labels
,
except:
[
:show
],
constraints:
{
id:
/\d+/
}
member
do
post
:toggle_subscription
end
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