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

metadata_item.vue « registry « 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: 93396219a54d0c4bf02c7aedd2fb0408d23ca90b (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
<script>
import { GlIcon, GlLink, GlTooltipDirective } from '@gitlab/ui';
import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate.vue';

export default {
  name: 'MetadataItem',
  components: {
    GlIcon,
    GlLink,
    TooltipOnTruncate,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    icon: {
      type: String,
      required: false,
      default: null,
    },
    text: {
      type: String,
      required: true,
    },
    link: {
      type: String,
      required: false,
      default: '',
    },
    size: {
      type: String,
      required: false,
      default: 's',
      validator(value) {
        return !value || ['xs', 's', 'm', 'l', 'xl'].includes(value);
      },
    },
    textTooltip: {
      type: String,
      required: false,
      default: '',
    },
  },
  computed: {
    sizeClass() {
      return `mw-${this.size}`;
    },
  },
};
</script>

<template>
  <div class="gl-display-inline-flex gl-align-items-center">
    <gl-icon v-if="icon" :name="icon" class="gl-text-gray-500 gl-mr-3" />
    <tooltip-on-truncate v-if="link" :title="text" class="gl-text-truncate" :class="sizeClass">
      <gl-link :href="link" class="gl-font-weight-bold">
        {{ text }}
      </gl-link>
    </tooltip-on-truncate>
    <div
      v-else
      data-testid="metadata-item-text"
      class="gl-font-weight-bold gl-display-inline-flex"
      :class="sizeClass"
    >
      <tooltip-on-truncate v-if="!textTooltip" :title="text" class="gl-text-truncate">
        {{ text }}
      </tooltip-on-truncate>
      <span v-else v-gl-tooltip="{ title: textTooltip }" data-testid="text-tooltip-container">
        {{ text }}</span
      >
    </div>
  </div>
</template>