Skip to content

Commit

Permalink
fix: ensure parentNode and stepId are removed when adding to template…
Browse files Browse the repository at this point in the history
… workspace, ensure only one entrypoint, show label instead of name (#479)

Signed-off-by: Doaa Radwan <[email protected]>
  • Loading branch information
DoaaRadwan authored and GitHub Enterprise committed Jan 10, 2024
1 parent 9eba7a0 commit 34c5ed5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
23 changes: 15 additions & 8 deletions src/canvas/components/TemplateWorkspace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
24 changes: 19 additions & 5 deletions src/canvas/components/canvases/BuildCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion src/canvas/functions/buildExperiment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<entry-instance>",
Expand Down

0 comments on commit 34c5ed5

Please sign in to comment.