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 {
required: false,
default: '',
},
cssClasses: {
type: String,
required: false,
default: '',
},
modalId: {
type: String,
required: false,
......@@ -110,6 +115,7 @@ export default {
<template>
<gl-button
v-gl-tooltip="{ placement: tooltipPlacement, container: tooltipContainer }"
:class="cssClasses"
:data-clipboard-target="target"
:data-clipboard-text="text"
:title="title"
......
<script>
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 { s__, sprintf } from '~/locale';
......@@ -8,6 +9,7 @@ export default {
GlButton,
GlModal,
Icon,
ModalCopyButton,
},
directives: {
'gl-modal': GlModalDirective,
......@@ -127,7 +129,15 @@ export default {
<p v-html="instructionText.intro"></p>
<div>
<p v-html="instructionText.step1"></p>
<pre> {{ copyString.script }} </pre>
<div class="flex align-items-start">
<pre> {{ copyString.script }} </pre>
<modal-copy-button
title="Copy script"
:text="copyString.script"
:modal-id="modalId"
css-classes="border-0"
/>
</div>
</div>
<p v-html="instructionText.step2"></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 VisualReviewAppLink from 'ee/vue_merge_request_widget/components/visual_review_app_link.vue';
import { GlButton, GlModal } from '@gitlab/ui';
import ModalCopyButton from '~/vue_shared/components/modal_copy_button.vue';
const localVue = createLocalVue();
......@@ -52,7 +53,6 @@ describe('Visual Review App Link', () => {
localVue,
});
});
it('with expected project Id', () => {
expect(wrapper.find(GlModal).text()).toEqual(
expect.stringContaining(`data-project-id='${propsData.appMetadata.sourceProjectId}'`),
......@@ -86,4 +86,15 @@ describe('Visual Review App 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