From 889c25ebde36275340fff1973b21cb94e2ae40e5 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Tue, 14 Nov 2017 13:11:43 +0100 Subject: Guarantee the order of groups in the dropdown 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. --- app/helpers/namespaces_helper.rb | 7 +++++-- 1 file 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' -- cgit v1.2.1