diff --git a/src/frontend/src/pages/FlowPage/index.tsx b/src/frontend/src/pages/FlowPage/index.tsx
index 4fc315926..eef70bf5b 100644
--- a/src/frontend/src/pages/FlowPage/index.tsx
+++ b/src/frontend/src/pages/FlowPage/index.tsx
@@ -32,7 +32,7 @@ var _ = require("lodash");
export default function FlowPage({ flow }:{flow:FlowType}) {
let { updateFlow, incrementNodeId} =
useContext(TabsContext);
- const { types, reactFlowInstance, setReactFlowInstance } =
+ const { types, reactFlowInstance, setReactFlowInstance, templates } =
useContext(typesContext);
const reactFlowWrapper = useRef(null);
@@ -180,7 +180,7 @@ export default function FlowPage({ flow }:{flow:FlowType}) {
return (
- {Object.keys(types).length > 0 ? (
+ {Object.keys(templates).length > 0 && Object.keys(types).length > 0 ? (
<>
void;
hardReset:()=>void;
-};
\ No newline at end of file
+};
+
+export type LangFlowState={ tabIndex:number, flows:FlowType[], id:number, nodeId:number }
\ No newline at end of file
diff --git a/src/frontend/src/types/templatesContext/index.ts b/src/frontend/src/types/templatesContext/index.ts
new file mode 100644
index 000000000..88e2dd07c
--- /dev/null
+++ b/src/frontend/src/types/templatesContext/index.ts
@@ -0,0 +1,7 @@
+
+const template:{[char: string]: string}={}
+
+export type TemplateContextType = {
+ templates: typeof template;
+ setTemplates: (newState: {}) => void;
+};
\ No newline at end of file
diff --git a/src/frontend/src/types/typesContext/index.ts b/src/frontend/src/types/typesContext/index.ts
index e943dafe3..59d22f365 100644
--- a/src/frontend/src/types/typesContext/index.ts
+++ b/src/frontend/src/types/typesContext/index.ts
@@ -1,6 +1,9 @@
import { ReactFlowInstance } from "reactflow";
-const types:{[char: string]: string}={}
+const types:{[char: string]: string}={};
+const template:{[char: string]: string}={}
+const data:{[char: string]: string}={}
+
export type typesContextType = {
reactFlowInstance: ReactFlowInstance|null;
@@ -8,4 +11,8 @@ export type typesContextType = {
deleteNode: (idx: string) => void;
types: typeof types;
setTypes: (newState: {}) => void;
+ templates: typeof template;
+ setTemplates: (newState: {}) => void;
+ data: typeof data;
+ setData: (newState: {}) => void;
};
\ No newline at end of file
diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts
index 405d56297..874bbd18e 100644
--- a/src/frontend/src/utils.ts
+++ b/src/frontend/src/utils.ts
@@ -387,4 +387,23 @@ export function removeApiKeys(flow:FlowType):FlowType{
}
})
return cleanFLow
+}
+
+export function updateObject>(reference: T, objectToUpdate: T): T {
+ let clonedObject = _.cloneDeep(objectToUpdate)
+ // Loop through each key in the object to update
+ for (const key in clonedObject) {
+ // If the key is not in the reference object, delete it
+ if (!(key in reference)) {
+ delete clonedObject[key];
+ }
+ }
+ // Loop through each key in the reference object
+ for (const key in reference) {
+ // If the key is not in the object to update, add it
+ if (!(key in clonedObject)) {
+ clonedObject[key] = reference[key];
+ }
+ }
+ return clonedObject;
}
\ No newline at end of file