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

export default {
  maxTextLength: 95,
  components: {
    GlPopover,
    GlIcon,
    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" triggers="hover" placement="top" container="popover-container">
      <div class="d-flex justify-content-between position-relative">
        <div class="pr-5 w-100 ci-popover-value">{{ displayValue }}</div>
        <gl-button
          v-gl-tooltip
          class="btn-transparent btn-clipboard position-absolute position-top-0 position-right-0"
          :title="tooltipText"
          :data-clipboard-text="value"
        >
          <gl-icon name="copy-to-clipboard" />
        </gl-button>
      </div>
    </gl-popover>
  </div>
</template>