2017-08-17 22:00:37 +05:30
|
|
|
<script>
|
2019-12-21 20:55:43 +05:30
|
|
|
import _ from 'underscore';
|
2019-02-15 15:39:39 +05:30
|
|
|
import { GlLoadingIcon } from '@gitlab/ui';
|
2018-05-09 12:01:36 +05:30
|
|
|
import StageColumnComponent from './stage_column_component.vue';
|
2019-03-02 22:35:43 +05:30
|
|
|
import GraphMixin from '../../mixins/graph_component_mixin';
|
2019-12-21 20:55:43 +05:30
|
|
|
import GraphWidthMixin from '../../mixins/graph_width_mixin';
|
|
|
|
import LinkedPipelinesColumn from './linked_pipelines_column.vue';
|
|
|
|
import GraphBundleMixin from '../../mixins/graph_pipeline_bundle_mixin';
|
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: {
|
|
|
|
StageColumnComponent,
|
2018-12-13 13:39:08 +05:30
|
|
|
GlLoadingIcon,
|
2019-12-21 20:55:43 +05:30
|
|
|
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 {
|
|
|
|
triggeredTopIndex: 1,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
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 &&
|
|
|
|
_.isArray(this.pipeline.triggered_by) &&
|
|
|
|
this.pipeline.triggered_by.find(el => el.isExpanded)
|
|
|
|
);
|
|
|
|
},
|
|
|
|
expandedTriggered() {
|
|
|
|
return this.pipeline.triggered && this.pipeline.triggered.find(el => el.isExpanded);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates the margin top of the clicked downstream pipeline by
|
|
|
|
* adding the height of each linked pipeline and the margin
|
|
|
|
*/
|
|
|
|
marginTop() {
|
|
|
|
return `${this.triggeredTopIndex * 52}px`;
|
|
|
|
},
|
|
|
|
pipelineTypeUpstream() {
|
|
|
|
return this.type !== this.$options.downstream && this.expandedTriggeredBy;
|
|
|
|
},
|
|
|
|
pipelineTypeDownstream() {
|
|
|
|
return this.type !== this.$options.upstream && this.expandedTriggered;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleClickedDownstream(pipeline, clickedIndex) {
|
|
|
|
this.triggeredTopIndex = clickedIndex;
|
|
|
|
this.$emit('onClickTriggered', this.pipeline, pipeline);
|
|
|
|
},
|
|
|
|
hasOnlyOneJob(stage) {
|
|
|
|
return stage.groups.length === 1;
|
|
|
|
},
|
|
|
|
hasDownstream(index, length) {
|
|
|
|
return index === length - 1 && this.hasTriggered;
|
|
|
|
},
|
|
|
|
hasUpstream(index) {
|
|
|
|
return index === 0 && this.hasTriggeredBy;
|
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
};
|
2017-08-17 22:00:37 +05:30
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<div class="build-content middle-block js-pipeline-graph">
|
2019-12-21 20:55:43 +05:30
|
|
|
<div
|
|
|
|
class="pipeline-visualization pipeline-graph"
|
|
|
|
:class="{ 'pipeline-tab-content': !isLinkedPipeline }"
|
|
|
|
>
|
2019-12-04 20:38:33 +05:30
|
|
|
<div
|
|
|
|
:style="{
|
|
|
|
paddingLeft: `${graphLeftPadding}px`,
|
|
|
|
paddingRight: `${graphRightPadding}px`,
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
<gl-loading-icon v-if="isLoading" class="m-auto" :size="3" />
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
<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"
|
|
|
|
@onClickTriggeredBy="
|
|
|
|
(parentPipeline, pipeline) => clickTriggeredByPipeline(parentPipeline, pipeline)
|
|
|
|
"
|
|
|
|
@refreshPipelineGraph="requestRefreshPipelineGraph"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<linked-pipelines-column
|
|
|
|
v-if="hasTriggeredBy"
|
|
|
|
:linked-pipelines="triggeredByPipelines"
|
|
|
|
:column-title="__('Upstream')"
|
|
|
|
graph-position="left"
|
|
|
|
@linkedPipelineClick="
|
|
|
|
linkedPipeline => $emit('onClickTriggeredBy', pipeline, linkedPipeline)
|
|
|
|
"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<ul
|
|
|
|
v-if="!isLoading"
|
|
|
|
:class="{
|
|
|
|
'inline js-has-linked-pipelines': hasTriggered || hasTriggeredBy,
|
|
|
|
}"
|
|
|
|
class="stage-column-list align-top"
|
|
|
|
>
|
2019-12-04 20:38:33 +05:30
|
|
|
<stage-column-component
|
|
|
|
v-for="(stage, index) in graph"
|
|
|
|
:key="stage.name"
|
|
|
|
:class="{
|
2019-12-21 20:55:43 +05:30
|
|
|
'has-upstream prepend-left-64': hasUpstream(index),
|
|
|
|
'has-downstream': hasDownstream(index, graph.length),
|
|
|
|
'has-only-one-job': hasOnlyOneJob(stage),
|
|
|
|
'append-right-46': shouldAddRightMargin(index),
|
2019-12-04 20:38:33 +05:30
|
|
|
}"
|
|
|
|
:title="capitalizeStageName(stage.name)"
|
|
|
|
:groups="stage.groups"
|
|
|
|
:stage-connector-class="stageConnectorClass(index, stage)"
|
|
|
|
:is-first-column="isFirstColumn(index)"
|
2019-12-21 20:55:43 +05:30
|
|
|
:has-triggered-by="hasTriggeredBy"
|
2019-12-04 20:38:33 +05:30
|
|
|
:action="stage.status.action"
|
|
|
|
@refreshPipelineGraph="refreshPipelineGraph"
|
|
|
|
/>
|
|
|
|
</ul>
|
2019-12-21 20:55:43 +05:30
|
|
|
|
|
|
|
<linked-pipelines-column
|
|
|
|
v-if="hasTriggered"
|
|
|
|
:linked-pipelines="triggeredPipelines"
|
|
|
|
:column-title="__('Downstream')"
|
|
|
|
graph-position="right"
|
|
|
|
@linkedPipelineClick="handleClickedDownstream"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<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"
|
|
|
|
:style="{ 'margin-top': marginTop }"
|
|
|
|
:mediator="mediator"
|
|
|
|
@onClickTriggered="
|
|
|
|
(parentPipeline, pipeline) => clickTriggeredPipeline(parentPipeline, pipeline)
|
|
|
|
"
|
|
|
|
@refreshPipelineGraph="requestRefreshPipelineGraph"
|
|
|
|
/>
|
2019-12-04 20:38:33 +05:30
|
|
|
</div>
|
2017-08-17 22:00:37 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|