summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ci_variable_list/components/ci_variable_popover.vue
blob: 605da5d9352101c3e0228c7ec787b4a1f0d08c2c (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
<script>
import { GlPopover, GlButton, GlTooltipDirective } from '@gitlab/ui';

export default {
  maxTextLength: 95,
  components: {
    GlPopover,
    GlButton,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    target: {
      type: String,
      required: true,
    },
    value: {
      type: String,
      required: true,
    },
    tooltipText: {
      type: String,
      required: true,
    },
  },
  computed: {
    displayValue() {
      if (this.value.length > this.$options.maxTextLength) {
        return `${this.value.substring(0, this.$options.maxTextLength)}...`;
      }
      return this.value;
    },
  },
};
</script>

<template>
  <div id="popover-container">
    <gl-popover :target="target" placement="top" container="popover-container">
      <div
        class="gl-display-flex gl-justify-content-space-between gl-align-items-center gl-word-break-all"
      >
        <div class="ci-popover-value gl-pr-3">
          {{ displayValue }}
        </div>
        <gl-button
          v-gl-tooltip
          category="tertiary"
          icon="copy-to-clipboard"
          :title="tooltipText"
          :data-clipboard-text="value"
          :aria-label="__('Copy to clipboard')"
        />
      </div>
    </gl-popover>
  </div>
</template>