2017-08-17 22:00:37 +05:30
|
|
|
<script>
|
2021-02-22 17:27:13 +05:30
|
|
|
import LinkedGraphWrapper from '../graph_shared/linked_graph_wrapper.vue';
|
2021-03-08 18:12:59 +05:30
|
|
|
import LinksLayer from '../graph_shared/links_layer.vue';
|
2019-12-21 20:55:43 +05:30
|
|
|
import LinkedPipelinesColumn from './linked_pipelines_column.vue';
|
2021-02-22 17:27:13 +05:30
|
|
|
import StageColumnComponent from './stage_column_component.vue';
|
|
|
|
import { DOWNSTREAM, MAIN, UPSTREAM } from './constants';
|
2021-03-08 18:12:59 +05:30
|
|
|
import { reportToSentry } from './utils';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
export default {
|
2019-12-21 20:55:43 +05:30
|
|
|
name: 'PipelineGraph',
|
2018-05-09 12:01:36 +05:30
|
|
|
components: {
|
2021-03-08 18:12:59 +05:30
|
|
|
LinksLayer,
|
2021-02-22 17:27:13 +05:30
|
|
|
LinkedGraphWrapper,
|
2019-12-21 20:55:43 +05:30
|
|
|
LinkedPipelinesColumn,
|
2021-02-22 17:27:13 +05:30
|
|
|
StageColumnComponent,
|
2019-12-21 20:55:43 +05:30
|
|
|
},
|
|
|
|
props: {
|
|
|
|
isLinkedPipeline: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
pipeline: {
|
2019-12-21 20:55:43 +05:30
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
2021-01-29 00:20:46 +05:30
|
|
|
default: MAIN,
|
2019-12-21 20:55:43 +05:30
|
|
|
},
|
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
pipelineTypeConstants: {
|
|
|
|
DOWNSTREAM,
|
|
|
|
UPSTREAM,
|
|
|
|
},
|
2021-03-08 18:12:59 +05:30
|
|
|
CONTAINER_REF: 'PIPELINE_LINKS_CONTAINER_REF',
|
|
|
|
BASE_CONTAINER_ID: 'pipeline-links-container',
|
2019-12-21 20:55:43 +05:30
|
|
|
data() {
|
|
|
|
return {
|
2021-02-22 17:27:13 +05:30
|
|
|
hoveredJobName: '',
|
2021-03-08 18:12:59 +05:30
|
|
|
highlightedJobs: [],
|
|
|
|
measurements: {
|
|
|
|
width: 0,
|
|
|
|
height: 0,
|
|
|
|
},
|
2020-11-24 15:15:51 +05:30
|
|
|
pipelineExpanded: {
|
|
|
|
jobName: '',
|
|
|
|
expanded: false,
|
|
|
|
},
|
2019-12-21 20:55:43 +05:30
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2021-03-08 18:12:59 +05:30
|
|
|
containerId() {
|
|
|
|
return `${this.$options.BASE_CONTAINER_ID}-${this.pipeline.id}`;
|
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
downstreamPipelines() {
|
|
|
|
return this.hasDownstreamPipelines ? this.pipeline.downstream : [];
|
|
|
|
},
|
2021-01-03 14:25:43 +05:30
|
|
|
graph() {
|
2021-02-22 17:27:13 +05:30
|
|
|
return this.pipeline.stages;
|
2021-01-03 14:25:43 +05:30
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
hasDownstreamPipelines() {
|
|
|
|
return Boolean(this.pipeline?.downstream?.length > 0);
|
2019-12-21 20:55:43 +05:30
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
hasUpstreamPipelines() {
|
|
|
|
return Boolean(this.pipeline?.upstream?.length > 0);
|
2019-12-21 20:55:43 +05:30
|
|
|
},
|
2021-03-08 18:12:59 +05:30
|
|
|
// The show downstream check prevents showing redundant linked columns
|
2021-02-22 17:27:13 +05:30
|
|
|
showDownstreamPipelines() {
|
2019-12-21 20:55:43 +05:30
|
|
|
return (
|
2021-02-22 17:27:13 +05:30
|
|
|
this.hasDownstreamPipelines && this.type !== this.$options.pipelineTypeConstants.UPSTREAM
|
2019-12-21 20:55:43 +05:30
|
|
|
);
|
|
|
|
},
|
2021-03-08 18:12:59 +05:30
|
|
|
// The show upstream check prevents showing redundant linked columns
|
2021-02-22 17:27:13 +05:30
|
|
|
showUpstreamPipelines() {
|
2019-12-21 20:55:43 +05:30
|
|
|
return (
|
2021-02-22 17:27:13 +05:30
|
|
|
this.hasUpstreamPipelines && this.type !== this.$options.pipelineTypeConstants.DOWNSTREAM
|
2019-12-21 20:55:43 +05:30
|
|
|
);
|
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
upstreamPipelines() {
|
|
|
|
return this.hasUpstreamPipelines ? this.pipeline.upstream : [];
|
2020-03-13 15:44:24 +05:30
|
|
|
},
|
2019-12-21 20:55:43 +05:30
|
|
|
},
|
2021-03-08 18:12:59 +05:30
|
|
|
errorCaptured(err, _vm, info) {
|
|
|
|
reportToSentry(this.$options.name, `error: ${err}, info: ${info}`);
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.measurements = this.getMeasurements();
|
|
|
|
},
|
2019-12-21 20:55:43 +05:30
|
|
|
methods: {
|
2021-03-08 18:12:59 +05:30
|
|
|
getMeasurements() {
|
|
|
|
return {
|
|
|
|
width: this.$refs[this.containerId].scrollWidth,
|
|
|
|
height: this.$refs[this.containerId].scrollHeight,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
onError(errorType) {
|
|
|
|
this.$emit('error', errorType);
|
|
|
|
},
|
2020-07-28 23:09:34 +05:30
|
|
|
setJob(jobName) {
|
2021-02-22 17:27:13 +05:30
|
|
|
this.hoveredJobName = jobName;
|
2020-07-28 23:09:34 +05:30
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
togglePipelineExpanded(jobName, expanded) {
|
|
|
|
this.pipelineExpanded = {
|
|
|
|
expanded,
|
|
|
|
jobName: expanded ? jobName : '',
|
|
|
|
};
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
2021-03-08 18:12:59 +05:30
|
|
|
updateHighlightedJobs(jobs) {
|
|
|
|
this.highlightedJobs = jobs;
|
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
};
|
2017-08-17 22:00:37 +05:30
|
|
|
</script>
|
|
|
|
<template>
|
2021-02-22 17:27:13 +05:30
|
|
|
<div class="js-pipeline-graph">
|
2019-12-21 20:55:43 +05:30
|
|
|
<div
|
2021-03-08 18:12:59 +05:30
|
|
|
class="gl-display-flex gl-position-relative gl-overflow-auto gl-bg-gray-10 gl-white-space-nowrap"
|
|
|
|
:class="{ 'gl-pipeline-min-h gl-py-5': !isLinkedPipeline }"
|
2019-12-21 20:55:43 +05:30
|
|
|
>
|
2021-02-22 17:27:13 +05:30
|
|
|
<linked-graph-wrapper>
|
|
|
|
<template #upstream>
|
|
|
|
<linked-pipelines-column
|
|
|
|
v-if="showUpstreamPipelines"
|
|
|
|
:linked-pipelines="upstreamPipelines"
|
|
|
|
:column-title="__('Upstream')"
|
|
|
|
:type="$options.pipelineTypeConstants.UPSTREAM"
|
2021-03-08 18:12:59 +05:30
|
|
|
@error="onError"
|
2021-02-22 17:27:13 +05:30
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<template #main>
|
2021-03-08 18:12:59 +05:30
|
|
|
<div :id="containerId" :ref="containerId">
|
|
|
|
<links-layer
|
|
|
|
:pipeline-data="graph"
|
|
|
|
:pipeline-id="pipeline.id"
|
|
|
|
:container-id="containerId"
|
|
|
|
:container-measurements="measurements"
|
|
|
|
:highlighted-job="hoveredJobName"
|
|
|
|
default-link-color="gl-stroke-transparent"
|
|
|
|
@error="onError"
|
|
|
|
@highlightedJobsChange="updateHighlightedJobs"
|
|
|
|
>
|
|
|
|
<stage-column-component
|
|
|
|
v-for="stage in graph"
|
|
|
|
:key="stage.name"
|
|
|
|
:title="stage.name"
|
|
|
|
:groups="stage.groups"
|
|
|
|
:action="stage.status.action"
|
|
|
|
:highlighted-jobs="highlightedJobs"
|
|
|
|
:job-hovered="hoveredJobName"
|
|
|
|
:pipeline-expanded="pipelineExpanded"
|
|
|
|
:pipeline-id="pipeline.id"
|
|
|
|
@refreshPipelineGraph="$emit('refreshPipelineGraph')"
|
|
|
|
@jobHover="setJob"
|
|
|
|
/>
|
|
|
|
</links-layer>
|
|
|
|
</div>
|
2021-02-22 17:27:13 +05:30
|
|
|
</template>
|
|
|
|
<template #downstream>
|
|
|
|
<linked-pipelines-column
|
|
|
|
v-if="showDownstreamPipelines"
|
|
|
|
:linked-pipelines="downstreamPipelines"
|
|
|
|
:column-title="__('Downstream')"
|
|
|
|
:type="$options.pipelineTypeConstants.DOWNSTREAM"
|
|
|
|
@downstreamHovered="setJob"
|
|
|
|
@pipelineExpandToggle="togglePipelineExpanded"
|
2021-03-08 18:12:59 +05:30
|
|
|
@error="onError"
|
2021-02-22 17:27:13 +05:30
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
</linked-graph-wrapper>
|
2017-08-17 22:00:37 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|