updateTemplate migration done
This commit is contained in:
parent
db8f5a74d3
commit
9a41ca9ce2
2 changed files with 26 additions and 6 deletions
|
|
@ -20,12 +20,8 @@ import {
|
||||||
import { APIClassType, APITemplateType } from "../types/api";
|
import { APIClassType, APITemplateType } from "../types/api";
|
||||||
import { FlowType, NodeType } from "../types/flow";
|
import { FlowType, NodeType } from "../types/flow";
|
||||||
import { TabsContextType, TabsState } from "../types/tabs";
|
import { TabsContextType, TabsState } from "../types/tabs";
|
||||||
import {
|
import { getRandomDescription, getRandomName, updateIds } from "../utils";
|
||||||
getRandomDescription,
|
import { updateTemplate } from "../utils/reactflowUtils";
|
||||||
getRandomName,
|
|
||||||
updateIds,
|
|
||||||
updateTemplate,
|
|
||||||
} from "../utils";
|
|
||||||
import { alertContext } from "./alertContext";
|
import { alertContext } from "./alertContext";
|
||||||
import { typesContext } from "./typesContext";
|
import { typesContext } from "./typesContext";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { Connection, ReactFlowInstance } from "reactflow";
|
import { Connection, ReactFlowInstance } from "reactflow";
|
||||||
|
import { APITemplateType } from "../types/api";
|
||||||
import { FlowType } from "../types/flow";
|
import { FlowType } from "../types/flow";
|
||||||
import { cleanEdgesType } from "../types/utils/reactflowUtils";
|
import { cleanEdgesType } from "../types/utils/reactflowUtils";
|
||||||
|
|
||||||
|
|
@ -100,3 +101,26 @@ export function removeApiKeys(flow: FlowType): FlowType {
|
||||||
});
|
});
|
||||||
return cleanFLow;
|
return cleanFLow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function updateTemplate(
|
||||||
|
reference: APITemplateType,
|
||||||
|
objectToUpdate: APITemplateType
|
||||||
|
): APITemplateType {
|
||||||
|
let clonedObject: APITemplateType = _.cloneDeep(reference);
|
||||||
|
|
||||||
|
// Loop through each key in the reference object
|
||||||
|
for (const key in clonedObject) {
|
||||||
|
// If the key is not in the object to update, add it
|
||||||
|
if (objectToUpdate[key] && objectToUpdate[key].value) {
|
||||||
|
clonedObject[key].value = objectToUpdate[key].value;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
objectToUpdate[key] &&
|
||||||
|
objectToUpdate[key].advanced !== null &&
|
||||||
|
objectToUpdate[key].advanced !== undefined
|
||||||
|
) {
|
||||||
|
clonedObject[key].advanced = objectToUpdate[key].advanced;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return clonedObject;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue