summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-06-16 17:51:35 +0000
committerClement Ho <ClemMakesApps@gmail.com>2017-06-19 09:29:09 -0500
commit0e2dc6ab7e5c8d2bbb5fdd06585627e593f1a0ed (patch)
treeaddc51dd767762bbf7ff42f24ef20893816beff8 /app
parentee6fbed71c1ede838227a0f7165bb5a6fb6650db (diff)
downloadgitlab-ce-0e2dc6ab7e5c8d2bbb5fdd06585627e593f1a0ed.tar.gz
Merge branch 'tc-fix-group-finder-subgrouping' into 'master'
Show private subgroups if member of parent group Closes #32135 See merge request !11764
Diffstat (limited to 'app')
-rw-r--r--app/finders/groups_finder.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/app/finders/groups_finder.rb b/app/finders/groups_finder.rb
index f68610e197c..e6fb112e7f2 100644
--- a/app/finders/groups_finder.rb
+++ b/app/finders/groups_finder.rb
@@ -5,8 +5,10 @@ class GroupsFinder < UnionFinder
end
def execute
- groups = find_union(all_groups, Group).with_route.order_id_desc
- by_parent(groups)
+ items = all_groups.map do |item|
+ by_parent(item)
+ end
+ find_union(items, Group).with_route.order_id_desc
end
private
@@ -16,12 +18,22 @@ class GroupsFinder < UnionFinder
def all_groups
groups = []
- groups << current_user.authorized_groups if current_user
+ if current_user
+ groups << Gitlab::GroupHierarchy.new(groups_for_ancestors, groups_for_descendants).all_groups
+ end
groups << Group.unscoped.public_to_user(current_user)
groups
end
+ def groups_for_ancestors
+ current_user.authorized_groups
+ end
+
+ def groups_for_descendants
+ current_user.groups
+ end
+
def by_parent(groups)
return groups unless params[:parent]