Prevent dagre error by checking if source node actually exists before creating edge

This commit is contained in:
Sipke Schoorstra 2021-04-28 22:22:55 +02:00
parent 7a73d071cf
commit ce2e13d9e4

View file

@ -338,7 +338,15 @@ export class ElsaWorkflowDesigner {
});
this.workflowModel.connections.forEach(({sourceId, targetId, outcome}) => {
this.graph.setEdge(`${sourceId}/${outcome}`, targetId, {arrowhead: 'undirected'});
const sourceName = `${sourceId}/${outcome}`;
if(!this.graph.hasNode(sourceName))
{
console.warn(`No source node with ID '${sourceName}' exists.`);
return;
}
this.graph.setEdge(sourceName, targetId, {arrowhead: 'undirected'});
});
}