Commit 14f680ee authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch 'pipeline-editor/commit-title' into 'master'

Add tooltip and commit title to pipeline editor's status header

See merge request gitlab-org/gitlab!73724
parents 7a15e05d 2b56a277
<script> <script>
import { GlButton, GlIcon, GlLink, GlLoadingIcon, GlSprintf } from '@gitlab/ui'; import { GlButton, GlIcon, GlLink, GlLoadingIcon, GlSprintf, GlTooltipDirective } 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';
...@@ -20,6 +20,7 @@ export const i18n = { ...@@ -20,6 +20,7 @@ export const i18n = {
`Pipeline|Pipeline %{idStart}#%{idEnd} %{statusStart}%{statusEnd} for %{commitStart}%{commitEnd}`, `Pipeline|Pipeline %{idStart}#%{idEnd} %{statusStart}%{statusEnd} for %{commitStart}%{commitEnd}`,
), ),
viewBtn: s__('Pipeline|View pipeline'), viewBtn: s__('Pipeline|View pipeline'),
viewCommit: s__('Pipeline|View commit'),
pipelineNotTriggeredMsg: s__( pipelineNotTriggeredMsg: s__(
'Pipeline|No pipeline was triggered for the latest changes due to the current CI/CD configuration.', 'Pipeline|No pipeline was triggered for the latest changes due to the current CI/CD configuration.',
), ),
...@@ -36,6 +37,9 @@ export default { ...@@ -36,6 +37,9 @@ export default {
GlSprintf, GlSprintf,
PipelineEditorMiniGraph, PipelineEditorMiniGraph,
}, },
directives: {
GlTooltip: GlTooltipDirective,
},
inject: ['projectFullPath'], inject: ['projectFullPath'],
props: { props: {
commitSha: { commitSha: {
...@@ -60,13 +64,13 @@ export default { ...@@ -60,13 +64,13 @@ export default {
}; };
}, },
update(data) { update(data) {
const { id, iid, commitPath = '', detailedStatus = {}, stages, status } = const { id, iid, commit = {}, detailedStatus = {}, stages, status } =
data.project?.pipeline || {}; data.project?.pipeline || {};
return { return {
id, id,
iid, iid,
commitPath, commit,
detailedStatus, detailedStatus,
stages, stages,
status, status,
...@@ -95,6 +99,16 @@ export default { ...@@ -95,6 +99,16 @@ export default {
}; };
}, },
computed: { computed: {
commitText() {
const shortSha = truncateSha(this.commitSha);
const commitTitle = this.pipeline.commit.title || '';
if (commitTitle.length > 0) {
return `${shortSha}: ${commitTitle}`;
}
return shortSha;
},
hasPipelineData() { hasPipelineData() {
return Boolean(this.pipeline?.id); return Boolean(this.pipeline?.id);
}, },
...@@ -146,7 +160,7 @@ export default { ...@@ -146,7 +160,7 @@ export default {
</div> </div>
</template> </template>
<template v-else> <template v-else>
<div> <div class="gl-text-truncate gl-md-max-w-50p gl-mr-1">
<a :href="status.detailsPath" class="gl-mr-auto"> <a :href="status.detailsPath" class="gl-mr-auto">
<ci-icon :status="status" :size="16" data-testid="pipeline-status-icon" /> <ci-icon :status="status" :size="16" data-testid="pipeline-status-icon" />
</a> </a>
...@@ -158,12 +172,12 @@ export default { ...@@ -158,12 +172,12 @@ export default {
<template #status>{{ status.text }}</template> <template #status>{{ status.text }}</template>
<template #commit> <template #commit>
<gl-link <gl-link
:href="pipeline.commitPath" v-gl-tooltip.hover
class="commit-sha gl-font-weight-normal" :href="pipeline.commit.webPath"
target="_blank" :title="$options.i18n.viewCommit"
data-testid="pipeline-commit" data-testid="pipeline-commit"
> >
{{ shortSha }} {{ commitText }}
</gl-link> </gl-link>
</template> </template>
</gl-sprintf> </gl-sprintf>
...@@ -173,7 +187,6 @@ export default { ...@@ -173,7 +187,6 @@ export default {
<pipeline-editor-mini-graph :pipeline="pipeline" v-on="$listeners" /> <pipeline-editor-mini-graph :pipeline="pipeline" v-on="$listeners" />
<gl-button <gl-button
class="gl-mt-2 gl-md-mt-0" class="gl-mt-2 gl-md-mt-0"
target="_blank"
category="secondary" category="secondary"
variant="confirm" variant="confirm"
:href="status.detailsPath" :href="status.detailsPath"
......
query getPipeline($fullPath: ID!, $sha: String!) { query getPipeline($fullPath: ID!, $sha: String!) {
project(fullPath: $fullPath) { project(fullPath: $fullPath) {
pipeline(sha: $sha) { pipeline(sha: $sha) {
commitPath
id id
iid iid
status status
commit {
title
webPath
}
detailedStatus { detailedStatus {
detailsPath detailsPath
icon icon
......
...@@ -290,3 +290,10 @@ $gl-line-height-42: px-to-rem(42px); ...@@ -290,3 +290,10 @@ $gl-line-height-42: px-to-rem(42px);
.gl-focus-ring-border-1-gray-900\! { .gl-focus-ring-border-1-gray-900\! {
@include gl-focus($gl-border-size-1, $gray-900, true); @include gl-focus($gl-border-size-1, $gray-900, true);
} }
// Will be moved to @gitlab/ui by https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/2476
.gl-md-max-w-50p {
@include gl-media-breakpoint-up(md) {
max-width: 50%;
}
}
...@@ -25707,6 +25707,9 @@ msgstr "" ...@@ -25707,6 +25707,9 @@ msgstr ""
msgid "Pipeline|Variables" msgid "Pipeline|Variables"
msgstr "" msgstr ""
msgid "Pipeline|View commit"
msgstr ""
msgid "Pipeline|View pipeline" msgid "Pipeline|View pipeline"
msgstr "" msgstr ""
......
...@@ -96,12 +96,13 @@ describe('Pipeline Status', () => { ...@@ -96,12 +96,13 @@ describe('Pipeline Status', () => {
it('renders pipeline data', () => { it('renders pipeline data', () => {
const { const {
id, id,
commit: { title },
detailedStatus: { detailsPath }, detailedStatus: { detailsPath },
} = mockProjectPipeline().pipeline; } = mockProjectPipeline().pipeline;
expect(findStatusIcon().exists()).toBe(true); expect(findStatusIcon().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}: ${title}`);
expect(findPipelineViewBtn().attributes('href')).toBe(detailsPath); expect(findPipelineViewBtn().attributes('href')).toBe(detailsPath);
}); });
......
...@@ -285,11 +285,14 @@ export const mockProjectPipeline = ({ hasStages = true } = {}) => { ...@@ -285,11 +285,14 @@ export const mockProjectPipeline = ({ hasStages = true } = {}) => {
return { return {
pipeline: { pipeline: {
commitPath: '/-/commit/aabbccdd',
id: 'gid://gitlab/Ci::Pipeline/118', id: 'gid://gitlab/Ci::Pipeline/118',
iid: '28', iid: '28',
shortSha: mockCommitSha, shortSha: mockCommitSha,
status: 'SUCCESS', status: 'SUCCESS',
commit: {
title: 'Update .gitlabe-ci.yml',
webPath: '/-/commit/aabbccdd',
},
detailedStatus: { detailedStatus: {
detailsPath: '/root/sample-ci-project/-/pipelines/118', detailsPath: '/root/sample-ci-project/-/pipelines/118',
group: 'success', group: 'success',
......
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