Commit 7ccd1d1b authored by Mark Florian's avatar Mark Florian

Merge branch '214385-indicate-if-a-user-account-is-a-group-managed-account' into 'master'

Add "Managed Account" badge for GMA users

See merge request gitlab-org/gitlab!29633
parents 8cd238a5 e9300f8a
- type ||= 'info'
%span.px-1.py-1
%span{ class: "badge badge-#{type}" }= yield
- if user.blocked?
= render 'shared/members/badge', type: 'danger' do
= _("Blocked")
- if user == current_user
= render 'shared/members/badge', type: 'success' do
= _("It's you")
......@@ -13,24 +13,23 @@
- if user
= image_tag avatar_icon_for_user(user, 40), class: "avatar s40 flex-shrink-0 flex-grow-0", alt: ''
.user-info
= link_to user.name, user_path(user), class: 'member js-user-link', data: { user_id: user.id }
= user_status(user)
%span.cgray= user.to_reference
%span.mr-1
= link_to user.name, user_path(user), class: 'member js-user-link', data: { user_id: user.id }
= user_status(user)
%span.cgray= user.to_reference
= render_if_exists 'shared/members/ee/sso_badge', member: member
.mx-n1.d-inline-flex.flex-wrap
= render_if_exists 'shared/members/ee/sso_badge', member: member
- if user == current_user
%span.badge.badge-success.prepend-left-5= _("It's you")
= render_if_exists 'shared/members/ee/gma_badge', member: member
= render_if_exists 'shared/members/ee/license_badge', user: user, group: @group
= render 'shared/members/its_you_badge', user: user, current_user: current_user
- if user.blocked?
%label.badge.badge-danger
%strong= _("Blocked")
= render_if_exists 'shared/members/ee/license_badge', user: user, group: @group
- if user.two_factor_enabled?
%label.badge.badge-info
= _("2FA")
= render 'shared/members/blocked_badge', user: user
= render 'shared/members/two_factor_auth_badge', user: user
- if source.instance_of?(Group) && source != @group
·
......
- if user.two_factor_enabled?
= render 'shared/members/badge', type: 'info' do
= _("2FA")
......@@ -6,6 +6,10 @@ module EE
member.user.group_sso?(source)
end
def group_managed_account?
member.user.group_managed_account?
end
private
def override_member_permission
......
......@@ -6,6 +6,10 @@ module EE
false
end
def group_managed_account?
false
end
private
def override_member_permission
......
- if member.group_managed_account?
= render 'shared/members/badge', type: 'info' do
= _('Managed Account')
- if group.present? && group.has_owner?(current_user) && user.using_gitlab_com_seat?(group)
%span.badge.badge-light= _("Is using seat")
= render 'shared/members/badge', type: 'light' do
= _("Is using seat")
- if member.group_sso?
%span.badge.badge-info.prepend-left-5 SAML
= render 'shared/members/badge', type: 'info' do
SAML
......@@ -27,7 +27,25 @@ describe 'Groups > Members > List members' do
visit group_group_members_path(group)
member = GroupMember.find_by(user: user2, group: group)
expect(find("#group_member_#{member.id}").find('.badge-info')).to have_content('SAML')
end
end
context 'when user has a "Group Managed Account"' do
let(:managed_group) { create(:group_with_managed_accounts) }
let(:managed_user) { create(:user, :group_managed, managing_group: managed_group) }
before do
managed_group.add_guest(managed_user)
end
it 'shows user with "Managed Account" badge' do
visit group_group_members_path(managed_group)
member = GroupMember.find_by(user: managed_user, group: managed_group)
expect(page).to have_selector("#group_member_#{member.id} .badge-info", text: 'Managed Account')
end
end
end
......@@ -19,6 +19,28 @@ describe GroupMemberPresenter do
end
end
describe '#group_managed_account?' do
context 'when user is part of the group managed account' do
before do
expect(user).to receive(:group_managed_account?).and_return(true)
end
it 'returns `true`' do
expect(presenter.group_managed_account?).to eq true
end
end
context 'when user is not part of the group managed account' do
before do
expect(user).to receive(:group_managed_account?).and_return(false)
end
it 'returns `false`' do
expect(presenter.group_managed_account?).to eq false
end
end
end
describe '#can_update?' do
context 'when user cannot update_group_member but can override_group_member' do
before do
......
......@@ -8,6 +8,18 @@ describe ProjectMemberPresenter do
let(:project_member) { double(:project_member, source: project) }
let(:presenter) { described_class.new(project_member, current_user: user) }
describe '#group_sso?' do
it 'returns `false`' do
expect(presenter.group_sso?).to eq(false)
end
end
describe '#group_managed_account?' do
it 'returns `false`' do
expect(presenter.group_managed_account?).to eq(false)
end
end
describe '#can_update?' do
context 'when user cannot update_project_member but can override_project_member' do
before do
......
......@@ -12521,6 +12521,9 @@ msgstr ""
msgid "Manage your license"
msgstr ""
msgid "Managed Account"
msgstr ""
msgid "Manifest"
msgstr ""
......
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