debian-mirror-gitlab/app/assets/javascripts/admin/users/components/user_avatar.vue

70 lines
1.8 KiB
Vue
Raw Normal View History

2021-03-08 18:12:59 +05:30
<script>
2021-03-11 19:13:27 +05:30
import { GlAvatarLabeled, GlBadge, GlIcon, GlTooltipDirective } from '@gitlab/ui';
import { truncate } from '~/lib/utils/text_utility';
import { USER_AVATAR_SIZE, LENGTH_OF_USER_NOTE_TOOLTIP } from '../constants';
2021-03-08 18:12:59 +05:30
export default {
2021-03-11 19:13:27 +05:30
directives: {
GlTooltip: GlTooltipDirective,
},
2021-03-08 18:12:59 +05:30
components: {
GlAvatarLabeled,
GlBadge,
2021-03-11 19:13:27 +05:30
GlIcon,
2021-03-08 18:12:59 +05:30
},
props: {
user: {
type: Object,
required: true,
},
adminUserPath: {
type: String,
required: true,
},
},
computed: {
adminUserHref() {
return this.adminUserPath.replace('id', this.user.username);
},
2021-03-11 19:13:27 +05:30
adminUserMailto() {
// NOTE: 'mailto:' is a false positive: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26#possible-false-positives
// eslint-disable-next-line @gitlab/require-i18n-strings
return `mailto:${this.user.email}`;
},
userNoteShort() {
return truncate(this.user.note, LENGTH_OF_USER_NOTE_TOOLTIP);
},
2021-03-08 18:12:59 +05:30
},
USER_AVATAR_SIZE,
};
</script>
<template>
2021-03-11 19:13:27 +05:30
<div
2021-03-08 18:12:59 +05:30
v-if="user"
2021-03-11 19:13:27 +05:30
class="js-user-link gl-display-inline-block"
2021-03-08 18:12:59 +05:30
:data-user-id="user.id"
:data-username="user.username"
>
<gl-avatar-labeled
:size="$options.USER_AVATAR_SIZE"
:src="user.avatarUrl"
:label="user.name"
:sub-label="user.email"
2021-03-11 19:13:27 +05:30
:label-link="adminUserHref"
:sub-label-link="adminUserMailto"
2021-03-08 18:12:59 +05:30
>
<template #meta>
2021-03-11 19:13:27 +05:30
<div v-if="user.note" class="gl-text-gray-500 gl-p-1">
<gl-icon v-gl-tooltip="userNoteShort" name="document" />
</div>
2021-03-08 18:12:59 +05:30
<div v-for="(badge, idx) in user.badges" :key="idx" class="gl-p-1">
<gl-badge class="gl-display-flex!" size="sm" :variant="badge.variant">{{
badge.text
}}</gl-badge>
</div>
</template>
</gl-avatar-labeled>
2021-03-11 19:13:27 +05:30
</div>
2021-03-08 18:12:59 +05:30
</template>