Skip to content
代码片段 群组 项目
未验证 提交 196a964a 编辑于 作者: Eduardo Sanz García's avatar Eduardo Sanz García 提交者: GitLab
浏览文件

Merge branch 'eduardosanz/service-account-badge' into 'master'

Display `Service Account` badge in members pages

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/166767



Merged-by: default avatarEduardo Sanz García <esanz-garcia@gitlab.com>
Approved-by: default avatarRahul Chanila <rchanila@gitlab.com>
Approved-by: default avatarAndrew Evans <aevans@gitlab.com>
No related branches found
No related tags found
无相关合并请求
......@@ -42,6 +42,11 @@ export const generateBadges = ({ member, isCurrentUser, canManageMembers }) => [
text: __('Enterprise'),
variant: 'info',
},
{
show: member.user?.isServiceAccount ?? false,
text: __('Service Account'),
variant: 'muted',
},
];
/**
......
......@@ -15,6 +15,10 @@ module MemberUserEntity
user.managed_by_user?(options[:current_user], group: options[:source]&.root_ancestor)
end
expose :is_service_account, if: ->(user, _options) { user&.service_account? } do |user|
user&.service_account?
end
def oncall_schedules
object.oncall_schedules.for_project(project_ids)
end
......
......@@ -39,12 +39,13 @@ describe('Members Utils', () => {
});
it.each`
member | expected
${{ ...memberMock, usingLicense: true }} | ${{ show: true, text: 'Is using seat', variant: 'neutral' }}
${{ ...memberMock, groupSso: true }} | ${{ show: true, text: 'SAML', variant: 'info' }}
${{ ...memberMock, groupManagedAccount: true }} | ${{ show: true, text: 'Managed Account', variant: 'info' }}
${{ ...memberMock, canOverride: true }} | ${{ show: true, text: 'LDAP', variant: 'info' }}
${{ ...memberMock, enterpriseUserOfThisGroup: true }} | ${{ show: true, text: 'Enterprise', variant: 'info' }}
member | expected
${{ ...memberMock, usingLicense: true }} | ${{ show: true, text: 'Is using seat', variant: 'neutral' }}
${{ ...memberMock, groupSso: true }} | ${{ show: true, text: 'SAML', variant: 'info' }}
${{ ...memberMock, groupManagedAccount: true }} | ${{ show: true, text: 'Managed Account', variant: 'info' }}
${{ ...memberMock, canOverride: true }} | ${{ show: true, text: 'LDAP', variant: 'info' }}
${{ ...memberMock, enterpriseUserOfThisGroup: true }} | ${{ show: true, text: 'Enterprise', variant: 'info' }}
${{ ...memberMock, ...{ user: { isServiceAccount: true } } }} | ${{ show: true, text: 'Service Account', variant: 'muted' }}
`('returns expected output for "$expected.text" badge', ({ member, expected }) => {
expect(
generateBadges({ member, isCurrentUser: true, canManageMembers: true }),
......
......@@ -192,6 +192,24 @@ def get_url(policy)
end
end
context 'with service account' do
context 'when the current_user is a service account' do
it "exposes `is_service_account`" do
allow(user).to receive(:service_account?).and_return(true)
expect(entity_hash[:is_service_account]).to eq(true)
end
end
context 'when the current_user is not a service account' do
it "does not expose `is_service_account`" do
allow(user).to receive(:service_account?).and_return(false)
expect(entity_hash.keys).not_to include(:is_service_account)
end
end
end
private
def expected_hash(oncall_object)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册