Disable subscribing to group-level labels

parent aa781489
...@@ -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;
} }
......
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)
......
...@@ -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)
......
...@@ -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');
...@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment