diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-01-19 16:10:27 +0100 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-01-22 17:02:04 +0100 |
commit | c56326fc3ef75767abf324f614a4be46153efbb3 (patch) | |
tree | 828eecd4d2dc06bb0104539de124ecac63b5c7fe /app/controllers | |
parent | b871764787068ce13fa03475e3f1d1a739cdc1b6 (diff) | |
download | gitlab-ce-c56326fc3ef75767abf324f614a4be46153efbb3.tar.gz |
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')
-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 |