diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-02-12 17:58:39 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-03-15 19:25:37 +0300 |
commit | 0444fa560acd07255960284f19b1de6499cd5910 (patch) | |
tree | 005ce576bbe661242ee58c1e1ddebd9e665bd9ff /app/controllers/projects/labels_controller.rb | |
parent | 178c80a561fa10a157bae6e5d4682b232ae727c7 (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/controllers/projects/labels_controller.rb')
-rw-r--r-- | app/controllers/projects/labels_controller.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index ecac3c395ec..d0334c37b67 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -1,8 +1,8 @@ class Projects::LabelsController < Projects::ApplicationController before_action :module_enabled - before_action :label, only: [:edit, :update, :destroy] + before_action :label, only: [:edit, :update, :destroy, :toggle_subscription] before_action :authorize_read_label! - before_action :authorize_admin_labels!, except: [:index] + before_action :authorize_admin_labels!, except: [:index, :toggle_subscription] respond_to :js, :html @@ -60,6 +60,11 @@ class Projects::LabelsController < Projects::ApplicationController end end + def toggle_subscription + @label.toggle_subscription(current_user) + render nothing: true + end + protected def module_enabled |