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,34 +112,47 @@ export default { ...@@ -108,34 +112,47 @@ 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>
<a :href="status.detailsPath" class="gl-mr-auto"> <div>
<ci-icon :status="status" :size="16" /> <a :href="status.detailsPath" class="gl-mr-auto">
</a> <ci-icon :status="status" :size="16" />
<span class="gl-font-weight-bold"> </a>
<gl-sprintf :message="$options.i18n.pipelineInfo"> <span class="gl-font-weight-bold">
<template #id="{ content }"> <gl-sprintf :message="$options.i18n.pipelineInfo">
<gl-link <template #id="{ content }">
:href="status.detailsPath" <gl-link
class="pipeline-id gl-font-weight-normal pipeline-number" :href="status.detailsPath"
target="_blank" class="pipeline-id gl-font-weight-normal pipeline-number"
data-testid="pipeline-id" target="_blank"
> data-testid="pipeline-id"
{{ content }}{{ pipelineId }}</gl-link >
> {{ content }}{{ pipelineId }}</gl-link
</template> >
<template #status>{{ status.text }}</template> </template>
<template #commit> <template #status>{{ status.text }}</template>
<gl-link <template #commit>
:href="pipeline.commitPath" <gl-link
class="commit-sha gl-font-weight-normal" :href="pipeline.commitPath"
target="_blank" class="commit-sha gl-font-weight-normal"
data-testid="pipeline-commit" target="_blank"
> data-testid="pipeline-commit"
{{ shortSha }} >
</gl-link> {{ shortSha }}
</template> </gl-link>
</gl-sprintf> </template>
</span> </gl-sprintf>
</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