summaryrefslogtreecommitdiff
path: root/app/finders/labels_finder.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-09-27 17:19:28 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-10-04 10:24:50 +0200
commit600a10b9d14c0d581efd270a68944957af762a17 (patch)
treed7f4fc6bf5abc9f1199b4256eb70f099f2e8c33c /app/finders/labels_finder.rb
parent2243e4d4ca4bbd96a05059d463d283d468a3fc57 (diff)
downloadgitlab-ce-600a10b9d14c0d581efd270a68944957af762a17.tar.gz
Add subscribe filter to labels page
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/finders/labels_finder.rb')
-rw-r--r--app/finders/labels_finder.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/finders/labels_finder.rb b/app/finders/labels_finder.rb
index 08fc2968e77..82e0b2ed9e1 100644
--- a/app/finders/labels_finder.rb
+++ b/app/finders/labels_finder.rb
@@ -17,6 +17,7 @@ class LabelsFinder < UnionFinder
@skip_authorization = skip_authorization
items = find_union(label_ids, Label) || Label.none
items = with_title(items)
+ items = by_subscription(items)
items = by_search(items)
sort(items)
end
@@ -84,6 +85,18 @@ class LabelsFinder < UnionFinder
labels.search(params[:search])
end
+ def by_subscription(labels)
+ labels.optionally_subscribed_by(subscriber_id)
+ end
+
+ def subscriber_id
+ current_user&.id if subscribed?
+ end
+
+ def subscribed?
+ params[:subscribed] == 'true'
+ end
+
# Gets redacted array of group ids
# which can include the ancestors and descendants of the requested group.
def group_ids_for(group)