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

work_item_link_child_metadata.vue « shared « components « work_items « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c0e87f0bb6e4512649d7341e998d30e06ce8ae8c (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
92
93
94
<script>
import { GlAvatar, GlAvatarLink, GlAvatarsInline, GlTooltipDirective } from '@gitlab/ui';

import { s__, sprintf } from '~/locale';

import ItemMilestone from '~/issuable/components/issue_milestone.vue';

import { WIDGET_TYPE_MILESTONE, WIDGET_TYPE_ASSIGNEES } from '../../constants';

export default {
  components: {
    GlAvatar,
    GlAvatarLink,
    GlAvatarsInline,
    ItemMilestone,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    metadataWidgets: {
      type: Object,
      required: false,
      default: () => ({}),
    },
  },
  computed: {
    milestone() {
      return this.metadataWidgets[WIDGET_TYPE_MILESTONE]?.milestone;
    },
    assignees() {
      return this.metadataWidgets[WIDGET_TYPE_ASSIGNEES]?.assignees?.nodes || [];
    },
    assigneesCollapsedTooltip() {
      if (this.assignees.length > 2) {
        return sprintf(s__('WorkItem|%{count} more assignees'), {
          count: this.assignees.length - 2,
        });
      }
      return '';
    },
    assigneesContainerClass() {
      if (this.assignees.length === 2) {
        return 'fixed-width-avatars-2';
      }
      if (this.assignees.length > 2) {
        return 'fixed-width-avatars-3';
      }
      return '';
    },
  },
};
</script>

<template>
  <div class="gl-display-flex gl-md-justify-content-end gl-gap-3">
    <slot></slot>
    <item-milestone
      v-if="milestone"
      :milestone="milestone"
      class="gl-display-flex gl-align-items-center gl-max-w-15 gl-font-sm gl-line-height-normal gl-text-secondary! gl-cursor-help! gl-text-decoration-none!"
    />
    <gl-avatars-inline
      v-if="assignees.length"
      :avatars="assignees"
      :collapsed="true"
      :max-visible="2"
      :avatar-size="24"
      badge-tooltip-prop="name"
      :badge-sr-only-text="assigneesCollapsedTooltip"
      :class="assigneesContainerClass"
      class="gl-white-space-nowrap"
    >
      <template #avatar="{ avatar }">
        <gl-avatar-link v-gl-tooltip target="blank" :href="avatar.webUrl" :title="avatar.name">
          <gl-avatar :src="avatar.avatarUrl" :size="24" />
        </gl-avatar-link>
      </template>
    </gl-avatars-inline>
  </div>
</template>

<style scoped>
/**
 * These overrides are needed to address https://gitlab.com/gitlab-org/gitlab-ui/-/issues/865
 */
.fixed-width-avatars-2 {
  width: 42px !important;
}

.fixed-width-avatars-3 {
  width: 67px !important;
}
</style>