2017-05-06 13:02:06 -04:00
|
|
|
<script>
|
2021-03-26 14:09:16 -04:00
|
|
|
import { reportToSentry } from '../../utils';
|
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-04-21 14:11:09 -04:00
|
|
|
import { generateColumnsFromLayersListMemoized } from '../parsing_utils';
|
2021-04-08 17:09:13 -04:00
|
|
|
import { DOWNSTREAM, MAIN, UPSTREAM, ONE_COL_WIDTH, STAGE_VIEW } 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-26 14:09:16 -04:00
|
|
|
import { 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,
|
|
|
|
},
|
2021-04-21 11:09:35 -04:00
|
|
|
showLinks: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
2021-04-08 17:09:13 -04:00
|
|
|
viewType: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2019-10-10 05:06:08 -04:00
|
|
|
isLinkedPipeline: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-08-11 17:10:33 -04:00
|
|
|
computedPipelineInfo: {
|
|
|
|
type: Object,
|
2021-04-08 17:09:13 -04:00
|
|
|
required: false,
|
2021-08-11 17:10:33 -04:00
|
|
|
default: () => ({}),
|
2021-04-08 17:09:13 -04:00
|
|
|
},
|
2019-10-10 05:06:08 -04:00
|
|
|
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-04-12 17:11:12 -04:00
|
|
|
hoveredSourceJobName: '',
|
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 : [];
|
|
|
|
},
|
2021-04-08 17:09:13 -04:00
|
|
|
layout() {
|
2021-04-21 14:11:09 -04:00
|
|
|
return this.isStageView
|
|
|
|
? this.pipeline.stages
|
2021-08-11 17:10:33 -04:00
|
|
|
: generateColumnsFromLayersListMemoized(
|
|
|
|
this.pipeline,
|
|
|
|
this.computedPipelineInfo.pipelineLayers,
|
|
|
|
);
|
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-04-08 17:09:13 -04:00
|
|
|
isStageView() {
|
|
|
|
return this.viewType === STAGE_VIEW;
|
|
|
|
},
|
2021-08-11 17:10:33 -04:00
|
|
|
linksData() {
|
|
|
|
return this.computedPipelineInfo?.linksData ?? null;
|
|
|
|
},
|
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-04-21 11:09:35 -04:00
|
|
|
showJobLinks() {
|
|
|
|
return !this.isStageView && this.showLinks;
|
2021-04-08 17:09:13 -04:00
|
|
|
},
|
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-04-12 17:11:12 -04:00
|
|
|
setSourceJob(jobName) {
|
|
|
|
this.hoveredSourceJobName = 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-07-19 11:09:40 -04: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 gl-border-t-solid gl-border-t-1 gl-border-gray-100': !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')"
|
2021-04-21 11:09:35 -04:00
|
|
|
:show-links="showJobLinks"
|
2021-01-14 19:10:45 -05:00
|
|
|
:type="$options.pipelineTypeConstants.UPSTREAM"
|
2021-04-08 17:09:13 -04:00
|
|
|
:view-type="viewType"
|
2021-01-14 19:10:45 -05:00
|
|
|
@error="onError"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<template #main>
|
|
|
|
<div :id="containerId" :ref="containerId">
|
|
|
|
<links-layer
|
2021-04-08 17:09:13 -04:00
|
|
|
:pipeline-data="layout"
|
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-08-11 17:10:33 -04:00
|
|
|
:links-data="linksData"
|
2021-02-18 13:10:41 -05:00
|
|
|
:metrics-config="metricsConfig"
|
2021-04-21 11:09:35 -04:00
|
|
|
:show-links="showJobLinks"
|
2021-04-08 17:09:13 -04:00
|
|
|
:view-type="viewType"
|
2021-01-14 07:10:54 -05:00
|
|
|
@error="onError"
|
2021-01-14 19:10:45 -05:00
|
|
|
@highlightedJobsChange="updateHighlightedJobs"
|
|
|
|
>
|
|
|
|
<stage-column-component
|
2021-04-08 17:09:13 -04:00
|
|
|
v-for="column in layout"
|
|
|
|
:key="column.id || column.name"
|
2021-04-12 17:11:12 -04:00
|
|
|
:name="column.name"
|
2021-04-08 17:09:13 -04:00
|
|
|
:groups="column.groups"
|
|
|
|
:action="column.status.action"
|
2021-01-14 19:10:45 -05:00
|
|
|
:highlighted-jobs="highlightedJobs"
|
2021-06-23 14:07:10 -04:00
|
|
|
:is-stage-view="isStageView"
|
2021-01-14 19:10:45 -05:00
|
|
|
:job-hovered="hoveredJobName"
|
2021-04-12 17:11:12 -04:00
|
|
|
:source-job-hovered="hoveredSourceJobName"
|
2021-01-14 19:10:45 -05:00
|
|
|
:pipeline-expanded="pipelineExpanded"
|
|
|
|
:pipeline-id="pipeline.id"
|
2021-06-17 14:10:22 -04:00
|
|
|
:user-permissions="pipeline.userPermissions"
|
2021-01-14 19:10:45 -05:00
|
|
|
@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')"
|
2021-04-21 11:09:35 -04:00
|
|
|
:show-links="showJobLinks"
|
2021-01-14 19:10:45 -05:00
|
|
|
:type="$options.pipelineTypeConstants.DOWNSTREAM"
|
2021-04-08 17:09:13 -04:00
|
|
|
:view-type="viewType"
|
2021-04-12 17:11:12 -04:00
|
|
|
@downstreamHovered="setSourceJob"
|
2021-01-14 19:10:45 -05:00
|
|
|
@pipelineExpandToggle="togglePipelineExpanded"
|
2022-04-21 17:08:43 -04:00
|
|
|
@refreshPipelineGraph="$emit('refreshPipelineGraph')"
|
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>
|