Commit e94d3822 authored by Etienne Baqué's avatar Etienne Baqué

Merge branch 'led/334288-add-pending-users-invited-tab' into 'master'

Add pending SaaS users to "Invited" members tab [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!70675
parents 21c07411 4ce8718a
......@@ -25,19 +25,15 @@ class Groups::GroupMembersController < Groups::ApplicationController
def index
@sort = params[:sort].presence || sort_value_name
@members = GroupMembersFinder
.new(@group, current_user, params: filter_params)
.execute(include_relations: requested_relations)
if can?(current_user, :admin_group_member, @group)
@skip_groups = @group.related_group_ids
@invited_members = @members.invite
@invited_members = invited_members
@invited_members = @invited_members.search_invite_email(params[:search_invited]) if params[:search_invited].present?
@invited_members = present_invited_members(@invited_members)
end
@members = present_group_members(@members.non_invite)
@members = present_group_members(non_invited_members)
@requesters = present_members(
AccessRequestsFinder.new(@group).execute(current_user)
......@@ -51,6 +47,20 @@ class Groups::GroupMembersController < Groups::ApplicationController
private
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
end
def non_invited_members
group_members.non_invite
end
def present_invited_members(invited_members)
present_members(invited_members
.page(params[:invited_members_page])
......
......@@ -19,16 +19,12 @@ class Projects::ProjectMembersController < Projects::ApplicationController
@group_links = @project.project_group_links
@group_links = @group_links.search(params[:search_groups]) if params[:search_groups].present?
project_members = MembersFinder
.new(@project, current_user, params: filter_params)
.execute(include_relations: requested_relations)
if can?(current_user, :admin_project_member, @project)
@invited_members = present_members(project_members.invite)
@invited_members = present_members(invited_members)
@requesters = present_members(AccessRequestsFinder.new(@project).execute(current_user))
end
@project_members = present_members(project_members.non_invite.page(params[:page]))
@project_members = present_members(non_invited_members.page(params[:page]))
@project_member = @project.project_members.new
end
......@@ -55,6 +51,20 @@ class Projects::ProjectMembersController < Projects::ApplicationController
private
def members
@members ||= MembersFinder
.new(@project, current_user, params: filter_params)
.execute(include_relations: requested_relations)
end
def invited_members
members.invite
end
def non_invited_members
members.non_invite
end
def filter_params
params.permit(:search).merge(sort: @sort)
end
......
......@@ -53,6 +53,16 @@ module EE
protected
override :invited_members
def invited_members
super.or(group_members.awaiting)
end
override :non_invited_members
def non_invited_members
super.non_awaiting
end
def authorize_update_group_member!
unless can?(current_user, :admin_group_member, group) || can?(current_user, :override_group_member, group)
render_403
......
......@@ -4,6 +4,7 @@ module EE
module Projects
module ProjectMembersController
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
prepended do
before_action :check_membership_lock!, only: [:create, :import, :apply_import]
......@@ -12,6 +13,18 @@ module EE
def check_membership_lock!
access_denied!('Membership is locked by group settings') if membership_locked?
end
protected
override :invited_members
def invited_members
super.or(members.awaiting)
end
override :non_invited_members
def non_invited_members
super.non_awaiting
end
end
end
end
......@@ -25,6 +25,8 @@ module EE
state :awaiting, value: STATE_AWAITING
state :active, value: STATE_ACTIVE
end
scope :awaiting, -> {where(state: STATE_AWAITING)}
scope :non_awaiting, -> {where.not(state: STATE_AWAITING)}
before_create :set_membership_activation
......
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