diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 5f259bd7e27..478154dc265 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -3,7 +3,7 @@ class Admin::UsersController < AdminController @admin_users = User.scoped @admin_users = @admin_users.filter(params[:filter]) @admin_users = @admin_users.search(params[:name]) if params[:name].present? - @admin_users = @admin_users.order("name ASC").page(params[:page]) + @admin_users = @admin_users.alphabetically.page(params[:page]) end def show diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 52715a265bd..2a33bae24f3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -78,7 +78,8 @@ module ApplicationHelper end def search_autocomplete_source - projects = current_user.projects.map{ |p| { label: p.name_with_namespace, url: project_path(p) } } + projects = current_user.authorized_projects.map { |p| { label: p.name_with_namespace, url: project_path(p) } } + groups = current_user.authorized_groups.map { |group| { label: " #{group.name}", url: group_path(group) } } default_nav = [ { label: "My Profile", url: profile_path }, @@ -113,7 +114,7 @@ module ApplicationHelper ] end - [projects, default_nav, project_nav, help_nav].flatten.to_json + [groups, projects, default_nav, project_nav, help_nav].flatten.to_json end def emoji_autocomplete_source diff --git a/app/models/user.rb b/app/models/user.rb index c2486fd3a16..ae0680b70ea 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -80,6 +80,7 @@ class User < ActiveRecord::Base scope :admins, where(admin: true) scope :blocked, where(blocked: true) scope :active, where(blocked: false) + scope :alphabetically, order('name ASC') class << self def filter filter_name diff --git a/app/views/groups/_new_group_member.html.haml b/app/views/groups/_new_group_member.html.haml index ddda038a6c3..2d599816e2a 100644 --- a/app/views/groups/_new_group_member.html.haml +++ b/app/views/groups/_new_group_member.html.haml @@ -5,7 +5,7 @@ %h6 1. Choose people you want in the team .clearfix = f.label :user_ids, "People" - .input= select_tag(:user_ids, options_from_collection_for_select(User.active.order('name ASC'), :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) + .input= select_tag(:user_ids, options_from_collection_for_select(User.active.alphabetically, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) %h6 2. Set access level for them .clearfix diff --git a/app/views/groups/_new_member.html.haml b/app/views/groups/_new_member.html.haml index c36d1920caf..89ac05e774e 100644 --- a/app/views/groups/_new_member.html.haml +++ b/app/views/groups/_new_member.html.haml @@ -5,7 +5,7 @@ %h6 1. Choose people you want in the team .clearfix = f.label :user_ids, "People" - .input= select_tag(:user_ids, options_from_collection_for_select(User.not_in_project(@project).order('name').all, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) + .input= select_tag(:user_ids, options_from_collection_for_select(User.not_in_project(@project).alphabetically, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) %h6 2. Set access level for them .clearfix diff --git a/app/views/team_members/_form.html.haml b/app/views/team_members/_form.html.haml index e5d9a4a4b5e..a963e462a78 100644 --- a/app/views/team_members/_form.html.haml +++ b/app/views/team_members/_form.html.haml @@ -11,7 +11,7 @@ %h6 1. Choose people you want in the team .clearfix = f.label :user_ids, "People" - .input= select_tag(:user_ids, options_from_collection_for_select(User.active.not_in_project(@project).all, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) + .input= select_tag(:user_ids, options_from_collection_for_select(User.active.not_in_project(@project).alphabetically, :id, :name), {data: {placeholder: "Select users"}, class: "chosen xxlarge", multiple: true}) %h6 2. Set access level for them .clearfix