debian-mirror-gitlab/app/assets/javascripts/vue_shared/components/clone_dropdown.vue

90 lines
2.3 KiB
Vue
Raw Normal View History

2020-04-22 19:07:51 +05:30
<script>
import {
2020-11-24 15:15:51 +05:30
GlDropdown,
GlDropdownSectionHeader,
2020-04-22 19:07:51 +05:30
GlFormInputGroup,
GlButton,
GlTooltipDirective,
} from '@gitlab/ui';
import { getHTTPProtocol } from '~/lib/utils/url_utility';
2021-03-11 19:13:27 +05:30
import { __, sprintf } from '~/locale';
2020-04-22 19:07:51 +05:30
export default {
components: {
2020-11-24 15:15:51 +05:30
GlDropdown,
GlDropdownSectionHeader,
2020-04-22 19:07:51 +05:30
GlFormInputGroup,
GlButton,
},
directives: {
GlTooltip: GlTooltipDirective,
},
props: {
sshLink: {
type: String,
required: false,
default: '',
},
httpLink: {
type: String,
required: false,
default: '',
},
},
computed: {
httpLabel() {
const protocol = this.httpLink ? getHTTPProtocol(this.httpLink)?.toUpperCase() : '';
return sprintf(__('Clone with %{protocol}'), { protocol });
},
},
labels: {
defaultLabel: __('Clone'),
ssh: __('Clone with SSH'),
},
copyURLTooltip: __('Copy URL'),
};
</script>
<template>
2020-11-24 15:15:51 +05:30
<gl-dropdown right :text="$options.labels.defaultLabel" category="primary" variant="info">
2020-04-22 19:07:51 +05:30
<div class="pb-2 mx-1">
<template v-if="sshLink">
2020-11-24 15:15:51 +05:30
<gl-dropdown-section-header>{{ $options.labels.ssh }}</gl-dropdown-section-header>
2020-04-22 19:07:51 +05:30
<div class="mx-3">
<gl-form-input-group :value="sshLink" readonly select-on-click>
<template #append>
<gl-button
v-gl-tooltip.hover
:title="$options.copyURLTooltip"
:data-clipboard-text="sshLink"
2020-05-24 23:13:21 +05:30
data-qa-selector="copy_ssh_url_button"
icon="copy-to-clipboard"
class="d-inline-flex"
/>
2020-04-22 19:07:51 +05:30
</template>
</gl-form-input-group>
</div>
</template>
<template v-if="httpLink">
2020-11-24 15:15:51 +05:30
<gl-dropdown-section-header>{{ httpLabel }}</gl-dropdown-section-header>
2020-04-22 19:07:51 +05:30
<div class="mx-3">
<gl-form-input-group :value="httpLink" readonly select-on-click>
<template #append>
<gl-button
v-gl-tooltip.hover
:title="$options.copyURLTooltip"
:data-clipboard-text="httpLink"
2020-05-24 23:13:21 +05:30
data-qa-selector="copy_http_url_button"
icon="copy-to-clipboard"
class="d-inline-flex"
/>
2020-04-22 19:07:51 +05:30
</template>
</gl-form-input-group>
</div>
</template>
</div>
2020-11-24 15:15:51 +05:30
</gl-dropdown>
2020-04-22 19:07:51 +05:30
</template>