summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-06-16 17:51:35 +0000
committerDouwe Maan <douwe@gitlab.com>2017-06-16 17:51:35 +0000
commit9b835d10d2c13b55b84461589542b9c77ab90b45 (patch)
tree76074b7c0865006b6df6e007793f6c5cc391f515 /app
parent11b3e54cfe709fdfcbf3d56fa894c4e8c781cef7 (diff)
parentaeaf58609b401b467cbc0c83d3b0a5cb9c04a440 (diff)
downloadgitlab-ce-9b835d10d2c13b55b84461589542b9c77ab90b45.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]