diff options
| author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-09-19 13:11:09 +0200 |
|---|---|---|
| committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-04 22:49:41 +0200 |
| commit | 22aa034427b9392b44d9ecba0a51bb1b6c6616d7 (patch) | |
| tree | 674a46d4ea73af07ccc3b7f5dd56168d4c5c1997 /app/finders | |
| parent | fb7a0f8c335631e1cb8c8f91e135e49528fad70e (diff) | |
| download | gitlab-ce-22aa034427b9392b44d9ecba0a51bb1b6c6616d7.tar.gz | |
Rename `GroupHierarchy` to `GroupDescendant`
Diffstat (limited to 'app/finders')
| -rw-r--r-- | app/finders/group_descendants_finder.rb (renamed from app/finders/group_children_finder.rb) | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/app/finders/group_children_finder.rb b/app/finders/group_descendants_finder.rb index 7c7e7f804ec..f6b938fa732 100644 --- a/app/finders/group_children_finder.rb +++ b/app/finders/group_descendants_finder.rb @@ -1,4 +1,4 @@ -class GroupChildrenFinder +class GroupDescendantsFinder include Gitlab::Allowable attr_reader :current_user, :parent_group, :params @@ -38,31 +38,33 @@ class GroupChildrenFinder private def children - @children ||= subgroups.with_route.includes(:route, :parent) + projects.with_route.includes(:route, :namespace) + @children ||= subgroups.with_route.includes(:parent) + projects.with_route.includes(:namespace) end - def direct_subgroups + def direct_child_groups GroupsFinder.new(current_user, parent: parent_group, all_available: true).execute end - def all_subgroups + def all_descendant_groups Gitlab::GroupHierarchy.new(Group.where(id: parent_group)).base_and_descendants end def subgroups_matching_filter - all_subgroups.where.not(id: parent_group).search(params[:filter]) + all_descendant_groups.where.not(id: parent_group).search(params[:filter]) end def subgroups return Group.none unless Group.supports_nested_groups? return Group.none unless can?(current_user, :read_group, parent_group) + # When filtering subgroups, we want to find all matches withing the tree of + # descendants to show to the user groups = if params[:filter] subgroups_matching_filter else - direct_subgroups + direct_child_groups end groups.sort(params[:sort]) end @@ -74,7 +76,7 @@ class GroupChildrenFinder def projects_matching_filter ProjectsFinder.new(current_user: current_user).execute .search(params[:filter]) - .where(namespace: all_subgroups) + .where(namespace: all_descendant_groups) end def projects |
