2017-05-06 13:02:06 -04:00
|
|
|
<script>
|
2020-12-07 10:09:49 -05:00
|
|
|
import LinkedGraphWrapper from '../graph_shared/linked_graph_wrapper.vue';
|
2021-01-14 07:10:54 -05:00
|
|
|
import LinksLayer from '../graph_shared/links_layer.vue';
|
2021-02-14 13:09:20 -05:00
|
|
|
import { DOWNSTREAM, MAIN, UPSTREAM, ONE_COL_WIDTH } from './constants';
|
2020-12-07 10:09:49 -05:00
|
|
|
import LinkedPipelinesColumn from './linked_pipelines_column.vue';
|
2018-04-06 11:42:19 -04:00
|
|
|
import StageColumnComponent from './stage_column_component.vue';
|
2021-03-02 13:11:20 -05:00
|
|
|
import { reportToSentry, validateConfigPaths } from './utils';
|
2017-05-06 13:02:06 -04:00
|
|
|
|
2018-04-06 11:42:19 -04:00
|
|
|
export default {
|
2019-10-10 05:06:08 -04:00
|
|
|
name: 'PipelineGraph',
|
2018-04-06 11:42:19 -04:00
|
|
|
components: {
|
2021-01-14 07:10:54 -05:00
|
|
|
LinksLayer,
|
2020-12-07 10:09:49 -05:00
|
|
|
LinkedGraphWrapper,
|
|
|
|
LinkedPipelinesColumn,
|
2018-04-06 11:42:19 -04:00
|
|
|
StageColumnComponent,
|
2019-10-10 05:06:08 -04:00
|
|
|
},
|
|
|
|
props: {
|
2021-03-02 13:11:20 -05:00
|
|
|
configPaths: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
validator: validateConfigPaths,
|
|
|
|
},
|
2021-02-18 13:10:41 -05:00
|
|
|
pipeline: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2019-10-10 05:06:08 -04:00
|
|
|
isLinkedPipeline: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
2020-11-17 13:09:20 -05:00
|
|
|
default: MAIN,
|
2019-10-10 05:06:08 -04:00
|
|
|
},
|
|
|
|
},
|
2020-12-07 10:09:49 -05:00
|
|
|
pipelineTypeConstants: {
|
|
|
|
DOWNSTREAM,
|
|
|
|
UPSTREAM,
|
|
|
|
},
|
2021-01-14 07:10:54 -05:00
|
|
|
CONTAINER_REF: 'PIPELINE_LINKS_CONTAINER_REF',
|
|
|
|
BASE_CONTAINER_ID: 'pipeline-links-container',
|
2020-12-07 10:09:49 -05:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
hoveredJobName: '',
|
2021-01-14 19:10:45 -05:00
|
|
|
highlightedJobs: [],
|
2021-01-14 07:10:54 -05:00
|
|
|
measurements: {
|
|
|
|
width: 0,
|
|
|
|
height: 0,
|
|
|
|
},
|
2020-12-07 10:09:49 -05:00
|
|
|
pipelineExpanded: {
|
|
|
|
jobName: '',
|
|
|
|
expanded: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
2019-10-10 05:06:08 -04:00
|
|
|
computed: {
|
2021-01-14 07:10:54 -05:00
|
|
|
containerId() {
|
|
|
|
return `${this.$options.BASE_CONTAINER_ID}-${this.pipeline.id}`;
|
|
|
|
},
|
2020-12-07 10:09:49 -05:00
|
|
|
downstreamPipelines() {
|
|
|
|
return this.hasDownstreamPipelines ? this.pipeline.downstream : [];
|
|
|
|
},
|
2020-09-24 14:09:51 -04:00
|
|
|
graph() {
|
2020-11-27 07:09:14 -05:00
|
|
|
return this.pipeline.stages;
|
2020-01-15 01:08:54 -05:00
|
|
|
},
|
2020-12-07 10:09:49 -05:00
|
|
|
hasDownstreamPipelines() {
|
|
|
|
return Boolean(this.pipeline?.downstream?.length > 0);
|
|
|
|
},
|
|
|
|
hasUpstreamPipelines() {
|
|
|
|
return Boolean(this.pipeline?.upstream?.length > 0);
|
|
|
|
},
|
2021-02-18 13:10:41 -05:00
|
|
|
metricsConfig() {
|
|
|
|
return {
|
2021-03-02 13:11:20 -05:00
|
|
|
path: this.configPaths.metricsPath,
|
2021-02-18 13:10:41 -05:00
|
|
|
collectMetrics: true,
|
|
|
|
};
|
|
|
|
},
|
2021-01-14 07:10:54 -05:00
|
|
|
// The show downstream check prevents showing redundant linked columns
|
2020-12-07 10:09:49 -05:00
|
|
|
showDownstreamPipelines() {
|
|
|
|
return (
|
|
|
|
this.hasDownstreamPipelines && this.type !== this.$options.pipelineTypeConstants.UPSTREAM
|
|
|
|
);
|
|
|
|
},
|
2021-01-14 07:10:54 -05:00
|
|
|
// The show upstream check prevents showing redundant linked columns
|
2020-12-07 10:09:49 -05:00
|
|
|
showUpstreamPipelines() {
|
|
|
|
return (
|
|
|
|
this.hasUpstreamPipelines && this.type !== this.$options.pipelineTypeConstants.DOWNSTREAM
|
|
|
|
);
|
|
|
|
},
|
|
|
|
upstreamPipelines() {
|
|
|
|
return this.hasUpstreamPipelines ? this.pipeline.upstream : [];
|
|
|
|
},
|
|
|
|
},
|
2021-01-11 16:10:36 -05:00
|
|
|
errorCaptured(err, _vm, info) {
|
|
|
|
reportToSentry(this.$options.name, `error: ${err}, info: ${info}`);
|
|
|
|
},
|
2021-01-14 07:10:54 -05:00
|
|
|
mounted() {
|
2021-02-03 04:09:07 -05:00
|
|
|
this.getMeasurements();
|
2021-01-14 07:10:54 -05:00
|
|
|
},
|
2020-12-07 10:09:49 -05:00
|
|
|
methods: {
|
2021-01-14 07:10:54 -05:00
|
|
|
getMeasurements() {
|
2021-02-03 04:09:07 -05:00
|
|
|
this.measurements = {
|
2021-01-14 07:10:54 -05:00
|
|
|
width: this.$refs[this.containerId].scrollWidth,
|
|
|
|
height: this.$refs[this.containerId].scrollHeight,
|
|
|
|
};
|
|
|
|
},
|
2021-03-12 13:09:23 -05:00
|
|
|
onError(payload) {
|
|
|
|
this.$emit('error', payload);
|
2021-01-14 07:10:54 -05:00
|
|
|
},
|
2020-12-07 10:09:49 -05:00
|
|
|
setJob(jobName) {
|
|
|
|
this.hoveredJobName = jobName;
|
|
|
|
},
|
2021-01-22 16:09:10 -05:00
|
|
|
slidePipelineContainer() {
|
|
|
|
this.$refs.mainPipelineContainer.scrollBy({
|
|
|
|
left: ONE_COL_WIDTH,
|
|
|
|
top: 0,
|
|
|
|
behavior: 'smooth',
|
|
|
|
});
|
|
|
|
},
|
2020-12-07 10:09:49 -05:00
|
|
|
togglePipelineExpanded(jobName, expanded) {
|
|
|
|
this.pipelineExpanded = {
|
|
|
|
expanded,
|
|
|
|
jobName: expanded ? jobName : '',
|
|
|
|
};
|
|
|
|
},
|
2021-01-14 19:10:45 -05:00
|
|
|
updateHighlightedJobs(jobs) {
|
|
|
|
this.highlightedJobs = jobs;
|
|
|
|
},
|
2019-10-10 05:06:08 -04:00
|
|
|
},
|
2018-04-06 11:42:19 -04:00
|
|
|
};
|
2017-05-06 13:02:06 -04:00
|
|
|
</script>
|
|
|
|
<template>
|
2020-11-27 13:09:52 -05:00
|
|
|
<div class="js-pipeline-graph">
|
2019-10-10 05:06:08 -04:00
|
|
|
<div
|
2021-01-22 16:09:10 -05:00
|
|
|
ref="mainPipelineContainer"
|
2021-01-21 19:09:25 -05:00
|
|
|
class="gl-display-flex gl-position-relative gl-bg-gray-10 gl-white-space-nowrap"
|
|
|
|
:class="{ 'gl-pipeline-min-h gl-py-5 gl-overflow-auto': !isLinkedPipeline }"
|
2019-10-10 05:06:08 -04:00
|
|
|
>
|
2021-01-14 19:10:45 -05:00
|
|
|
<linked-graph-wrapper>
|
|
|
|
<template #upstream>
|
|
|
|
<linked-pipelines-column
|
|
|
|
v-if="showUpstreamPipelines"
|
2021-03-02 13:11:20 -05:00
|
|
|
:config-paths="configPaths"
|
2021-01-14 19:10:45 -05:00
|
|
|
:linked-pipelines="upstreamPipelines"
|
|
|
|
:column-title="__('Upstream')"
|
|
|
|
:type="$options.pipelineTypeConstants.UPSTREAM"
|
|
|
|
@error="onError"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<template #main>
|
|
|
|
<div :id="containerId" :ref="containerId">
|
|
|
|
<links-layer
|
|
|
|
:pipeline-data="graph"
|
2021-01-14 07:10:54 -05:00
|
|
|
:pipeline-id="pipeline.id"
|
2021-01-14 19:10:45 -05:00
|
|
|
:container-id="containerId"
|
|
|
|
:container-measurements="measurements"
|
|
|
|
:highlighted-job="hoveredJobName"
|
2021-02-18 13:10:41 -05:00
|
|
|
:metrics-config="metricsConfig"
|
2021-03-15 17:09:16 -04:00
|
|
|
:never-show-links="true"
|
2021-01-14 19:10:45 -05:00
|
|
|
default-link-color="gl-stroke-transparent"
|
2021-01-14 07:10:54 -05:00
|
|
|
@error="onError"
|
2021-01-14 19:10:45 -05:00
|
|
|
@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"
|
2021-02-03 04:09:07 -05:00
|
|
|
@updateMeasurements="getMeasurements"
|
2021-01-14 19:10:45 -05:00
|
|
|
/>
|
|
|
|
</links-layer>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template #downstream>
|
|
|
|
<linked-pipelines-column
|
|
|
|
v-if="showDownstreamPipelines"
|
2021-02-02 10:09:06 -05:00
|
|
|
class="gl-mr-6"
|
2021-03-02 13:11:20 -05:00
|
|
|
:config-paths="configPaths"
|
2021-01-14 19:10:45 -05:00
|
|
|
:linked-pipelines="downstreamPipelines"
|
|
|
|
:column-title="__('Downstream')"
|
|
|
|
:type="$options.pipelineTypeConstants.DOWNSTREAM"
|
|
|
|
@downstreamHovered="setJob"
|
|
|
|
@pipelineExpandToggle="togglePipelineExpanded"
|
2021-01-22 16:09:10 -05:00
|
|
|
@scrollContainer="slidePipelineContainer"
|
2021-01-14 19:10:45 -05:00
|
|
|
@error="onError"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
</linked-graph-wrapper>
|
2017-05-06 13:02:06 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|