Commit d5aba68e authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'pipeline-editor/view-pipeline-btn' into 'master'

Add view pipeline button in pipeline editor

See merge request gitlab-org/gitlab!67474
parents 3c13e684 dd5e9f74
<script> <script>
import { GlIcon, GlLink, GlLoadingIcon, GlSprintf } from '@gitlab/ui'; import { GlButton, GlIcon, GlLink, GlLoadingIcon, GlSprintf } from '@gitlab/ui';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { truncateSha } from '~/lib/utils/text_utility'; import { truncateSha } from '~/lib/utils/text_utility';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
...@@ -19,12 +19,14 @@ export const i18n = { ...@@ -19,12 +19,14 @@ export const i18n = {
pipelineInfo: s__( pipelineInfo: s__(
`Pipeline|Pipeline %{idStart}#%{idEnd} %{statusStart}%{statusEnd} for %{commitStart}%{commitEnd}`, `Pipeline|Pipeline %{idStart}#%{idEnd} %{statusStart}%{statusEnd} for %{commitStart}%{commitEnd}`,
), ),
viewBtn: s__('Pipeline|View pipeline'),
}; };
export default { export default {
i18n, i18n,
components: { components: {
CiIcon, CiIcon,
GlButton,
GlIcon, GlIcon,
GlLink, GlLink,
GlLoadingIcon, GlLoadingIcon,
...@@ -98,7 +100,9 @@ export default { ...@@ -98,7 +100,9 @@ export default {
</script> </script>
<template> <template>
<div class="gl-white-space-nowrap gl-max-w-full"> <div
class="gl-display-flex gl-justify-content-space-between gl-align-items-center gl-white-space-nowrap gl-max-w-full"
>
<template v-if="showLoadingState"> <template v-if="showLoadingState">
<gl-loading-icon class="gl-mr-auto gl-display-inline-block" size="sm" /> <gl-loading-icon class="gl-mr-auto gl-display-inline-block" size="sm" />
<span data-testid="pipeline-loading-msg">{{ $options.i18n.fetchLoading }}</span> <span data-testid="pipeline-loading-msg">{{ $options.i18n.fetchLoading }}</span>
...@@ -108,6 +112,7 @@ export default { ...@@ -108,6 +112,7 @@ export default {
<span data-testid="pipeline-error-msg">{{ $options.i18n.fetchError }}</span> <span data-testid="pipeline-error-msg">{{ $options.i18n.fetchError }}</span>
</template> </template>
<template v-else> <template v-else>
<div>
<a :href="status.detailsPath" class="gl-mr-auto"> <a :href="status.detailsPath" class="gl-mr-auto">
<ci-icon :status="status" :size="16" /> <ci-icon :status="status" :size="16" />
</a> </a>
...@@ -136,6 +141,18 @@ export default { ...@@ -136,6 +141,18 @@ export default {
</template> </template>
</gl-sprintf> </gl-sprintf>
</span> </span>
</div>
<div>
<gl-button
target="_blank"
category="secondary"
variant="confirm"
:href="status.detailsPath"
data-testid="pipeline-view-btn"
>
{{ $options.i18n.viewBtn }}
</gl-button>
</div>
</template> </template>
</div> </div>
</template> </template>
...@@ -24654,6 +24654,9 @@ msgstr "" ...@@ -24654,6 +24654,9 @@ msgstr ""
msgid "Pipeline|Variables" msgid "Pipeline|Variables"
msgstr "" msgstr ""
msgid "Pipeline|View pipeline"
msgstr ""
msgid "Pipeline|We are currently unable to fetch pipeline data" msgid "Pipeline|We are currently unable to fetch pipeline data"
msgstr "" msgstr ""
......
...@@ -44,6 +44,7 @@ describe('Pipeline Status', () => { ...@@ -44,6 +44,7 @@ describe('Pipeline Status', () => {
const findPipelineCommit = () => wrapper.find('[data-testid="pipeline-commit"]'); const findPipelineCommit = () => wrapper.find('[data-testid="pipeline-commit"]');
const findPipelineErrorMsg = () => wrapper.find('[data-testid="pipeline-error-msg"]'); const findPipelineErrorMsg = () => wrapper.find('[data-testid="pipeline-error-msg"]');
const findPipelineLoadingMsg = () => wrapper.find('[data-testid="pipeline-loading-msg"]'); const findPipelineLoadingMsg = () => wrapper.find('[data-testid="pipeline-loading-msg"]');
const findPipelineViewBtn = () => wrapper.find('[data-testid="pipeline-view-btn"]');
beforeEach(() => { beforeEach(() => {
mockPipelineQuery = jest.fn(); mockPipelineQuery = jest.fn();
...@@ -96,11 +97,15 @@ describe('Pipeline Status', () => { ...@@ -96,11 +97,15 @@ describe('Pipeline Status', () => {
}); });
it('renders pipeline data', () => { it('renders pipeline data', () => {
const { id } = mockProjectPipeline.pipeline; const {
id,
detailedStatus: { detailsPath },
} = mockProjectPipeline.pipeline;
expect(findCiIcon().exists()).toBe(true); expect(findCiIcon().exists()).toBe(true);
expect(findPipelineId().text()).toBe(`#${id.match(/\d+/g)[0]}`); expect(findPipelineId().text()).toBe(`#${id.match(/\d+/g)[0]}`);
expect(findPipelineCommit().text()).toBe(mockCommitSha); expect(findPipelineCommit().text()).toBe(mockCommitSha);
expect(findPipelineViewBtn().attributes('href')).toBe(detailsPath);
}); });
}); });
...@@ -121,6 +126,7 @@ describe('Pipeline Status', () => { ...@@ -121,6 +126,7 @@ describe('Pipeline Status', () => {
expect(findCiIcon().exists()).toBe(false); expect(findCiIcon().exists()).toBe(false);
expect(findPipelineId().exists()).toBe(false); expect(findPipelineId().exists()).toBe(false);
expect(findPipelineCommit().exists()).toBe(false); expect(findPipelineCommit().exists()).toBe(false);
expect(findPipelineViewBtn().exists()).toBe(false);
}); });
}); });
}); });
......
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