Skip to content

Commit

Permalink
feat(ui): reduced opacity on unused paths
Browse files Browse the repository at this point in the history
closes #241
  • Loading branch information
brian-mulier-p committed Sep 26, 2023
1 parent 08cb9e4 commit 9b505aa
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 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 @@ -11,7 +11,7 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path ../.gitignore"
},
"dependencies": {
"@kestra-io/ui-libs": "^0.0.22",
"@kestra-io/ui-libs": "^0.0.23",
"@popperjs/core": "npm:@sxzz/[email protected]",
"@vue-flow/background": "^1.2.0",
"@vue-flow/controls": "1.0.6",
Expand Down
46 changes: 46 additions & 0 deletions ui/src/components/executions/Topology.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,35 @@
},
loadData(){
this.loadGraph();
},
isUnused: function (nodeByUid, nodeUid) {
let nodeToCheck = nodeByUid[nodeUid];
if(!nodeToCheck) {
return false;
}
if(!nodeToCheck.task) {
// check if parent is unused (current node is probably a cluster root or end)
const splitUid = nodeToCheck.uid.split(".");
splitUid.pop();
return this.isUnused(nodeByUid, splitUid.join("."));
}
if (!nodeToCheck.executionId) {
return true;
}
const nodeExecution = nodeToCheck.executionId === this.execution?.id ? this.execution
: Object.values(this.subflowsExecutions).filter(execution => execution.id === this.data.executionId)?.[0];
if (!nodeExecution) {
return true;
}
return !nodeExecution.taskRunList.some(taskRun => taskRun.taskId === nodeToCheck.task?.id);
},
loadGraph(force) {
if (this.execution && (force || (this.flowGraph === undefined || this.previousExecutionId !== this.execution.id))) {
Expand All @@ -89,8 +118,14 @@
?.filter(cluster => cluster.type.endsWith("SubflowGraphCluster"))
?.map(cluster => cluster.uid.replace(CLUSTER_PREFIX, ""))
?? [];
const nodeByUid = {};
this.flowGraph.nodes
// lowest depth first to be available in nodeByUid map for child-to-parent unused check
.sort((a, b) => a.uid.length - b.uid.length)
.forEach(node => {
nodeByUid[node.uid] = node;
const parentSubflow = subflowPaths.filter(subflowPath => node.uid.startsWith(subflowPath + "."))
.sort((a, b) => b.length - a.length)?.[0]
Expand All @@ -103,8 +138,19 @@
}
node.executionId = this.execution.id;
// reduce opacity for cluster root & end
if(!node.task && this.isUnused(nodeByUid, node.uid)) {
node.unused = true;
}
});
this.flowGraph.edges
// keep only unused (or skipped) paths
.filter(edge => {
return this.isUnused(nodeByUid, edge.target) || this.isUnused(nodeByUid, edge.source);
}).forEach(edge => edge.unused = true);
// force refresh
this.$store.commit("flow/setFlowGraph", Object.assign({}, this.flowGraph));
})
Expand Down

0 comments on commit 9b505aa

Please sign in to comment.