debian-mirror-gitlab/app/assets/javascripts/ci_variable_list/components/ci_variable_popover.vue
2020-10-24 23:57:45 +05:30

56 lines
1.2 KiB
Vue

<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" triggers="hover" placement="top" container="popover-container">
<div class="gl-display-flex gl-justify-content-space-between gl-align-items-center">
<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>