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
|
<script>
import { GlButton, GlDisclosureDropdown, GlFormInputGroup, GlTooltipDirective } from '@gitlab/ui';
import { escape as esc } from 'lodash';
import { __ } from '~/locale';
const MSG_EMBED = __('Embed');
const MSG_SHARE = __('Share');
const MSG_COPY = __('Copy');
export default {
components: {
GlButton,
GlDisclosureDropdown,
GlFormInputGroup,
},
directives: {
GlTooltip: GlTooltipDirective,
},
props: {
url: {
type: String,
required: true,
},
},
computed: {
sections() {
return [
// eslint-disable-next-line no-useless-escape
{ name: MSG_EMBED, value: `<script src="${esc(this.url)}.js"><\/script>` },
{ name: MSG_SHARE, value: this.url },
];
},
},
MSG_EMBED,
MSG_COPY,
};
</script>
<template>
<gl-disclosure-dropdown
:auto-close="false"
fluid-width
placement="right"
:toggle-text="$options.MSG_EMBED"
>
<template v-for="{ name, value } in sections">
<div :key="name" :data-testid="`section-${name}`" class="gl-px-4 gl-py-2">
<h5 class="gl-font-sm gl-mt-1 gl-mb-2" data-testid="header">{{ name }}</h5>
<gl-form-input-group class="gl-w-31" :value="value" readonly select-on-click :label="name">
<template #append>
<gl-button
v-gl-tooltip.hover
:title="$options.MSG_COPY"
:aria-label="$options.MSG_COPY"
:data-clipboard-text="value"
icon="copy-to-clipboard"
data-qa-selector="copy_button"
:data-qa-action="name"
/>
</template>
</gl-form-input-group>
</div>
</template>
</gl-disclosure-dropdown>
</template>
|