fix bug on import new flow

This commit is contained in:
anovazzi1 2023-08-22 11:06:24 -03:00
commit 0fa51db7c5
2 changed files with 4 additions and 7 deletions

View file

@ -214,9 +214,7 @@ export function TabsProvider({ children }: { children: ReactNode }) {
let sourceHandleObject: sourceHandleType = scapeJSONParse( let sourceHandleObject: sourceHandleType = scapeJSONParse(
edge.sourceHandle! edge.sourceHandle!
); );
sourceHandleObject.baseClasses = sourceHandleObject.baseClasses.concat( sourceHandleObject.baseClasses = template["base_classes"];
template["base_classes"]
);
edge.sourceHandle = scapedJSONStringfy(sourceHandleObject); edge.sourceHandle = scapedJSONStringfy(sourceHandleObject);
} }
}); });
@ -513,7 +511,6 @@ export function TabsProvider({ children }: { children: ReactNode }) {
const extractDataFromFlow = (flow: FlowType) => { const extractDataFromFlow = (flow: FlowType) => {
let data = flow?.data ? flow.data : null; let data = flow?.data ? flow.data : null;
const description = flow?.description ? flow.description : ""; const description = flow?.description ? flow.description : "";
if (data) { if (data) {
processFlowEdges(flow); processFlowEdges(flow);
processFlowNodes(flow); processFlowNodes(flow);

View file

@ -71,7 +71,6 @@ export function isValidConnection(
) { ) {
const targetHandleObject: targetHandleType = scapeJSONParse(targetHandle!); const targetHandleObject: targetHandleType = scapeJSONParse(targetHandle!);
const sourceHandleObject: sourceHandleType = scapeJSONParse(sourceHandle!); const sourceHandleObject: sourceHandleType = scapeJSONParse(sourceHandle!);
console.log(sourceHandleObject, targetHandleObject);
if ( if (
targetHandleObject.inputTypes?.some( targetHandleObject.inputTypes?.some(
(n) => n === sourceHandleObject.dataType (n) => n === sourceHandleObject.dataType
@ -283,9 +282,9 @@ export function updateEdgesHandleIds({
} }
if (source && sourceNode) { if (source && sourceNode) {
newSource = { newSource = {
dataType: sourceNode.data.type,
id: sourceNode.data.id, id: sourceNode.data.id,
baseClasses: sourceNode.data.node!.base_classes, baseClasses: sourceNode.data.node!.base_classes,
dataType: sourceNode.data.type,
}; };
} }
edge.sourceHandle = scapedJSONStringfy(newSource!); edge.sourceHandle = scapedJSONStringfy(newSource!);
@ -334,7 +333,8 @@ export function scapedJSONStringfy(json: object): string {
return customStringify(json).replace(/"/g, "œ"); return customStringify(json).replace(/"/g, "œ");
} }
export function scapeJSONParse(json: string): any { export function scapeJSONParse(json: string): any {
return JSON.parse(json.replace(/œ/g, '"')); let parsed = json.replace(/œ/g, '"');
return JSON.parse(parsed);
} }
// this function receives an array of edges and return true if any of the handles are not a json string // this function receives an array of edges and return true if any of the handles are not a json string