debian-mirror-gitlab/app/controllers/groups/group_members_controller.rb

104 lines
2.5 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2015-04-26 12:48:37 +05:30
class Groups::GroupMembersController < Groups::ApplicationController
include MembershipActions
2018-03-17 18:26:18 +05:30
include MembersPresentation
2017-08-17 22:00:37 +05:30
include SortingHelper
2021-06-08 01:23:25 +05:30
include Gitlab::Utils::StrongMemoize
2019-10-12 21:52:04 +05:30
MEMBER_PER_PAGE_LIMIT = 50
2018-11-08 19:23:39 +05:30
def self.admin_not_required_endpoints
%i[index leave request_access]
end
2015-04-26 12:48:37 +05:30
# Authorize
2018-11-08 19:23:39 +05:30
before_action :authorize_admin_group_member!, except: admin_not_required_endpoints
2022-06-02 21:05:25 +05:30
before_action :authorize_read_group_member!, only: :index
2015-04-26 12:48:37 +05:30
2023-06-20 00:43:36 +05:30
before_action only: [:index] do
push_frontend_feature_flag(:service_accounts_crud, @group)
end
2019-07-07 11:18:12 +05:30
skip_before_action :check_two_factor_requirement, only: :leave
2022-05-07 20:08:51 +05:30
skip_cross_project_access_check :index, :update, :destroy, :request_access,
2023-05-27 22:25:52 +05:30
:approve_access_request, :leave, :resend_invite, :override
2018-03-27 19:54:05 +05:30
2022-06-21 17:19:12 +05:30
feature_category :subgroups
2022-07-16 23:28:13 +05:30
urgency :low
2021-01-03 14:25:43 +05:30
2015-04-26 12:48:37 +05:30
def index
2017-08-17 22:00:37 +05:30
@sort = params[:sort].presence || sort_value_name
2022-07-23 23:45:48 +05:30
@include_relations ||= requested_relations(:groups_with_inherited_permissions)
2020-05-24 23:13:21 +05:30
2021-10-27 15:23:28 +05:30
if can?(current_user, :admin_group_member, @group)
2021-11-18 22:05:49 +05:30
@invited_members = invited_members
2020-05-24 23:13:21 +05:30
@invited_members = @invited_members.search_invite_email(params[:search_invited]) if params[:search_invited].present?
@invited_members = present_invited_members(@invited_members)
2019-10-12 21:52:04 +05:30
end
2021-11-18 22:05:49 +05:30
@members = present_group_members(non_invited_members)
2015-04-26 12:48:37 +05:30
2018-03-17 18:26:18 +05:30
@requesters = present_members(
2020-05-24 23:13:21 +05:30
AccessRequestsFinder.new(@group).execute(current_user)
)
2015-04-26 12:48:37 +05:30
end
# MembershipActions concern
alias_method :membershipable, :group
2020-01-01 13:55:28 +05:30
private
2021-11-18 22:05:49 +05:30
def group_members
@group_members ||= GroupMembersFinder
.new(@group, current_user, params: filter_params)
.execute(include_relations: requested_relations)
end
def invited_members
group_members.invite.with_invited_user_state
end
def non_invited_members
group_members.non_invite
end
2020-05-24 23:13:21 +05:30
def present_invited_members(invited_members)
present_members(invited_members
.page(params[:invited_members_page])
.per(MEMBER_PER_PAGE_LIMIT))
2020-03-13 15:44:24 +05:30
end
2020-05-24 23:13:21 +05:30
def present_group_members(members)
present_members(members
.page(params[:page])
.per(MEMBER_PER_PAGE_LIMIT))
2020-03-13 15:44:24 +05:30
end
2020-05-24 23:13:21 +05:30
def filter_params
2023-05-27 22:25:52 +05:30
params.permit(:two_factor, :search, :user_type).merge(sort: @sort)
2020-01-01 13:55:28 +05:30
end
2021-01-03 14:25:43 +05:30
def membershipable_members
group.members
end
2021-09-04 01:27:46 +05:30
def plain_source_type
'group'
end
def source_type
_("group")
end
def members_page_url
polymorphic_url([group, :members])
end
def root_params_key
:group_member
end
2015-04-26 12:48:37 +05:30
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
Groups::GroupMembersController.prepend_mod_with('Groups::GroupMembersController')