debian-mirror-gitlab/app/assets/javascripts/pipelines/components/graph/graph_component.vue

127 lines
3.5 KiB
Vue
Raw Normal View History

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';
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';
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-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,
},
2019-12-21 20:55:43 +05:30
data() {
return {
2021-02-22 17:27:13 +05:30
hoveredJobName: '',
2020-11-24 15:15:51 +05:30
pipelineExpanded: {
jobName: '',
expanded: false,
},
2019-12-21 20:55:43 +05:30
};
},
computed: {
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-02-22 17:27:13 +05:30
// The two show checks prevent upstream / downstream from showing redundant linked columns
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-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
},
methods: {
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
},
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-02-22 17:27:13 +05:30
class="gl-pipeline-min-h gl-display-flex gl-position-relative gl-overflow-auto gl-bg-gray-10 gl-white-space-nowrap"
:class="{ '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"
@error="emit('error', errorType)"
/>
</template>
<template #main>
2019-12-04 20:38:33 +05:30
<stage-column-component
2021-02-22 17:27:13 +05:30
v-for="stage in graph"
2019-12-04 20:38:33 +05:30
:key="stage.name"
2021-02-22 17:27:13 +05:30
:title="stage.name"
2019-12-04 20:38:33 +05:30
:groups="stage.groups"
:action="stage.status.action"
2021-02-22 17:27:13 +05:30
:job-hovered="hoveredJobName"
2020-11-24 15:15:51 +05:30
:pipeline-expanded="pipelineExpanded"
2021-02-22 17:27:13 +05:30
@refreshPipelineGraph="$emit('refreshPipelineGraph')"
2019-12-04 20:38:33 +05:30
/>
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"
@error="emit('error', errorType)"
/>
</template>
</linked-graph-wrapper>
2017-08-17 22:00:37 +05:30
</div>
</div>
</template>