summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/user_popover/user_popover.vue
blob: f9773622001e20f2af71f23df604f9c6ee3925c1 (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
84
85
86
87
88
89
90
91
<script>
import { GlPopover, GlSkeletonLoading } from '@gitlab/ui';
import UserAvatarImage from '../user_avatar/user_avatar_image.vue';
import { glEmojiTag } from '../../../emoji';

export default {
  name: 'UserPopover',
  components: {
    GlPopover,
    GlSkeletonLoading,
    UserAvatarImage,
  },
  props: {
    target: {
      type: HTMLAnchorElement,
      required: true,
    },
    user: {
      type: Object,
      required: true,
      default: null,
    },
    loaded: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  computed: {
    statusHtml() {
      if (this.user.status.emoji && this.user.status.message_html) {
        return `${glEmojiTag(this.user.status.emoji)} ${this.user.status.message_html}`;
      } else if (this.user.status.message_html) {
        return this.user.status.message_html;
      }
      return '';
    },
    nameIsLoading() {
      return !this.user.name;
    },
    jobInfoIsLoading() {
      return !this.user.loaded && this.user.organization === null;
    },
    locationIsLoading() {
      return !this.user.loaded && this.user.location === null;
    },
  },
};
</script>

<template>
  <gl-popover :target="target" boundary="viewport" placement="top" show>
    <div class="user-popover d-flex">
      <div class="p-1 flex-shrink-1">
        <user-avatar-image :img-src="user.avatarUrl" :size="60" css-classes="mr-2" />
      </div>
      <div class="p-1 w-100">
        <h5 class="m-0">
          {{ user.name }}
          <gl-skeleton-loading
            v-if="nameIsLoading"
            :lines="1"
            class="animation-container-small mb-1"
          />
        </h5>
        <div class="text-secondary mb-2">
          <span v-if="user.username">@{{ user.username }}</span>
          <gl-skeleton-loading v-else :lines="1" class="animation-container-small mb-1" />
        </div>
        <div class="text-secondary">
          <div v-if="user.bio" class="js-bio">{{ user.bio }}</div>
          <div v-if="user.organization" class="js-organization">{{ user.organization }}</div>
          <gl-skeleton-loading
            v-if="jobInfoIsLoading"
            :lines="1"
            class="animation-container-small mb-1"
          />
        </div>
        <div class="text-secondary">
          {{ user.location }}
          <gl-skeleton-loading
            v-if="locationIsLoading"
            :lines="1"
            class="animation-container-small mb-1"
          />
        </div>
        <div v-if="user.status" class="mt-2"><span v-html="statusHtml"></span></div>
      </div>
    </div>
  </gl-popover>
</template>