Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-11-14 15:11:43 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2017-11-14 18:57:41 +0300
commit889c25ebde36275340fff1973b21cb94e2ae40e5 (patch)
tree4327b8dc733dbe9b1e1ffd3f099b7a56482d816c
parent022d8420ec0713909ff379e1e8d36c4e46bde3a3 (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.
-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'