summaryrefslogtreecommitdiff
path: root/app/finders
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2017-12-06 17:07:47 -0200
committerFelipe Artur <felipefac@gmail.com>2018-01-04 17:28:10 -0200
commit5e148d4e931792733400f59864e1aa886ef55953 (patch)
tree3e08b1776015895dcb242909df01f5db60265d7e /app/finders
parente5a9b9a14d32d890dea20403c977dfd569eb3e17 (diff)
downloadgitlab-ce-5e148d4e931792733400f59864e1aa886ef55953.tar.gz
EE-BACKPORT group boards
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/labels_finder.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/app/finders/labels_finder.rb b/app/finders/labels_finder.rb
index ce432ddbfe6..6de9eb89468 100644
--- a/app/finders/labels_finder.rb
+++ b/app/finders/labels_finder.rb
@@ -1,4 +1,6 @@
class LabelsFinder < UnionFinder
+ include Gitlab::Utils::StrongMemoize
+
def initialize(current_user, params = {})
@current_user = current_user
@params = params
@@ -32,6 +34,8 @@ class LabelsFinder < UnionFinder
label_ids << project.labels
end
end
+ elsif only_group_labels?
+ label_ids << Label.where(group_id: group.id)
else
label_ids << Label.where(group_id: projects.group_ids)
label_ids << Label.where(project_id: projects.select(:id))
@@ -51,6 +55,13 @@ class LabelsFinder < UnionFinder
items.where(title: title)
end
+ def group
+ strong_memoize(:group) do
+ group = Group.find(params[:group_id])
+ authorized_to_read_labels?(group) && group
+ end
+ end
+
def group?
params[:group_id].present?
end
@@ -63,6 +74,10 @@ class LabelsFinder < UnionFinder
params[:project_ids].present?
end
+ def only_group_labels?
+ params[:only_group_labels]
+ end
+
def title
params[:title] || params[:name]
end
@@ -96,9 +111,9 @@ class LabelsFinder < UnionFinder
@projects
end
- def authorized_to_read_labels?(project)
+ def authorized_to_read_labels?(label_parent)
return true if skip_authorization
- Ability.allowed?(current_user, :read_label, project)
+ Ability.allowed?(current_user, :read_label, label_parent)
end
end