Commit 2a1a4c45 authored by Frédéric Caplette's avatar Frédéric Caplette Committed by Andrew Fontaine

Move Ci pipeline graph mounted logic to an immediate watcher

Because pipeline_editor component can be used in multiple sections,
we cannot know if the rendering will only happen in mount lifecycle.
Instead, we move the logic to an immediate watcher where the render
can be trigger if:
- The component mounts for the first time
- The pipelineData prop changes

This also merges other watchers that were made to report error since
they are also dependants on the pipelineData.
parent a2610ef0
...@@ -126,33 +126,22 @@ export default { ...@@ -126,33 +126,22 @@ export default {
}, },
}, },
watch: { watch: {
isPipelineDataEmpty: { pipelineData: {
immediate: true, immediate: true,
handler(isDataEmpty) { handler() {
if (isDataEmpty) { if (this.isPipelineDataEmpty) {
this.reportFailure(EMPTY_PIPELINE_DATA); this.reportFailure(EMPTY_PIPELINE_DATA);
} } else if (this.isInvalidCiConfig) {
},
},
isInvalidCiConfig: {
immediate: true,
handler(isInvalid) {
if (isInvalid) {
this.reportFailure(INVALID_CI_CONFIG); this.reportFailure(INVALID_CI_CONFIG);
} else {
this.$nextTick(() => {
this.computeGraphDimensions();
this.prepareLinkData();
});
} }
}, },
}, },
}, },
mounted() {
if (!this.isPipelineDataEmpty && !this.isInvalidCiConfig) {
// This guarantee that all sub-elements are rendered
// https://v3.vuejs.org/api/options-lifecycle-hooks.html#mounted
this.$nextTick(() => {
this.getGraphDimensions();
this.prepareLinkData();
});
}
},
methods: { methods: {
prepareLinkData() { prepareLinkData() {
try { try {
...@@ -194,7 +183,7 @@ export default { ...@@ -194,7 +183,7 @@ export default {
removeHighlightNeeds() { removeHighlightNeeds() {
this.highlightedJob = null; this.highlightedJob = null;
}, },
getGraphDimensions() { computeGraphDimensions() {
this.width = `${this.$refs[this.$options.CONTAINER_REF].scrollWidth}`; this.width = `${this.$refs[this.$options.CONTAINER_REF].scrollWidth}`;
this.height = `${this.$refs[this.$options.CONTAINER_REF].scrollHeight}`; this.height = `${this.$refs[this.$options.CONTAINER_REF].scrollHeight}`;
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment