diff --git a/src/canvas/components/TemplateWorkspace.vue b/src/canvas/components/TemplateWorkspace.vue index d55bd3f..77236ec 100644 --- a/src/canvas/components/TemplateWorkspace.vue +++ b/src/canvas/components/TemplateWorkspace.vue @@ -233,17 +233,24 @@ function getTemplatesNamesSet() { function addToTemplateWorkspace(data, type) { if (type == "workflow") { const block = getEntryWorkflowBlock(data); - if (block.parentNode == undefined) { - block.parentNode = ""; - block.id = getId(); - block.label = block.label + " (*)"; - } + block.label = block.label + " (*)"; + block.id = getId(); fullElements.value.push(block); elements.value.push(block); } else { - data.label = data.label + " (*)"; - fullElements.value.push(data); - elements.value.push(data); + //Create a new object to make sure no values are carried over when un needed + //We don't do this for workflow type as the dsl generate new element objects anyway + let element = { + id: getId(), + definition: data.definition, + label: data.label + " (*)", + parentNode: "", + type: data.type, + position: { x: 0, y: 0 }, + width: data.width, + }; + fullElements.value.push(element); + elements.value.push(element); } } diff --git a/src/canvas/components/canvases/BuildCanvas.vue b/src/canvas/components/canvases/BuildCanvas.vue index e640863..97e19e6 100644 --- a/src/canvas/components/canvases/BuildCanvas.vue +++ b/src/canvas/components/canvases/BuildCanvas.vue @@ -789,13 +789,24 @@ function getChildrenNodes(parentNode, validNodes, childrenNodes) { }); } const addToTemplateWorkspace = () => { - if (selectedNode.type == "workflow") { + //Deep copy the node so we sever the connection between the node in the canvas + //and the node in the template workspace + let selectedTemplateCopy = JSON.parse(JSON.stringify(selectedNode)); + if (selectedTemplateCopy.type == "workflow") { //prep Nodes let validNodes = nodes.value.filter( (node) => node.type == "workflow" || node.type == "component", ); let childrenNodes = []; - getChildrenNodes(selectedNode, validNodes, childrenNodes); + //Set the node as entrypoint to get correct DSL + selectedTemplateCopy.isEntry = true; + getChildrenNodes(selectedTemplateCopy, validNodes, childrenNodes); + //Make sure only the entrypointNode is set as entrypoint + childrenNodes.map((node) => { + if (node.id != selectedTemplateCopy.id) { + node.isEntry = false; + } + }); let workflowDsl = getDsl(childrenNodes, edges.value); templateWorkspace.value.addToTemplateWorkspace(workflowDsl, "workflow"); let notification = { @@ -805,10 +816,13 @@ const addToTemplateWorkspace = () => { }; emit("updateBuildCanvasNotification", notification); } else { - //Deep copy the node so we sever the connection between the node in the canvas - //and the node in the template workspace + //if node is a step, we have to remove stepId and update the node label + if (selectedTemplateCopy.stepId) { + delete selectedTemplateCopy.stepId; + } + updateNodeLabel(selectedTemplateCopy); templateWorkspace.value.addToTemplateWorkspace( - JSON.parse(JSON.stringify(selectedNode)), + selectedTemplateCopy, "component", ); let notification = { diff --git a/src/canvas/functions/buildExperiment.js b/src/canvas/functions/buildExperiment.js index c6508e4..81d7c21 100644 --- a/src/canvas/functions/buildExperiment.js +++ b/src/canvas/functions/buildExperiment.js @@ -9,7 +9,7 @@ export default function buildExperiment(nodes, edges, entryNode) { if (entryNode != undefined) { result = { entrypoint: { - "entry-instance": entryNode.label, + "entry-instance": entryNode.definition.signature.name, execute: [ { target: "",