Welcome to mirror list, hosted at ThFree Co, Russian Federation.

user_avatar.vue « users_table « components « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5f197066cb544cde73000dc71774a92001af0148 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<script>
import { GlAvatarLabeled, GlBadge, GlIcon, GlTooltipDirective } from '@gitlab/ui';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { truncate } from '~/lib/utils/text_utility';
import { USER_AVATAR_SIZE, LENGTH_OF_USER_NOTE_TOOLTIP } from './constants';

export default {
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  components: {
    GlAvatarLabeled,
    GlBadge,
    GlIcon,
  },
  mixins: [glFeatureFlagsMixin()],
  props: {
    user: {
      type: Object,
      required: true,
    },
    adminUserPath: {
      type: String,
      required: true,
    },
  },
  computed: {
    subLabel() {
      if (this.user.email) {
        return {
          label: this.user.email,
          link: `mailto:${this.user.email}`,
        };
      }

      return {
        label: `@${this.user.username}`,
      };
    },
    adminUserHref() {
      return this.adminUserPath.replace('id', this.user.username);
    },
    userNoteShort() {
      return truncate(this.user.note, LENGTH_OF_USER_NOTE_TOOLTIP);
    },
  },
  USER_AVATAR_SIZE,
};
</script>

<template>
  <div
    v-if="user"
    class="js-user-link gl-display-inline-block"
    :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="subLabel.label"
      :label-link="adminUserHref"
      :sub-label-link="subLabel.link"
    >
      <template #meta>
        <div v-if="user.note" class="gl-text-gray-500 gl-p-1">
          <gl-icon v-gl-tooltip="userNoteShort" name="document" />
        </div>
        <div
          v-for="(badge, idx) in user.badges"
          :key="idx"
          class="gl-p-1"
          :class="{ 'gl-pb-0': glFeatures.simplifiedBadges }"
        >
          <gl-badge class="gl-display-flex!" size="sm" :variant="badge.variant">{{
            badge.text
          }}</gl-badge>
        </div>
      </template>
    </gl-avatar-labeled>
  </div>
</template>