Commit 0c1e8060 authored by Fatih Acet's avatar Fatih Acet

Merge branch '11707-add-copy-to-clipboard' into 'master'

Resolve "Add Copy to Clipboard Button to Review App Modal"

Closes #11707

See merge request gitlab-org/gitlab-ee!14290
parents 4db922df e95a6d1b
...@@ -26,6 +26,11 @@ export default { ...@@ -26,6 +26,11 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
cssClasses: {
type: String,
required: false,
default: '',
},
modalId: { modalId: {
type: String, type: String,
required: false, required: false,
...@@ -110,6 +115,7 @@ export default { ...@@ -110,6 +115,7 @@ export default {
<template> <template>
<gl-button <gl-button
v-gl-tooltip="{ placement: tooltipPlacement, container: tooltipContainer }" v-gl-tooltip="{ placement: tooltipPlacement, container: tooltipContainer }"
:class="cssClasses"
:data-clipboard-target="target" :data-clipboard-target="target"
:data-clipboard-text="text" :data-clipboard-text="text"
:title="title" :title="title"
......
<script> <script>
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import ModalCopyButton from '~/vue_shared/components/modal_copy_button.vue';
import { GlButton, GlModal, GlModalDirective } from '@gitlab/ui'; import { GlButton, GlModal, GlModalDirective } from '@gitlab/ui';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
...@@ -8,6 +9,7 @@ export default { ...@@ -8,6 +9,7 @@ export default {
GlButton, GlButton,
GlModal, GlModal,
Icon, Icon,
ModalCopyButton,
}, },
directives: { directives: {
'gl-modal': GlModalDirective, 'gl-modal': GlModalDirective,
...@@ -127,7 +129,15 @@ export default { ...@@ -127,7 +129,15 @@ export default {
<p v-html="instructionText.intro"></p> <p v-html="instructionText.intro"></p>
<div> <div>
<p v-html="instructionText.step1"></p> <p v-html="instructionText.step1"></p>
<div class="flex align-items-start">
<pre> {{ copyString.script }} </pre> <pre> {{ copyString.script }} </pre>
<modal-copy-button
title="Copy script"
:text="copyString.script"
:modal-id="modalId"
css-classes="border-0"
/>
</div>
</div> </div>
<p v-html="instructionText.step2"></p> <p v-html="instructionText.step2"></p>
<p v-html="instructionText.step3"></p> <p v-html="instructionText.step3"></p>
......
---
title: Add Copy to Clipboard Button to Review App Modal
merge_request: 14290
author:
type: changed
import { shallowMount, mount, createLocalVue } from '@vue/test-utils'; import { shallowMount, mount, createLocalVue } from '@vue/test-utils';
import VisualReviewAppLink from 'ee/vue_merge_request_widget/components/visual_review_app_link.vue'; import VisualReviewAppLink from 'ee/vue_merge_request_widget/components/visual_review_app_link.vue';
import { GlButton, GlModal } from '@gitlab/ui'; import { GlButton, GlModal } from '@gitlab/ui';
import ModalCopyButton from '~/vue_shared/components/modal_copy_button.vue';
const localVue = createLocalVue(); const localVue = createLocalVue();
...@@ -52,7 +53,6 @@ describe('Visual Review App Link', () => { ...@@ -52,7 +53,6 @@ describe('Visual Review App Link', () => {
localVue, localVue,
}); });
}); });
it('with expected project Id', () => { it('with expected project Id', () => {
expect(wrapper.find(GlModal).text()).toEqual( expect(wrapper.find(GlModal).text()).toEqual(
expect.stringContaining(`data-project-id='${propsData.appMetadata.sourceProjectId}'`), expect.stringContaining(`data-project-id='${propsData.appMetadata.sourceProjectId}'`),
...@@ -86,4 +86,15 @@ describe('Visual Review App Link', () => { ...@@ -86,4 +86,15 @@ describe('Visual Review App Link', () => {
).toEqual(propsData.link); ).toEqual(propsData.link);
}); });
}); });
describe('renders the copyToClipboard button', () => {
it('within the modal', () => {
expect(wrapper.find(ModalCopyButton)).toBeTruthy();
});
it('with the expected modalId', () => {
const renderedId = wrapper.find(GlModal).attributes('modalid');
expect(wrapper.find(ModalCopyButton).props().modalId).toBe(renderedId);
});
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment