Commit 39a8eff4 authored by Brandon Labuschagne's avatar Brandon Labuschagne

Merge branch 'mw/add_clipboard_to_job_ref' into 'master'

Add copy feature to CI job page

See merge request gitlab-org/gitlab!68148
parents 4da0b54f 5d72b702
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
import { GlLink, GlDropdown, GlDropdownItem } from '@gitlab/ui'; import { GlLink, GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import CiIcon from '~/vue_shared/components/ci_icon.vue'; import CiIcon from '~/vue_shared/components/ci_icon.vue';
import clipboardButton from '~/vue_shared/components/clipboard_button.vue';
export default { export default {
components: { components: {
CiIcon, CiIcon,
clipboardButton,
GlDropdown, GlDropdown,
GlDropdownItem, GlDropdownItem,
GlLink, GlLink,
...@@ -45,7 +47,7 @@ export default { ...@@ -45,7 +47,7 @@ export default {
<template> <template>
<div class="dropdown"> <div class="dropdown">
<div class="js-pipeline-info" data-testid="pipeline-info"> <div class="js-pipeline-info" data-testid="pipeline-info">
<ci-icon :status="pipeline.details.status" class="vertical-align-middle" /> <ci-icon :status="pipeline.details.status" />
<span class="font-weight-bold">{{ s__('Job|Pipeline') }}</span> <span class="font-weight-bold">{{ s__('Job|Pipeline') }}</span>
<gl-link <gl-link
...@@ -85,7 +87,14 @@ export default { ...@@ -85,7 +87,14 @@ export default {
</template> </template>
<gl-link v-else :href="pipeline.ref.path" class="link-commit ref-name">{{ <gl-link v-else :href="pipeline.ref.path" class="link-commit ref-name">{{
pipeline.ref.name pipeline.ref.name
}}</gl-link> }}</gl-link
><clipboard-button
:text="pipeline.ref.name"
:title="__('Copy reference')"
category="tertiary"
size="small"
data-testid="copy-source-ref-link"
/>
</template> </template>
</div> </div>
......
...@@ -20,6 +20,7 @@ describe('Stages Dropdown', () => { ...@@ -20,6 +20,7 @@ describe('Stages Dropdown', () => {
const findPipelineInfoText = () => wrapper.findByTestId('pipeline-info').text(); const findPipelineInfoText = () => wrapper.findByTestId('pipeline-info').text();
const findPipelinePath = () => wrapper.findByTestId('pipeline-path').attributes('href'); const findPipelinePath = () => wrapper.findByTestId('pipeline-path').attributes('href');
const findMRLinkPath = () => wrapper.findByTestId('mr-link').attributes('href'); const findMRLinkPath = () => wrapper.findByTestId('mr-link').attributes('href');
const findCopySourceBranchBtn = () => wrapper.findByTestId('copy-source-ref-link');
const findSourceBranchLinkPath = () => const findSourceBranchLinkPath = () =>
wrapper.findByTestId('source-branch-link').attributes('href'); wrapper.findByTestId('source-branch-link').attributes('href');
const findTargetBranchLinkPath = () => const findTargetBranchLinkPath = () =>
...@@ -70,6 +71,10 @@ describe('Stages Dropdown', () => { ...@@ -70,6 +71,10 @@ describe('Stages Dropdown', () => {
expect(actual).toBe(expected); expect(actual).toBe(expected);
}); });
it(`renders the source ref copy button`, () => {
expect(findCopySourceBranchBtn().exists()).toBe(true);
});
}); });
describe('with an "attached" merge request pipeline', () => { describe('with an "attached" merge request pipeline', () => {
...@@ -103,6 +108,10 @@ describe('Stages Dropdown', () => { ...@@ -103,6 +108,10 @@ describe('Stages Dropdown', () => {
mockPipelineWithAttachedMR.merge_request.target_branch_path, mockPipelineWithAttachedMR.merge_request.target_branch_path,
); );
}); });
it(`renders the source ref copy button`, () => {
expect(findCopySourceBranchBtn().exists()).toBe(true);
});
}); });
describe('with a detached merge request pipeline', () => { describe('with a detached merge request pipeline', () => {
...@@ -130,5 +139,9 @@ describe('Stages Dropdown', () => { ...@@ -130,5 +139,9 @@ describe('Stages Dropdown', () => {
mockPipelineDetached.merge_request.source_branch_path, mockPipelineDetached.merge_request.source_branch_path,
); );
}); });
it(`renders the source ref copy button`, () => {
expect(findCopySourceBranchBtn().exists()).toBe(true);
});
}); });
}); });
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