2019-12-21 20:55:43 +05:30
|
|
|
<script>
|
2021-03-08 18:12:59 +05:30
|
|
|
import { GlTooltipDirective, GlButton, GlLink, GlLoadingIcon, GlBadge } from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
|
2020-07-28 23:09:34 +05:30
|
|
|
import { __, sprintf } from '~/locale';
|
2021-03-11 19:13:27 +05:30
|
|
|
import CiStatus from '~/vue_shared/components/ci_icon.vue';
|
2021-04-29 21:17:54 +05:30
|
|
|
import { reportToSentry } from '../../utils';
|
2021-11-11 11:23:49 +05:30
|
|
|
import { DOWNSTREAM, UPSTREAM } from './constants';
|
2019-12-21 20:55:43 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
directives: {
|
|
|
|
GlTooltip: GlTooltipDirective,
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
CiStatus,
|
2020-10-24 23:57:45 +05:30
|
|
|
GlButton,
|
2020-11-24 15:15:51 +05:30
|
|
|
GlLink,
|
|
|
|
GlLoadingIcon,
|
2021-03-08 18:12:59 +05:30
|
|
|
GlBadge,
|
2019-12-21 20:55:43 +05:30
|
|
|
},
|
|
|
|
props: {
|
2021-01-29 00:20:46 +05:30
|
|
|
columnTitle: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
expanded: {
|
|
|
|
type: Boolean,
|
2019-12-21 20:55:43 +05:30
|
|
|
required: true,
|
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
pipeline: {
|
|
|
|
type: Object,
|
2020-03-13 15:44:24 +05:30
|
|
|
required: true,
|
|
|
|
},
|
2021-01-29 00:20:46 +05:30
|
|
|
type: {
|
2020-03-13 15:44:24 +05:30
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
isLoading: {
|
|
|
|
type: Boolean,
|
2021-11-11 11:23:49 +05:30
|
|
|
required: true,
|
2021-02-22 17:27:13 +05:30
|
|
|
},
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
2019-12-21 20:55:43 +05:30
|
|
|
computed: {
|
|
|
|
tooltipText() {
|
2021-09-04 01:27:46 +05:30
|
|
|
return `${this.downstreamTitle} #${this.pipeline.id} - ${this.pipelineStatus.label} -
|
2020-07-28 23:09:34 +05:30
|
|
|
${this.sourceJobInfo}`;
|
2019-12-21 20:55:43 +05:30
|
|
|
},
|
|
|
|
buttonId() {
|
|
|
|
return `js-linked-pipeline-${this.pipeline.id}`;
|
|
|
|
},
|
|
|
|
pipelineStatus() {
|
2021-11-11 11:23:49 +05:30
|
|
|
return this.pipeline.status;
|
2019-12-21 20:55:43 +05:30
|
|
|
},
|
|
|
|
projectName() {
|
|
|
|
return this.pipeline.project.name;
|
|
|
|
},
|
2020-07-28 23:09:34 +05:30
|
|
|
downstreamTitle() {
|
2021-09-04 01:27:46 +05:30
|
|
|
return this.childPipeline ? this.sourceJobName : this.pipeline.project.name;
|
2020-07-28 23:09:34 +05:30
|
|
|
},
|
2020-03-13 15:44:24 +05:30
|
|
|
parentPipeline() {
|
2021-01-29 00:20:46 +05:30
|
|
|
return this.isUpstream && this.isSameProject;
|
2020-03-13 15:44:24 +05:30
|
|
|
},
|
|
|
|
childPipeline() {
|
2021-01-29 00:20:46 +05:30
|
|
|
return this.isDownstream && this.isSameProject;
|
2020-03-13 15:44:24 +05:30
|
|
|
},
|
|
|
|
label() {
|
2020-07-28 23:09:34 +05:30
|
|
|
if (this.parentPipeline) {
|
|
|
|
return __('Parent');
|
|
|
|
} else if (this.childPipeline) {
|
|
|
|
return __('Child');
|
|
|
|
}
|
|
|
|
return __('Multi-project');
|
2020-03-13 15:44:24 +05:30
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
pipelineIsLoading() {
|
|
|
|
return Boolean(this.isLoading || this.pipeline.isLoading);
|
|
|
|
},
|
2020-07-28 23:09:34 +05:30
|
|
|
isDownstream() {
|
2021-01-29 00:20:46 +05:30
|
|
|
return this.type === DOWNSTREAM;
|
|
|
|
},
|
|
|
|
isUpstream() {
|
|
|
|
return this.type === UPSTREAM;
|
|
|
|
},
|
|
|
|
isSameProject() {
|
2021-11-11 11:23:49 +05:30
|
|
|
return !this.pipeline.multiproject;
|
2021-02-22 17:27:13 +05:30
|
|
|
},
|
|
|
|
sourceJobName() {
|
2021-11-11 11:23:49 +05:30
|
|
|
return this.pipeline.sourceJob?.name ?? '';
|
2020-03-13 15:44:24 +05:30
|
|
|
},
|
2020-07-28 23:09:34 +05:30
|
|
|
sourceJobInfo() {
|
2021-02-22 17:27:13 +05:30
|
|
|
return this.isDownstream ? sprintf(__('Created by %{job}'), { job: this.sourceJobName }) : '';
|
2020-03-13 15:44:24 +05:30
|
|
|
},
|
2020-11-24 15:15:51 +05:30
|
|
|
expandedIcon() {
|
2021-01-29 00:20:46 +05:30
|
|
|
if (this.isUpstream) {
|
2020-11-24 15:15:51 +05:30
|
|
|
return this.expanded ? 'angle-right' : 'angle-left';
|
|
|
|
}
|
|
|
|
return this.expanded ? 'angle-left' : 'angle-right';
|
|
|
|
},
|
|
|
|
expandButtonPosition() {
|
2021-01-29 00:20:46 +05:30
|
|
|
return this.isUpstream ? 'gl-left-0 gl-border-r-1!' : 'gl-right-0 gl-border-l-1!';
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
2019-12-21 20:55:43 +05:30
|
|
|
},
|
2021-03-08 18:12:59 +05:30
|
|
|
errorCaptured(err, _vm, info) {
|
|
|
|
reportToSentry('linked_pipeline', `error: ${err}, info: ${info}`);
|
|
|
|
},
|
2019-12-21 20:55:43 +05:30
|
|
|
methods: {
|
|
|
|
onClickLinkedPipeline() {
|
2021-02-22 17:27:13 +05:30
|
|
|
this.hideTooltips();
|
2020-03-13 15:44:24 +05:30
|
|
|
this.$emit('pipelineClicked', this.$refs.linkedPipeline);
|
2021-02-22 17:27:13 +05:30
|
|
|
this.$emit('pipelineExpandToggle', this.sourceJobName, !this.expanded);
|
2020-03-13 15:44:24 +05:30
|
|
|
},
|
|
|
|
hideTooltips() {
|
2021-03-11 19:13:27 +05:30
|
|
|
this.$root.$emit(BV_HIDE_TOOLTIP);
|
2019-12-21 20:55:43 +05:30
|
|
|
},
|
2020-07-28 23:09:34 +05:30
|
|
|
onDownstreamHovered() {
|
2021-02-22 17:27:13 +05:30
|
|
|
this.$emit('downstreamHovered', this.sourceJobName);
|
2020-07-28 23:09:34 +05:30
|
|
|
},
|
|
|
|
onDownstreamHoverLeave() {
|
|
|
|
this.$emit('downstreamHovered', '');
|
|
|
|
},
|
2019-12-21 20:55:43 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2021-02-22 17:27:13 +05:30
|
|
|
<div
|
2020-03-13 15:44:24 +05:30
|
|
|
ref="linkedPipeline"
|
2020-11-24 15:15:51 +05:30
|
|
|
v-gl-tooltip
|
2021-11-11 11:23:49 +05:30
|
|
|
class="gl-pipeline-job-width"
|
2020-11-24 15:15:51 +05:30
|
|
|
:title="tooltipText"
|
2020-07-28 23:09:34 +05:30
|
|
|
data-qa-selector="child_pipeline"
|
|
|
|
@mouseover="onDownstreamHovered"
|
|
|
|
@mouseleave="onDownstreamHoverLeave"
|
2020-03-13 15:44:24 +05:30
|
|
|
>
|
2020-11-24 15:15:51 +05:30
|
|
|
<div
|
|
|
|
class="gl-relative gl-bg-white gl-p-3 gl-border-solid gl-border-gray-100 gl-border-1"
|
2021-01-29 00:20:46 +05:30
|
|
|
:class="{ 'gl-pl-9': isUpstream }"
|
2019-12-21 20:55:43 +05:30
|
|
|
>
|
2020-11-24 15:15:51 +05:30
|
|
|
<div class="gl-display-flex">
|
|
|
|
<ci-status
|
2021-02-22 17:27:13 +05:30
|
|
|
v-if="!pipelineIsLoading"
|
2020-11-24 15:15:51 +05:30
|
|
|
:status="pipelineStatus"
|
2021-02-22 17:27:13 +05:30
|
|
|
:size="24"
|
2020-11-24 15:15:51 +05:30
|
|
|
css-classes="gl-top-0 gl-pr-2"
|
|
|
|
/>
|
2021-09-30 23:02:18 +05:30
|
|
|
<div v-else class="gl-pr-2"><gl-loading-icon size="sm" inline /></div>
|
2020-11-24 15:15:51 +05:30
|
|
|
<div class="gl-display-flex gl-flex-direction-column gl-w-13">
|
2021-09-04 01:27:46 +05:30
|
|
|
<span class="gl-text-truncate" data-testid="downstream-title">
|
2020-11-24 15:15:51 +05:30
|
|
|
{{ downstreamTitle }}
|
|
|
|
</span>
|
|
|
|
<div class="gl-text-truncate">
|
|
|
|
<gl-link class="gl-text-blue-500!" :href="pipeline.path" data-testid="pipelineLink"
|
|
|
|
>#{{ pipeline.id }}</gl-link
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-07-28 23:09:34 +05:30
|
|
|
<div class="gl-pt-2">
|
2021-03-08 18:12:59 +05:30
|
|
|
<gl-badge size="sm" variant="info" data-testid="downstream-pipeline-label">
|
|
|
|
{{ label }}
|
|
|
|
</gl-badge>
|
2020-03-13 15:44:24 +05:30
|
|
|
</div>
|
2020-11-24 15:15:51 +05:30
|
|
|
<gl-button
|
|
|
|
:id="buttonId"
|
|
|
|
class="gl-absolute gl-top-0 gl-bottom-0 gl-shadow-none! gl-rounded-0!"
|
|
|
|
:class="`js-pipeline-expand-${pipeline.id} ${expandButtonPosition}`"
|
|
|
|
:icon="expandedIcon"
|
2021-04-29 21:17:54 +05:30
|
|
|
:aria-label="__('Expand pipeline')"
|
2021-02-22 17:27:13 +05:30
|
|
|
data-testid="expand-pipeline-button"
|
2020-11-24 15:15:51 +05:30
|
|
|
data-qa-selector="expand_pipeline_button"
|
|
|
|
@click="onClickLinkedPipeline"
|
|
|
|
/>
|
|
|
|
</div>
|
2021-02-22 17:27:13 +05:30
|
|
|
</div>
|
2019-12-21 20:55:43 +05:30
|
|
|
</template>
|