Refactoring label subscription toggle button text to accept a project

parent d45c6eca
...@@ -155,10 +155,10 @@ module LabelsHelper ...@@ -155,10 +155,10 @@ module LabelsHelper
end end
end end
def label_subscription_toggle_button_text(label) def label_subscription_toggle_button_text(label, project)
case label case label
when GroupLabel then 'Subscribing to group labels is currently not supported.' when GroupLabel then 'Subscribing to group labels is currently not supported.'
when ProjectLabel then label.subscribed?(current_user) ? 'Unsubscribe' : 'Subscribe' when ProjectLabel then label.subscribed?(current_user, project) ? 'Unsubscribe' : 'Subscribe'
end end
end end
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
= pluralize open_issues_count, 'open issue' = pluralize open_issues_count, 'open issue'
- if current_user - if current_user
%li.label-subscription{ data: toggle_subscription_data(label) } %li.label-subscription{ data: toggle_subscription_data(label) }
%span= label_subscription_toggle_button_text(label)
%a.js-subscribe-button.label-subscribe-button.subscription-status{ role: "button", href: "#", data: { toggle: "tooltip", status: label_subscription_status(label, @project) } } %a.js-subscribe-button.label-subscribe-button.subscription-status{ role: "button", href: "#", data: { toggle: "tooltip", status: label_subscription_status(label, @project) } }
%span= label_subscription_toggle_button_text(label, @project)
- if can?(current_user, :admin_label, label) - if can?(current_user, :admin_label, label)
%li %li
= link_to 'Edit', edit_label_path(label) = link_to 'Edit', edit_label_path(label)
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
- if current_user - if current_user
.label-subscription.inline{ data: toggle_subscription_data(label) } .label-subscription.inline{ data: toggle_subscription_data(label) }
%span.sr-only= label_subscription_toggle_button_text(label)
%button.js-subscribe-button.label-subscribe-button.btn.btn-transparent.btn-action.subscription-status{ type: "button", title: label_subscription_toggle_button_text(label, @project), data: { toggle: "tooltip", status: label_subscription_status(label, @project) } } %button.js-subscribe-button.label-subscribe-button.btn.btn-transparent.btn-action.subscription-status{ type: "button", title: label_subscription_toggle_button_text(label, @project), data: { toggle: "tooltip", status: label_subscription_status(label, @project) } }
%span.sr-only= label_subscription_toggle_button_text(label, @project)
= icon('eye', class: 'label-subscribe-button-icon', disabled: label.is_a?(GroupLabel)) = 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')
......
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