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) => {
if (userData) {
Object.assign(user, {
avatarUrl: userData.avatar_url,
bot: userData.bot,
username: userData.username,
name: userData.name,
location: userData.location,
......
......@@ -12,11 +12,6 @@ import UserAvatarImage from '../user_avatar/user_avatar_image.vue';
const MAX_SKELETON_LINES = 4;
const SECURITY_BOT_USER_DATA = {
username: 'GitLab-Security-Bot',
name: 'GitLab Security Bot',
};
export default {
name: 'UserPopover',
maxSkeletonLines: MAX_SKELETON_LINES,
......@@ -56,15 +51,6 @@ export default {
userIsLoading() {
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() {
return this.user?.status?.availability || '';
},
......@@ -114,7 +100,7 @@ export default {
<div v-if="statusHtml" class="js-user-status gl-mt-3">
<span v-html="statusHtml"></span>
</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-link data-testid="user-popover-bot-docs-link" :href="user.websiteUrl">
{{ 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 = {
username: 'root',
name: 'Administrator',
location: 'Vienna',
bot: true,
bio: null,
workInformation: null,
status: null,
......@@ -244,14 +245,5 @@ describe('User Popover Component', () => {
expect(securityBotDocsLink.exists()).toBe(true);
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