2020-08-25 21:10:30 +00:00
|
|
|
<script>
|
|
|
|
import { escape as esc } from 'lodash';
|
|
|
|
import {
|
|
|
|
GlButton,
|
|
|
|
GlDropdown,
|
2020-09-15 00:09:47 +00:00
|
|
|
GlDropdownSectionHeader,
|
2020-08-25 21:10:30 +00:00
|
|
|
GlDropdownText,
|
|
|
|
GlFormInputGroup,
|
|
|
|
GlTooltipDirective,
|
|
|
|
} from '@gitlab/ui';
|
|
|
|
import { __ } from '~/locale';
|
|
|
|
|
|
|
|
const MSG_EMBED = __('Embed');
|
|
|
|
const MSG_SHARE = __('Share');
|
|
|
|
const MSG_COPY = __('Copy');
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
GlButton,
|
|
|
|
GlDropdown,
|
2020-09-15 00:09:47 +00:00
|
|
|
GlDropdownSectionHeader,
|
2020-08-25 21:10:30 +00:00
|
|
|
GlDropdownText,
|
|
|
|
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-dropdown
|
|
|
|
right
|
|
|
|
:text="$options.MSG_EMBED"
|
|
|
|
menu-class="gl-px-1! gl-pb-5! gl-dropdown-menu-wide"
|
|
|
|
>
|
|
|
|
<template v-for="{ name, value } in sections">
|
2020-09-15 00:09:47 +00:00
|
|
|
<gl-dropdown-section-header :key="`header_${name}`" data-testid="header">{{
|
2020-08-25 21:10:30 +00:00
|
|
|
name
|
2020-09-15 00:09:47 +00:00
|
|
|
}}</gl-dropdown-section-header>
|
2020-08-25 21:10:30 +00:00
|
|
|
<gl-dropdown-text
|
|
|
|
:key="`input_${name}`"
|
|
|
|
tag="div"
|
|
|
|
class="gl-dropdown-text-py-0 gl-dropdown-text-block"
|
|
|
|
data-testid="input"
|
|
|
|
>
|
|
|
|
<gl-form-input-group :value="value" readonly select-on-click>
|
|
|
|
<template #append>
|
|
|
|
<gl-button
|
|
|
|
v-gl-tooltip.hover
|
|
|
|
:title="$options.MSG_COPY"
|
|
|
|
:data-clipboard-text="value"
|
|
|
|
icon="copy-to-clipboard"
|
2020-09-09 09:08:40 +00:00
|
|
|
data-qa-selector="copy_button"
|
|
|
|
:data-qa-action="name"
|
2020-08-25 21:10:30 +00:00
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
</gl-form-input-group>
|
|
|
|
</gl-dropdown-text>
|
|
|
|
</template>
|
|
|
|
</gl-dropdown>
|
|
|
|
</template>
|