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 25, 2023
1 parent 06963c2 commit b75fe54
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 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,18 @@
}
node.executionId = this.execution.id;
if(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 b75fe54

Please sign in to comment.