diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/assets/javascripts/vue_shared/components/modal_copy_button.vue | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) | |
download | gitlab-ce-7e9c479f7de77702622631cff2628a9c8dcbc627.tar.gz |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/assets/javascripts/vue_shared/components/modal_copy_button.vue')
-rw-r--r-- | app/assets/javascripts/vue_shared/components/modal_copy_button.vue | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/app/assets/javascripts/vue_shared/components/modal_copy_button.vue b/app/assets/javascripts/vue_shared/components/modal_copy_button.vue index cad4439ecea..de9c84dd157 100644 --- a/app/assets/javascripts/vue_shared/components/modal_copy_button.vue +++ b/app/assets/javascripts/vue_shared/components/modal_copy_button.vue @@ -1,8 +1,7 @@ <script> -import $ from 'jquery'; import { GlButton, GlTooltipDirective } from '@gitlab/ui'; import Clipboard from 'clipboard'; -import { __ } from '~/locale'; +import { uniqueId } from 'lodash'; export default { components: { @@ -17,6 +16,11 @@ export default { required: false, default: '', }, + id: { + type: String, + required: false, + default: () => uniqueId('modal-copy-button-'), + }, container: { type: String, required: false, @@ -52,7 +56,6 @@ export default { default: null, }, }, - copySuccessText: __('Copied'), computed: { modalDomId() { return this.modalId ? `#${this.modalId}` : ''; @@ -68,11 +71,11 @@ export default { }); this.clipboard .on('success', e => { - this.updateTooltip(e.trigger); + this.$root.$emit('bv::hide::tooltip', this.id); this.$emit('success', e); // Clear the selection and blur the trigger so it loses its border e.clearSelection(); - $(e.trigger).blur(); + e.trigger.blur(); }) .on('error', e => this.$emit('error', e)); }); @@ -82,29 +85,11 @@ export default { this.clipboard.destroy(); } }, - methods: { - updateTooltip(target) { - const $target = $(target); - const originalTitle = $target.data('originalTitle'); - - if ($target.tooltip) { - /** - * The original tooltip will continue staying there unless we remove it by hand. - * $target.tooltip('hide') isn't working. - */ - $('.tooltip').remove(); - $target.attr('title', this.$options.copySuccessText); - $target.tooltip('_fixTitle'); - $target.tooltip('show'); - $target.attr('title', originalTitle); - $target.tooltip('_fixTitle'); - } - }, - }, }; </script> <template> <gl-button + :id="id" v-gl-tooltip="{ placement: tooltipPlacement, container: tooltipContainer }" :class="cssClasses" :data-clipboard-target="target" |