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

72 lines
1.8 KiB
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
2018-10-15 14:42:47 +05:30
import _ from 'underscore';
2018-12-23 12:14:25 +05:30
import { GlLoadingIcon } from '@gitlab/ui';
2018-05-09 12:01:36 +05:30
import StageColumnComponent from './stage_column_component.vue';
2017-08-17 22:00:37 +05:30
2018-05-09 12:01:36 +05:30
export default {
components: {
StageColumnComponent,
2018-12-13 13:39:08 +05:30
GlLoadingIcon,
2018-05-09 12:01:36 +05:30
},
props: {
isLoading: {
type: Boolean,
required: true,
},
pipeline: {
type: Object,
required: true,
},
},
computed: {
graph() {
return this.pipeline.details && this.pipeline.details.stages;
2017-08-17 22:00:37 +05:30
},
2018-05-09 12:01:36 +05:30
},
methods: {
capitalizeStageName(name) {
2018-10-15 14:42:47 +05:30
const escapedName = _.escape(name);
return escapedName.charAt(0).toUpperCase() + escapedName.slice(1);
2018-05-09 12:01:36 +05:30
},
isFirstColumn(index) {
return index === 0;
},
stageConnectorClass(index, stage) {
let className;
2017-08-17 22:00:37 +05:30
2018-05-09 12:01:36 +05:30
// If it's the first stage column and only has one job
if (index === 0 && stage.groups.length === 1) {
className = 'no-margin';
} else if (index > 0) {
// If it is not the first column
className = 'left-margin';
}
2017-08-17 22:00:37 +05:30
2018-05-09 12:01:36 +05:30
return className;
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
refreshPipelineGraph() {
this.$emit('refreshPipelineGraph');
},
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">
2018-03-27 19:54:05 +05:30
<div class="pipeline-visualization pipeline-graph pipeline-tab-content">
2018-12-23 12:14:25 +05:30
<div class="text-center"><gl-loading-icon v-if="isLoading" :size="3" /></div>
2017-08-17 22:00:37 +05:30
2018-12-23 12:14:25 +05:30
<ul v-if="!isLoading" class="stage-column-list">
2017-08-17 22:00:37 +05:30
<stage-column-component
2017-09-10 17:25:29 +05:30
v-for="(stage, index) in graph"
2018-12-05 23:21:45 +05:30
:key="stage.name"
2017-08-17 22:00:37 +05:30
:title="capitalizeStageName(stage.name)"
2018-12-13 13:39:08 +05:30
:groups="stage.groups"
2017-08-17 22:00:37 +05:30
:stage-connector-class="stageConnectorClass(index, stage)"
2018-03-17 18:26:18 +05:30
:is-first-column="isFirstColumn(index)"
2018-10-15 14:42:47 +05:30
@refreshPipelineGraph="refreshPipelineGraph"
2018-03-17 18:26:18 +05:30
/>
2017-08-17 22:00:37 +05:30
</ul>
</div>
</div>
</template>