debian-mirror-gitlab/app/assets/javascripts/pipelines/components/graph_shared/links_layer.vue

76 lines
1.6 KiB
Vue
Raw Normal View History

2021-03-08 18:12:59 +05:30
<script>
2021-10-27 15:23:28 +05:30
import { memoize } from 'lodash';
2021-04-29 21:17:54 +05:30
import { reportToSentry } from '../../utils';
2021-04-17 20:07:23 +05:30
import { parseData } from '../parsing_utils';
2021-03-08 18:12:59 +05:30
import LinksInner from './links_inner.vue';
2021-10-27 15:23:28 +05:30
const parseForLinksBare = (pipeline) => {
const arrayOfJobs = pipeline.flatMap(({ groups }) => groups);
return parseData(arrayOfJobs).links;
};
const parseForLinks = memoize(parseForLinksBare);
2021-03-08 18:12:59 +05:30
export default {
name: 'LinksLayer',
components: {
LinksInner,
},
props: {
containerMeasurements: {
type: Object,
required: true,
},
pipelineData: {
type: Array,
required: true,
},
2021-10-27 15:23:28 +05:30
linksData: {
type: Array,
2021-04-17 20:07:23 +05:30
required: false,
2021-10-27 15:23:28 +05:30
default: () => [],
2021-04-17 20:07:23 +05:30
},
2021-06-08 01:23:25 +05:30
showLinks: {
2021-04-17 20:07:23 +05:30
type: Boolean,
required: false,
2021-06-08 01:23:25 +05:30
default: true,
2021-04-17 20:07:23 +05:30
},
2021-03-08 18:12:59 +05:30
},
computed: {
containerZero() {
return !this.containerMeasurements.width || !this.containerMeasurements.height;
},
2021-10-27 15:23:28 +05:30
getLinksData() {
if (this.linksData.length > 0) {
return this.linksData;
}
return parseForLinks(this.pipelineData);
2021-04-17 20:07:23 +05:30
},
2021-03-08 18:12:59 +05:30
showLinkedLayers() {
2021-06-08 01:23:25 +05:30
return this.showLinks && !this.containerZero;
2021-03-08 18:12:59 +05:30
},
},
2021-04-17 20:07:23 +05:30
errorCaptured(err, _vm, info) {
reportToSentry(this.$options.name, `error: ${err}, info: ${info}`);
},
2021-03-08 18:12:59 +05:30
};
</script>
<template>
<links-inner
v-if="showLinkedLayers"
:container-measurements="containerMeasurements"
2021-10-27 15:23:28 +05:30
:links-data="getLinksData"
2021-03-08 18:12:59 +05:30
:pipeline-data="pipelineData"
v-bind="$attrs"
v-on="$listeners"
>
<slot></slot>
</links-inner>
<div v-else>
2021-03-11 19:13:27 +05:30
<div class="gl-display-flex gl-relative">
<slot></slot>
</div>
2021-03-08 18:12:59 +05:30
</div>
</template>