summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-01-14 17:59:32 +0000
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-01-14 17:59:32 +0000
commitb27654b026a78ca96e1c7bbf7fa8edfa7a86151a (patch)
treeb0ce025a575fc760cc814bdae2085e75c517a46d
parentbf8e174f0ae21b320c17b5a8f8d45aefcfef9520 (diff)
downloadgitlab-ce-add-subscribed-labels-list.tar.gz
added a subscribed sub listadd-subscribed-labels-list
-rw-r--r--app/assets/stylesheets/pages/labels.scss5
-rw-r--r--app/controllers/projects/labels_controller.rb11
-rw-r--r--app/views/projects/labels/index.html.haml11
3 files changed, 25 insertions, 2 deletions
diff --git a/app/assets/stylesheets/pages/labels.scss b/app/assets/stylesheets/pages/labels.scss
index 78683c7d574..df8d43db5f5 100644
--- a/app/assets/stylesheets/pages/labels.scss
+++ b/app/assets/stylesheets/pages/labels.scss
@@ -147,9 +147,12 @@
color: $gray-darkest;
}
-.prioritized-labels {
+.prioritized-labels,
+.subscribed-labels {
margin-bottom: 30px;
+}
+.prioritized-labels {
.add-priority {
display: none;
color: $gray-light;
diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb
index 824ed7be73e..3e588f40dba 100644
--- a/app/controllers/projects/labels_controller.rb
+++ b/app/controllers/projects/labels_controller.rb
@@ -13,7 +13,16 @@ class Projects::LabelsController < Projects::ApplicationController
def index
@prioritized_labels = @available_labels.prioritized(@project)
- @labels = @available_labels.unprioritized(@project).page(params[:page])
+
+ subscribed_label_ids = Subscription.where(user_id: current_user,
+ project_id: project,
+ subscribable_type: 'Label',
+ subscribed: true)
+ .map(&:subscribable_id)
+
+ @subscribed_labels = @available_labels.find(subscribed_label_ids)
+
+ @labels = @available_labels.where.not(id: subscribed_label_ids).unprioritized(@project).page(params[:page])
respond_to do |format|
format.html
diff --git a/app/views/projects/labels/index.html.haml b/app/views/projects/labels/index.html.haml
index 05a8475dcd6..2cdaa31bf43 100644
--- a/app/views/projects/labels/index.html.haml
+++ b/app/views/projects/labels/index.html.haml
@@ -24,6 +24,17 @@
- if @prioritized_labels.present?
= render partial: 'shared/label', subject: @project, collection: @prioritized_labels, as: :label
+
+ - if can?(current_user, :admin_label, @project)
+ -# Only show it in the first page
+ - hide = @available_labels.empty? || (params[:page].present? && params[:page] != '1')
+ .subscribed-labels{ class: ('hide' if hide) }
+ %h5 Subscribed Labels
+ %ul.content-list.manage-labels-list.js-subscribed-labels
+ %p.empty-message{ class: ('hidden' unless @subscribed_labels.empty?) } No subscribed labels yet
+ - if @subscribed_labels.present?
+ = render partial: 'shared/label', subject: @project, collection: @subscribed_labels, as: :label
+
.other-labels
- if can?(current_user, :admin_label, @project)
%h5{ class: ('hide' if hide) } Other Labels