2017-05-06 13:02:06 -04:00
|
|
|
<script>
|
2018-11-16 14:29:11 -05:00
|
|
|
import { GlLoadingIcon } from '@gitlab/ui';
|
2018-04-06 11:42:19 -04:00
|
|
|
import StageColumnComponent from './stage_column_component.vue';
|
2019-01-11 08:12:48 -05:00
|
|
|
import GraphMixin from '../../mixins/graph_component_mixin';
|
2019-10-10 05:06:08 -04:00
|
|
|
import GraphWidthMixin from '../../mixins/graph_width_mixin';
|
|
|
|
import LinkedPipelinesColumn from './linked_pipelines_column.vue';
|
|
|
|
import GraphBundleMixin from '../../mixins/graph_pipeline_bundle_mixin';
|
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: {
|
|
|
|
StageColumnComponent,
|
2018-11-07 05:06:15 -05:00
|
|
|
GlLoadingIcon,
|
2019-10-10 05:06:08 -04:00
|
|
|
LinkedPipelinesColumn,
|
|
|
|
},
|
|
|
|
mixins: [GraphMixin, GraphWidthMixin, GraphBundleMixin],
|
|
|
|
props: {
|
|
|
|
isLoading: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
pipeline: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
isLinkedPipeline: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
mediator: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: 'main',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
upstream: 'upstream',
|
|
|
|
downstream: 'downstream',
|
|
|
|
data() {
|
|
|
|
return {
|
2020-01-15 01:08:54 -05:00
|
|
|
downstreamMarginTop: null,
|
2020-07-16 11:09:38 -04:00
|
|
|
jobName: null,
|
2019-10-10 05:06:08 -04:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
hasTriggeredBy() {
|
|
|
|
return (
|
|
|
|
this.type !== this.$options.downstream &&
|
|
|
|
this.triggeredByPipelines &&
|
|
|
|
this.pipeline.triggered_by !== null
|
|
|
|
);
|
|
|
|
},
|
|
|
|
triggeredByPipelines() {
|
|
|
|
return this.pipeline.triggered_by;
|
|
|
|
},
|
|
|
|
hasTriggered() {
|
|
|
|
return (
|
|
|
|
this.type !== this.$options.upstream &&
|
|
|
|
this.triggeredPipelines &&
|
|
|
|
this.pipeline.triggered.length > 0
|
|
|
|
);
|
|
|
|
},
|
|
|
|
triggeredPipelines() {
|
|
|
|
return this.pipeline.triggered;
|
|
|
|
},
|
|
|
|
expandedTriggeredBy() {
|
|
|
|
return (
|
|
|
|
this.pipeline.triggered_by &&
|
2020-02-13 16:08:59 -05:00
|
|
|
Array.isArray(this.pipeline.triggered_by) &&
|
2019-10-10 05:06:08 -04:00
|
|
|
this.pipeline.triggered_by.find(el => el.isExpanded)
|
|
|
|
);
|
|
|
|
},
|
|
|
|
expandedTriggered() {
|
|
|
|
return this.pipeline.triggered && this.pipeline.triggered.find(el => el.isExpanded);
|
|
|
|
},
|
|
|
|
pipelineTypeUpstream() {
|
|
|
|
return this.type !== this.$options.downstream && this.expandedTriggeredBy;
|
|
|
|
},
|
|
|
|
pipelineTypeDownstream() {
|
|
|
|
return this.type !== this.$options.upstream && this.expandedTriggered;
|
|
|
|
},
|
2020-01-15 01:08:54 -05:00
|
|
|
pipelineProjectId() {
|
|
|
|
return this.pipeline.project.id;
|
|
|
|
},
|
2019-10-10 05:06:08 -04:00
|
|
|
},
|
|
|
|
methods: {
|
2020-01-15 01:08:54 -05:00
|
|
|
handleClickedDownstream(pipeline, clickedIndex, downstreamNode) {
|
|
|
|
/**
|
|
|
|
* Calculates the margin top of the clicked downstream pipeline by
|
|
|
|
* subtracting the clicked downstream pipelines offsetTop by it's parent's
|
2020-07-16 11:09:38 -04:00
|
|
|
* offsetTop and then subtracting 15
|
2020-01-15 01:08:54 -05:00
|
|
|
*/
|
2020-07-16 11:09:38 -04:00
|
|
|
this.downstreamMarginTop = this.calculateMarginTop(downstreamNode, 15);
|
2020-01-15 01:08:54 -05:00
|
|
|
|
2020-04-08 05:09:43 -04:00
|
|
|
/**
|
|
|
|
* If the expanded trigger is defined and the id is different than the
|
|
|
|
* pipeline we clicked, then it means we clicked on a sibling downstream link
|
|
|
|
* and we want to reset the pipeline store. Triggering the reset without
|
|
|
|
* this condition would mean not allowing downstreams of downstreams to expand
|
|
|
|
*/
|
|
|
|
if (this.expandedTriggered?.id !== pipeline.id) {
|
|
|
|
this.$emit('onResetTriggered', this.pipeline, pipeline);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$emit('onClickTriggered', pipeline);
|
2019-10-10 05:06:08 -04:00
|
|
|
},
|
2020-01-15 01:08:54 -05:00
|
|
|
calculateMarginTop(downstreamNode, pixelDiff) {
|
|
|
|
return `${downstreamNode.offsetTop - downstreamNode.offsetParent.offsetTop - pixelDiff}px`;
|
|
|
|
},
|
2019-10-10 05:06:08 -04:00
|
|
|
hasOnlyOneJob(stage) {
|
|
|
|
return stage.groups.length === 1;
|
|
|
|
},
|
|
|
|
hasUpstream(index) {
|
|
|
|
return index === 0 && this.hasTriggeredBy;
|
|
|
|
},
|
2020-07-16 11:09:38 -04:00
|
|
|
setJob(jobName) {
|
|
|
|
this.jobName = jobName;
|
|
|
|
},
|
2018-04-06 11:42:19 -04:00
|
|
|
},
|
|
|
|
};
|
2017-05-06 13:02:06 -04:00
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<div class="build-content middle-block js-pipeline-graph">
|
2019-10-10 05:06:08 -04:00
|
|
|
<div
|
|
|
|
class="pipeline-visualization pipeline-graph"
|
|
|
|
:class="{ 'pipeline-tab-content': !isLinkedPipeline }"
|
|
|
|
>
|
2019-09-18 10:02:45 -04:00
|
|
|
<div
|
|
|
|
:style="{
|
2020-08-27 14:10:29 -04:00
|
|
|
paddingLeft: `${graphLeftPadding}px`,
|
|
|
|
paddingRight: `${graphRightPadding}px`,
|
2019-09-18 10:02:45 -04:00
|
|
|
}"
|
|
|
|
>
|
2020-04-14 11:09:44 -04:00
|
|
|
<gl-loading-icon v-if="isLoading" class="m-auto" size="lg" />
|
2017-05-06 13:02:06 -04:00
|
|
|
|
2019-10-10 05:06:08 -04:00
|
|
|
<pipeline-graph
|
|
|
|
v-if="pipelineTypeUpstream"
|
|
|
|
type="upstream"
|
|
|
|
class="d-inline-block upstream-pipeline"
|
|
|
|
:class="`js-upstream-pipeline-${expandedTriggeredBy.id}`"
|
|
|
|
:is-loading="false"
|
|
|
|
:pipeline="expandedTriggeredBy"
|
|
|
|
:is-linked-pipeline="true"
|
|
|
|
:mediator="mediator"
|
2020-04-08 05:09:43 -04:00
|
|
|
@onClickTriggeredBy="clickTriggeredByPipeline"
|
2019-10-10 05:06:08 -04:00
|
|
|
@refreshPipelineGraph="requestRefreshPipelineGraph"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<linked-pipelines-column
|
|
|
|
v-if="hasTriggeredBy"
|
|
|
|
:linked-pipelines="triggeredByPipelines"
|
|
|
|
:column-title="__('Upstream')"
|
2020-01-15 01:08:54 -05:00
|
|
|
:project-id="pipelineProjectId"
|
2019-10-10 05:06:08 -04:00
|
|
|
graph-position="left"
|
2020-04-08 05:09:43 -04:00
|
|
|
@linkedPipelineClick="$emit('onClickTriggeredBy', $event)"
|
2019-10-10 05:06:08 -04:00
|
|
|
/>
|
|
|
|
|
|
|
|
<ul
|
|
|
|
v-if="!isLoading"
|
|
|
|
:class="{
|
|
|
|
'inline js-has-linked-pipelines': hasTriggered || hasTriggeredBy,
|
|
|
|
}"
|
|
|
|
class="stage-column-list align-top"
|
|
|
|
>
|
2019-09-18 10:02:45 -04:00
|
|
|
<stage-column-component
|
|
|
|
v-for="(stage, index) in graph"
|
|
|
|
:key="stage.name"
|
|
|
|
:class="{
|
2020-07-29 20:09:53 -04:00
|
|
|
'has-upstream gl-ml-11': hasUpstream(index),
|
2019-10-10 05:06:08 -04:00
|
|
|
'has-only-one-job': hasOnlyOneJob(stage),
|
2020-06-24 14:09:03 -04:00
|
|
|
'gl-mr-26': shouldAddRightMargin(index),
|
2019-09-18 10:02:45 -04:00
|
|
|
}"
|
|
|
|
:title="capitalizeStageName(stage.name)"
|
|
|
|
:groups="stage.groups"
|
|
|
|
:stage-connector-class="stageConnectorClass(index, stage)"
|
|
|
|
:is-first-column="isFirstColumn(index)"
|
2019-10-10 05:06:08 -04:00
|
|
|
:has-triggered-by="hasTriggeredBy"
|
2019-09-18 10:02:45 -04:00
|
|
|
:action="stage.status.action"
|
2020-07-16 11:09:38 -04:00
|
|
|
:job-hovered="jobName"
|
2019-09-18 10:02:45 -04:00
|
|
|
@refreshPipelineGraph="refreshPipelineGraph"
|
|
|
|
/>
|
|
|
|
</ul>
|
2019-10-10 05:06:08 -04:00
|
|
|
|
|
|
|
<linked-pipelines-column
|
|
|
|
v-if="hasTriggered"
|
|
|
|
:linked-pipelines="triggeredPipelines"
|
|
|
|
:column-title="__('Downstream')"
|
2020-01-15 01:08:54 -05:00
|
|
|
:project-id="pipelineProjectId"
|
2019-10-10 05:06:08 -04:00
|
|
|
graph-position="right"
|
|
|
|
@linkedPipelineClick="handleClickedDownstream"
|
2020-07-16 11:09:38 -04:00
|
|
|
@downstreamHovered="setJob"
|
2019-10-10 05:06:08 -04:00
|
|
|
/>
|
|
|
|
|
|
|
|
<pipeline-graph
|
|
|
|
v-if="pipelineTypeDownstream"
|
|
|
|
type="downstream"
|
|
|
|
class="d-inline-block"
|
|
|
|
:class="`js-downstream-pipeline-${expandedTriggered.id}`"
|
|
|
|
:is-loading="false"
|
|
|
|
:pipeline="expandedTriggered"
|
|
|
|
:is-linked-pipeline="true"
|
2020-01-15 01:08:54 -05:00
|
|
|
:style="{ 'margin-top': downstreamMarginTop }"
|
2019-10-10 05:06:08 -04:00
|
|
|
:mediator="mediator"
|
2020-04-08 05:09:43 -04:00
|
|
|
@onClickTriggered="clickTriggeredPipeline"
|
2019-10-10 05:06:08 -04:00
|
|
|
@refreshPipelineGraph="requestRefreshPipelineGraph"
|
|
|
|
/>
|
2019-09-18 10:02:45 -04:00
|
|
|
</div>
|
2017-05-06 13:02:06 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|