Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-02-12 17:58:39 +0300
committerRémy Coutable <remy@rymai.me>2016-03-15 19:25:37 +0300
commit0444fa560acd07255960284f19b1de6499cd5910 (patch)
tree005ce576bbe661242ee58c1e1ddebd9e665bd9ff /app/views/projects/labels
parent178c80a561fa10a157bae6e5d4682b232ae727c7 (diff)
Original implementation to allow users to subscribe to labels
1. Allow subscribing (the current user) to a label - Refactor the `Subscription` coffeescript class - The main change is that it accepts a container, and conducts all DOM queries within its scope. We need this because the labels page has multiple instances of `Subscription` on the same page. 2. Creating an issue or MR with labels notifies users subscribed to those labels - Label `has_many` subscribers through subscriptions. 3. Adding a label to an issue or MR notifies users subscribed to those labels - This only applies to subscribers of the label that has just been added, not all labels for the issue.
Diffstat (limited to 'app/views/projects/labels')
-rw-r--r--app/views/projects/labels/_label.html.haml12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/views/projects/labels/_label.html.haml b/app/views/projects/labels/_label.html.haml
index f7ddd30c5a9..3b14a925c46 100644
--- a/app/views/projects/labels/_label.html.haml
+++ b/app/views/projects/labels/_label.html.haml
@@ -10,6 +10,18 @@
= link_to_label(label) do
= pluralize label.open_issues_count, 'open issue'
+ - if current_user
+ %div{class: "label-subscription", data: {id: label.id}}
+ - subscribed = label.subscribed?(current_user)
+ - subscription_status = subscribed ? 'subscribed' : 'unsubscribed'
+ .subscription-status{data: {status: subscription_status}}
+ %button.btn.btn-sm.btn-info.subscribe-button{:type => 'button'}
+ %span= subscribed ? 'Unsubscribe' : 'Subscribe'
+
- if can? current_user, :admin_label, @project
= link_to 'Edit', edit_namespace_project_label_path(@project.namespace, @project, label), class: 'btn btn-sm'
= link_to 'Delete', namespace_project_label_path(@project.namespace, @project, label), class: 'btn btn-sm btn-remove remove-row', method: :delete, remote: true, data: {confirm: "Remove this label? Are you sure?"}
+
+:javascript
+ new Subscription("#{toggle_subscription_namespace_project_label_path(@project.namespace, @project, label)}",
+ ".label-subscription[data-id='#{label.id}']");