diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-01-19 18:10:27 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-01-22 19:02:04 +0300 |
commit | c56326fc3ef75767abf324f614a4be46153efbb3 (patch) | |
tree | 828eecd4d2dc06bb0104539de124ecac63b5c7fe /app/controllers/concerns | |
parent | b871764787068ce13fa03475e3f1d1a739cdc1b6 (diff) |
Fix filter on `dashboard/groups` & `explore/groups
When searching we would limit the scope of ancestors to load because
the filter would be applied to the ancestors. Instead, we need to load
_all_ ancestors for matching projects.
Diffstat (limited to 'app/controllers/concerns')
-rw-r--r-- | app/controllers/concerns/group_tree.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/controllers/concerns/group_tree.rb b/app/controllers/concerns/group_tree.rb index b569029283f..fafb10090ca 100644 --- a/app/controllers/concerns/group_tree.rb +++ b/app/controllers/concerns/group_tree.rb @@ -2,7 +2,11 @@ module GroupTree # rubocop:disable Gitlab/ModuleWithInstanceVariables def render_group_tree(groups) @groups = if params[:filter].present? - Gitlab::GroupHierarchy.new(groups.search(params[:filter])) + # We find the ancestors by ID of the search results here. + # Otherwise the ancestors would also have filters applied, + # which would cause them not to be preloaded. + group_ids = groups.search(params[:filter]).select(:id) + Gitlab::GroupHierarchy.new(Group.where(id: group_ids)) .base_and_ancestors else # Only show root groups if no parent-id is given |