BigW Consortium Gitlab

Sort group/project members alphabetically by default

parent 4b7a3d0c
class Groups::GroupMembersController < Groups::ApplicationController class Groups::GroupMembersController < Groups::ApplicationController
include MembershipActions include MembershipActions
include SortingHelper
# Authorize # Authorize
before_action :authorize_admin_group_member!, except: [:index, :leave, :request_access] before_action :authorize_admin_group_member!, except: [:index, :leave, :request_access]
def index def index
@sort = params[:sort].presence || sort_value_name
@project = @group.projects.find(params[:project_id]) if params[:project_id] @project = @group.projects.find(params[:project_id]) if params[:project_id]
@members = @group.group_members @members = @group.group_members
@members = @members.non_invite unless can?(current_user, :admin_group, @group) @members = @members.non_invite unless can?(current_user, :admin_group, @group)
@members = @members.search(params[:search]) if params[:search].present? @members = @members.search(params[:search]) if params[:search].present?
@members = @members.sort(@sort = params[:sort]) if params[:sort].present? @members = @members.sort(@sort)
@members = @members.page(params[:page]).per(50) @members = @members.page(params[:page]).per(50)
@requesters = AccessRequestsFinder.new(@group).execute(current_user) @requesters = AccessRequestsFinder.new(@group).execute(current_user)
......
- @sort ||= sort_value_last_joined
.dropdown.inline .dropdown.inline
= dropdown_toggle(member_sort_options_hash[@sort], { toggle: 'dropdown' }, { id: 'sort-members-dropdown' }) = dropdown_toggle(member_sort_options_hash[@sort], { toggle: 'dropdown' }, { id: 'sort-members-dropdown' })
%ul.dropdown-menu.dropdown-menu-align-right.dropdown-menu-selectable %ul.dropdown-menu.dropdown-menu-align-right.dropdown-menu-selectable
......
...@@ -12,6 +12,13 @@ feature 'Groups > Members > Sorting', feature: true do ...@@ -12,6 +12,13 @@ feature 'Groups > Members > Sorting', feature: true do
login_as(owner) login_as(owner)
end end
scenario 'sorts alphabetically by default' do
visit_members_list(sort: nil)
expect(first_member).to include(owner.name)
expect(second_member).to include(developer.name)
end
scenario 'sorts by access level ascending' do scenario 'sorts by access level ascending' do
visit_members_list(sort: :access_level_asc) visit_members_list(sort: :access_level_asc)
......
...@@ -12,6 +12,13 @@ feature 'Projects > Members > Sorting', feature: true do ...@@ -12,6 +12,13 @@ feature 'Projects > Members > Sorting', feature: true do
login_as(master) login_as(master)
end end
scenario 'sorts alphabetically by default' do
visit_members_list(sort: nil)
expect(first_member).to include(master.name)
expect(second_member).to include(developer.name)
end
scenario 'sorts by access level ascending' do scenario 'sorts by access level ascending' do
visit_members_list(sort: :access_level_asc) visit_members_list(sort: :access_level_asc)
......
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