summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-11-14 13:11:43 +0100
committerBob Van Landuyt <bob@vanlanduyt.co>2017-11-14 16:57:41 +0100
commit889c25ebde36275340fff1973b21cb94e2ae40e5 (patch)
tree4327b8dc733dbe9b1e1ffd3f099b7a56482d816c
parent022d8420ec0713909ff379e1e8d36c4e46bde3a3 (diff)
downloadgitlab-ce-889c25ebde36275340fff1973b21cb94e2ae40e5.tar.gz
Guarantee the order of groups in the dropdownbvl-subgroup-in-dropdowns
So the groups with the same parent are listed together. The recursive cte seemed to do it by itself, but it is not guaranteed. By ordering on the `route.path` that includes every parent group, we can assume they're going to be in the right order.
-rw-r--r--app/helpers/namespaces_helper.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb
index fa749098d76..b78d3072186 100644
--- a/app/helpers/namespaces_helper.rb
+++ b/app/helpers/namespaces_helper.rb
@@ -4,8 +4,11 @@ module NamespacesHelper
end
def namespaces_options(selected = :current_user, display_path: false, extra_group: nil)
- groups = current_user.manageable_groups.includes(:route)
- users = [current_user.namespace]
+ groups = current_user.manageable_groups
+ .joins(:route)
+ .includes(:route)
+ .order('routes.path')
+ users = [current_user.namespace]
unless extra_group.nil? || extra_group.is_a?(Group)
extra_group = Group.find(extra_group) if Namespace.find(extra_group).kind == 'group'