Skip to content

Commit

Permalink
fix(ui): expanded subflows list is shared between Topology tab & Edit…
Browse files Browse the repository at this point in the history
…orView's topology
  • Loading branch information
brian-mulier-p committed Sep 14, 2023
1 parent 4568b09 commit 1b72943
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 28 deletions.
8 changes: 4 additions & 4 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path ../.gitignore"
},
"dependencies": {
"@kestra-io/ui-libs": "^0.0.16",
"@kestra-io/ui-libs": "^0.0.17",
"@popperjs/core": "npm:@sxzz/[email protected]",
"@vue-flow/background": "^1.2.0",
"@vue-flow/controls": "1.0.6",
Expand Down
6 changes: 6 additions & 0 deletions ui/src/components/flows/FlowEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
:is-read-only="isReadOnly"
:flow-error="flowError"
:flow-deprecations="flowDeprecations"
:expanded-subflows="expandedSubflows"
@expand-subflow="$emit('expand-subflow', $event)"
/>
</template>
<script>
Expand All @@ -26,6 +28,10 @@
isReadOnly: {
type: Boolean,
default: false
},
expandedSubflows: {
type: Array,
default: []
}
},
computed: {
Expand Down
17 changes: 12 additions & 5 deletions ui/src/components/flows/FlowRoot.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<div v-if="ready">
<tabs route-name="flows/update" ref="currentTab" :tabs="tabs" />
<tabs @expand-subflow="updateExpandedSubflows" route-name="flows/update" ref="currentTab" :tabs="tabs" />
<bottom-line v-if="displayBottomLine()">
<ul>
<li>
Expand Down Expand Up @@ -54,7 +54,8 @@
return {
tabIndex: undefined,
previousFlow: undefined,
depedenciesCount: undefined
depedenciesCount: undefined,
expandedSubflows: []
};
},
watch: {
Expand Down Expand Up @@ -84,7 +85,6 @@
}
});
}
},
flowKey() {
return this.$route.params.namespace + "/" + this.$route.params.id;
Expand All @@ -96,7 +96,8 @@
component: Topology,
title: this.$t("topology"),
props: {
isReadOnly: true
isReadOnly: true,
expandedSubflows: this.expandedSubflows
}
},
];
Expand Down Expand Up @@ -126,6 +127,9 @@
name: "editor",
component: FlowEditor,
title: this.$t("editor"),
props: {
expandedSubflows: this.expandedSubflows
}
});
}
Expand Down Expand Up @@ -189,6 +193,9 @@
tab: "editor"
}})
},
updateExpandedSubflows(expandedSubflows) {
this.expandedSubflows = expandedSubflows;
}
},
computed: {
...mapState("flow", ["flow"]),
Expand Down Expand Up @@ -229,7 +236,7 @@
return this.user.isAllowed(permission.EXECUTION, action.CREATE, this.flow.namespace)
}
return false;
},
}
},
unmounted () {
this.$store.commit("flow/setFlow", undefined)
Expand Down
11 changes: 5 additions & 6 deletions ui/src/components/flows/Topology.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
isReadOnly: {
type: Boolean,
default: false
},
expandedSubflows: {
type: Array,
default: []
}
},
computed: {
Expand All @@ -39,14 +43,9 @@
beforeUnmount() {
this.$store.commit("flow/setFlowError", undefined);
},
data() {
return {
expandedSubflows: []
}
},
methods: {
onExpandSubflow(event) {
this.expandedSubflows = event;
this.$emit("expand-subflow", event);
this.$store.dispatch("flow/loadGraph", {
flow: this.flow,
params: {
Expand Down
27 changes: 16 additions & 11 deletions ui/src/components/inputs/EditorView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
const store = useStore();
const router = getCurrentInstance().appContext.config.globalProperties.$router;
const emit = defineEmits(["follow"])
const emit = defineEmits(["follow", "expand-subflow"])
const toast = getCurrentInstance().appContext.config.globalProperties.$toast();
const t = getCurrentInstance().appContext.config.globalProperties.$t;
const http = getCurrentInstance().appContext.config.globalProperties.$http;
Expand Down Expand Up @@ -93,6 +93,10 @@
flowDeprecations: {
type: Array,
default: undefined
},
expandedSubflows: {
type: Array,
default: []
}
})
Expand Down Expand Up @@ -165,6 +169,12 @@
taskError.value = store.getters["flow/taskError"];
});
watch(() => props.expandedSubflows, (_, oldValue) => {
fetchGraph().catch(() => {
emit("expand-subflow", oldValue);
});
});
const flowHaveTasks = (source) => {
const flow = source ? source : flowYaml.value
return flow ? YamlUtils.flowHaveTasks(flow) : false;
Expand Down Expand Up @@ -357,14 +367,13 @@
persistEditorContent(false);
}
const expandedSubflows = ref([]);
const fetchGraph = () => {
return store.dispatch("flow/loadGraphFromSource", {
flow: flowYaml.value,
config: {
params: {
// due to usage of axios instance instead of $http which doesn't convert arrays
subflows: expandedSubflows.value.join(","),
subflows: props.expandedSubflows.join(","),
},
validateStatus: (status) => {
return status === 200 || status === 422;
Expand Down Expand Up @@ -649,15 +658,11 @@
}
const onExpandSubflow = (e) => {
const oldExpandedSubflows = expandedSubflows.value;
expandedSubflows.value = e;
fetchGraph().catch(() => {
expandedSubflows.value = oldExpandedSubflows;
});
emit("expand-subflow", e);
}
const onSwappedTask = (swappedTasks) => {
expandedSubflows.value = expandedSubflows.value.map(expandedSubflow => {
emit("expand-subflow", props.expandedSubflows.map(expandedSubflow => {
let swappedTaskSplit;
if (expandedSubflow === swappedTasks[0]) {
swappedTaskSplit = swappedTasks[1].split(".");
Expand All @@ -673,7 +678,7 @@
}
return expandedSubflow;
});
}));
}
</script>
Expand Down Expand Up @@ -719,7 +724,7 @@
:source="flowYaml"
:is-allowed-edit="isAllowedEdit()"
:view-type="viewType"
:expanded-subflows="expandedSubflows"
:expanded-subflows="props.expandedSubflows"
>
<template #top-bar v-if="viewType === editorViewTypes.TOPOLOGY">
<ValidationError tooltip-placement="bottom-start" size="small" class="ms-2" :error="flowError" :warnings="flowWarnings" />
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/inputs/LowCodeEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@
:flowGraph="props.flowGraph"
:flow-id="flowId"
:namespace="namespace"
:expanded-subflows="expandedSubflows"
:expanded-subflows="props.expandedSubflows"
@toggle-orientation="toggleOrientation"
@edit="onEditTask($event)"
@delete="onDelete"
Expand Down

0 comments on commit 1b72943

Please sign in to comment.