Commit 889c25eb authored by Bob Van Landuyt's avatar Bob Van Landuyt

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.
parent 022d8420
...@@ -4,8 +4,11 @@ module NamespacesHelper ...@@ -4,8 +4,11 @@ module NamespacesHelper
end end
def namespaces_options(selected = :current_user, display_path: false, extra_group: nil) def namespaces_options(selected = :current_user, display_path: false, extra_group: nil)
groups = current_user.manageable_groups.includes(:route) groups = current_user.manageable_groups
users = [current_user.namespace] .joins(:route)
.includes(:route)
.order('routes.path')
users = [current_user.namespace]
unless extra_group.nil? || extra_group.is_a?(Group) unless extra_group.nil? || extra_group.is_a?(Group)
extra_group = Group.find(extra_group) if Namespace.find(extra_group).kind == 'group' extra_group = Group.find(extra_group) if Namespace.find(extra_group).kind == 'group'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment