Commit 4ce8718a authored by Sheldon Led's avatar Sheldon Led Committed by Etienne Baqué

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

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