chore(reactflowUtils.ts): add TODO comment to update to new types
feat(reactflowUtils.ts): add function to update group node template to set visibility of basic types to advanced true feat(reactflowUtils.ts): add function to generate node template for group node based on flow data feat(reactflowUtils.ts): add function to generate node from flow data
This commit is contained in:
parent
e129b3c9f4
commit
8cdfb00af6
1 changed files with 34 additions and 0 deletions
|
|
@ -517,6 +517,40 @@ export function validateSelection(
|
||||||
}
|
}
|
||||||
return errorsArray;
|
return errorsArray;
|
||||||
}
|
}
|
||||||
|
// TODO UPDATE TO NEW TYPES
|
||||||
|
function updateGroupNodeTemplate(template: APITemplateType) {
|
||||||
|
/*this function receives a template, iterates for it's items
|
||||||
|
updating the visibility of all basic types setting it to advanced true*/
|
||||||
|
Object.keys(template).forEach((key) => {
|
||||||
|
let type = template[key].type;
|
||||||
|
if (
|
||||||
|
(type === "str" ||
|
||||||
|
type === "bool" ||
|
||||||
|
type === "float" ||
|
||||||
|
type === "code" ||
|
||||||
|
type === "prompt" ||
|
||||||
|
type === "file" ||
|
||||||
|
type === "int") &&
|
||||||
|
!template[key].required
|
||||||
|
) {
|
||||||
|
template[key].advanced = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function generateNodeTemplate(Flow: FlowType) {
|
||||||
|
/*
|
||||||
|
this function receives a flow and generate a template for the group node
|
||||||
|
*/
|
||||||
|
let template = mergeNodeTemplates({
|
||||||
|
nodes: Flow.data!.nodes,
|
||||||
|
edges: Flow.data!.edges,
|
||||||
|
});
|
||||||
|
updateGroupNodeTemplate(template);
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export function generateNodeFromFlow(flow: FlowType): NodeType {
|
export function generateNodeFromFlow(flow: FlowType): NodeType {
|
||||||
const { nodes } = flow.data!;
|
const { nodes } = flow.data!;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue