use new loop variable reference field (#1485)
This commit is contained in:
@@ -28,7 +28,7 @@ function LoopNode({ id, data }: NodeProps<LoopNode>) {
|
|||||||
initialValue: data.label,
|
initialValue: data.label,
|
||||||
});
|
});
|
||||||
const [inputs, setInputs] = useState({
|
const [inputs, setInputs] = useState({
|
||||||
loopValue: data.loopValue,
|
loopVariableReference: data.loopVariableReference,
|
||||||
});
|
});
|
||||||
const deleteNodeCallback = useDeleteNodeCallback();
|
const deleteNodeCallback = useDeleteNodeCallback();
|
||||||
|
|
||||||
@@ -105,13 +105,13 @@ function LoopNode({ id, data }: NodeProps<LoopNode>) {
|
|||||||
</div>
|
</div>
|
||||||
<WorkflowBlockInput
|
<WorkflowBlockInput
|
||||||
nodeId={id}
|
nodeId={id}
|
||||||
value={inputs.loopValue}
|
value={inputs.loopVariableReference}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
setInputs({
|
setInputs({
|
||||||
...inputs,
|
...inputs,
|
||||||
loopValue: value,
|
loopVariableReference: value,
|
||||||
});
|
});
|
||||||
updateNodeData(id, { loopValue: value });
|
updateNodeData(id, { loopVariableReference: value });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { NodeBaseData } from "../types";
|
|||||||
|
|
||||||
export type LoopNodeData = NodeBaseData & {
|
export type LoopNodeData = NodeBaseData & {
|
||||||
loopValue: string;
|
loopValue: string;
|
||||||
|
loopVariableReference: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type LoopNode = Node<LoopNodeData, "loop">;
|
export type LoopNode = Node<LoopNodeData, "loop">;
|
||||||
@@ -11,6 +12,7 @@ export const loopNodeDefaultData: LoopNodeData = {
|
|||||||
editable: true,
|
editable: true,
|
||||||
label: "",
|
label: "",
|
||||||
loopValue: "",
|
loopValue: "",
|
||||||
|
loopVariableReference: "",
|
||||||
continueOnFailure: false,
|
continueOnFailure: false,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
|||||||
@@ -365,6 +365,10 @@ function convertToNode(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
case "for_loop": {
|
case "for_loop": {
|
||||||
|
const loopVariableReference =
|
||||||
|
block.loop_variable_reference !== null
|
||||||
|
? block.loop_variable_reference
|
||||||
|
: block.loop_over.key;
|
||||||
return {
|
return {
|
||||||
...identifiers,
|
...identifiers,
|
||||||
...common,
|
...common,
|
||||||
@@ -372,6 +376,7 @@ function convertToNode(
|
|||||||
data: {
|
data: {
|
||||||
...commonData,
|
...commonData,
|
||||||
loopValue: block.loop_over.key,
|
loopValue: block.loop_over.key,
|
||||||
|
loopVariableReference: loopVariableReference,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1073,6 +1078,7 @@ function getWorkflowBlocksUtil(
|
|||||||
continue_on_failure: node.data.continueOnFailure,
|
continue_on_failure: node.data.continueOnFailure,
|
||||||
loop_over_parameter_key: node.data.loopValue,
|
loop_over_parameter_key: node.data.loopValue,
|
||||||
loop_blocks: getOrderedChildrenBlocks(nodes, edges, node.id),
|
loop_blocks: getOrderedChildrenBlocks(nodes, edges, node.id),
|
||||||
|
loop_variable_reference: node.data.loopVariableReference,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -1570,6 +1576,7 @@ function convertBlocksToBlockYAML(
|
|||||||
block_type: "for_loop",
|
block_type: "for_loop",
|
||||||
loop_over_parameter_key: block.loop_over.key,
|
loop_over_parameter_key: block.loop_over.key,
|
||||||
loop_blocks: convertBlocksToBlockYAML(block.loop_blocks),
|
loop_blocks: convertBlocksToBlockYAML(block.loop_blocks),
|
||||||
|
loop_variable_reference: block.loop_variable_reference,
|
||||||
};
|
};
|
||||||
return blockYaml;
|
return blockYaml;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,6 +186,7 @@ export type ForLoopBlock = WorkflowBlockBase & {
|
|||||||
block_type: "for_loop";
|
block_type: "for_loop";
|
||||||
loop_over: WorkflowParameter;
|
loop_over: WorkflowParameter;
|
||||||
loop_blocks: Array<WorkflowBlock>;
|
loop_blocks: Array<WorkflowBlock>;
|
||||||
|
loop_variable_reference: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CodeBlock = WorkflowBlockBase & {
|
export type CodeBlock = WorkflowBlockBase & {
|
||||||
|
|||||||
@@ -250,4 +250,5 @@ export type ForLoopBlockYAML = BlockYAMLBase & {
|
|||||||
block_type: "for_loop";
|
block_type: "for_loop";
|
||||||
loop_over_parameter_key: string;
|
loop_over_parameter_key: string;
|
||||||
loop_blocks: Array<BlockYAML>;
|
loop_blocks: Array<BlockYAML>;
|
||||||
|
loop_variable_reference: string | null;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user