Commit 6e931ae1 authored by Jannik Lehmann's avatar Jannik Lehmann

Add check if user is bot to Users API

This commit solves
https://gitlab.com/gitlab-org/gitlab/-/issues/300068
The check whether or not a user is a bot
is now consumed from the API the feature flag
for the securityAutoFix was removed.
parent 252ebf2c
...@@ -36,6 +36,7 @@ const populateUserInfo = (user) => { ...@@ -36,6 +36,7 @@ const populateUserInfo = (user) => {
if (userData) { if (userData) {
Object.assign(user, { Object.assign(user, {
avatarUrl: userData.avatar_url, avatarUrl: userData.avatar_url,
bot: userData.bot,
username: userData.username, username: userData.username,
name: userData.name, name: userData.name,
location: userData.location, location: userData.location,
......
...@@ -12,11 +12,6 @@ import UserAvatarImage from '../user_avatar/user_avatar_image.vue'; ...@@ -12,11 +12,6 @@ import UserAvatarImage from '../user_avatar/user_avatar_image.vue';
const MAX_SKELETON_LINES = 4; const MAX_SKELETON_LINES = 4;
const SECURITY_BOT_USER_DATA = {
username: 'GitLab-Security-Bot',
name: 'GitLab Security Bot',
};
export default { export default {
name: 'UserPopover', name: 'UserPopover',
maxSkeletonLines: MAX_SKELETON_LINES, maxSkeletonLines: MAX_SKELETON_LINES,
...@@ -56,15 +51,6 @@ export default { ...@@ -56,15 +51,6 @@ export default {
userIsLoading() { userIsLoading() {
return !this.user?.loaded; return !this.user?.loaded;
}, },
isSecurityBot() {
const { username, name, websiteUrl = '' } = this.user;
return (
gon.features?.securityAutoFix &&
username === SECURITY_BOT_USER_DATA.username &&
name === SECURITY_BOT_USER_DATA.name &&
websiteUrl.length
);
},
availabilityStatus() { availabilityStatus() {
return this.user?.status?.availability || ''; return this.user?.status?.availability || '';
}, },
...@@ -114,7 +100,7 @@ export default { ...@@ -114,7 +100,7 @@ export default {
<div v-if="statusHtml" class="js-user-status gl-mt-3"> <div v-if="statusHtml" class="js-user-status gl-mt-3">
<span v-html="statusHtml"></span> <span v-html="statusHtml"></span>
</div> </div>
<div v-if="isSecurityBot" class="gl-text-blue-500"> <div v-if="user.bot" class="gl-text-blue-500">
<gl-icon name="question" /> <gl-icon name="question" />
<gl-link data-testid="user-popover-bot-docs-link" :href="user.websiteUrl"> <gl-link data-testid="user-popover-bot-docs-link" :href="user.websiteUrl">
{{ sprintf(__('Learn more about %{username}'), { username: user.name }) }} {{ sprintf(__('Learn more about %{username}'), { username: user.name }) }}
......
---
title: Consume check if user is bot from Users API
merge_request: 56362
author:
type: changed
...@@ -9,6 +9,7 @@ const DEFAULT_PROPS = { ...@@ -9,6 +9,7 @@ const DEFAULT_PROPS = {
username: 'root', username: 'root',
name: 'Administrator', name: 'Administrator',
location: 'Vienna', location: 'Vienna',
bot: true,
bio: null, bio: null,
workInformation: null, workInformation: null,
status: null, status: null,
...@@ -244,14 +245,5 @@ describe('User Popover Component', () => { ...@@ -244,14 +245,5 @@ describe('User Popover Component', () => {
expect(securityBotDocsLink.exists()).toBe(true); expect(securityBotDocsLink.exists()).toBe(true);
expect(securityBotDocsLink.attributes('href')).toBe(SECURITY_BOT_USER.websiteUrl); expect(securityBotDocsLink.attributes('href')).toBe(SECURITY_BOT_USER.websiteUrl);
}); });
it('does not show the link if the feature flag is disabled', () => {
window.gon.features = {
securityAutoFix: false,
};
createWrapper({ user: SECURITY_BOT_USER });
expect(findSecurityBotDocsLink().exists()).toBe(false);
});
}); });
}); });
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