diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-11-14 15:11:43 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-11-14 18:57:41 +0300 |
commit | 889c25ebde36275340fff1973b21cb94e2ae40e5 (patch) | |
tree | 4327b8dc733dbe9b1e1ffd3f099b7a56482d816c /app/helpers | |
parent | 022d8420ec0713909ff379e1e8d36c4e46bde3a3 (diff) |
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.
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/namespaces_helper.rb | 7 |
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' |