summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/assets/stylesheets/pages/labels.scss7
-rw-r--r--app/controllers/groups/labels_controller.rb5
-rw-r--r--app/helpers/labels_helper.rb21
-rw-r--r--app/views/shared/_label.html.haml8
-rw-r--r--config/routes/group.rb6
5 files changed, 27 insertions, 20 deletions
diff --git a/app/assets/stylesheets/pages/labels.scss b/app/assets/stylesheets/pages/labels.scss
index 2f7f7325877..397f89f501a 100644
--- a/app/assets/stylesheets/pages/labels.scss
+++ b/app/assets/stylesheets/pages/labels.scss
@@ -223,6 +223,13 @@
}
.label-subscribe-button {
+ .label-subscribe-button-icon {
+ &[disabled] {
+ opacity: 0.5;
+ pointer-events: none;
+ }
+ }
+
.label-subscribe-button-loading {
display: none;
}
diff --git a/app/controllers/groups/labels_controller.rb b/app/controllers/groups/labels_controller.rb
index 0a3dee5ce39..29528b2cfaa 100644
--- a/app/controllers/groups/labels_controller.rb
+++ b/app/controllers/groups/labels_controller.rb
@@ -1,7 +1,5 @@
class Groups::LabelsController < Groups::ApplicationController
- include ToggleSubscriptionAction
-
- before_action :label, only: [:edit, :update, :destroy, :toggle_subscription]
+ before_action :label, only: [:edit, :update, :destroy]
before_action :authorize_admin_labels!, only: [:new, :create, :edit, :update, :destroy]
before_action :save_previous_label_path, only: [:edit]
@@ -71,7 +69,6 @@ class Groups::LabelsController < Groups::ApplicationController
def label
@label ||= @group.labels.find(params[:id])
end
- alias_method :subscribable_resource, :label
def label_params
params.require(:label).permit(:title, :description, :color)
diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb
index d7cfd24c918..221a84b042f 100644
--- a/app/helpers/labels_helper.rb
+++ b/app/helpers/labels_helper.rb
@@ -68,11 +68,12 @@ module LabelsHelper
end
end
- def toggle_subscription_label_path(label)
- case label
- 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
+ def toggle_subscription_data(label)
+ return unless label.is_a?(ProjectLabel)
+
+ {
+ url: toggle_subscription_namespace_project_label_path(label.project.namespace, label.project, label)
+ }
end
def render_colored_label(label, label_suffix = '', tooltip: true)
@@ -148,11 +149,17 @@ module LabelsHelper
end
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
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
def label_deletion_confirm_text(label)
diff --git a/app/views/shared/_label.html.haml b/app/views/shared/_label.html.haml
index 5cdd18d24f0..40c8d2af226 100644
--- a/app/views/shared/_label.html.haml
+++ b/app/views/shared/_label.html.haml
@@ -18,7 +18,7 @@
= link_to_label(label, subject: @project) do
= pluralize open_issues_count, 'open issue'
- 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) } }
%span= label_subscription_toggle_button_text(label)
- if can?(current_user, :admin_label, label)
@@ -34,10 +34,10 @@
= pluralize open_issues_count, 'open issue'
- 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) } }
%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')
- if can?(current_user, :admin_label, label)
@@ -48,6 +48,6 @@
%span.sr-only Delete
= icon('trash-o')
- - if current_user
+ - if current_user && label.is_a?(ProjectLabel)
:javascript
new Subscription('##{dom_id(label)} .label-subscription');
diff --git a/config/routes/group.rb b/config/routes/group.rb
index 7bb9aa50875..4838c9d91c6 100644
--- a/config/routes/group.rb
+++ b/config/routes/group.rb
@@ -29,10 +29,6 @@ resources :groups, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ } do
resource :avatar, only: [:destroy]
resources :milestones, constraints: { id: /[^\/]+/ }, only: [:index, :show, :update, :new, :create]
- resources :labels, except: [:show], constraints: { id: /\d+/ } do
- member do
- post :toggle_subscription
- end
- end
+ resources :labels, except: [:show], constraints: { id: /\d+/ }
end
end