From 62bcfdeaa9cc63bac38650020226309f3c79935d Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Wed, 19 Jul 2023 11:03:44 -0300 Subject: [PATCH] Fixed bug where prompt modal not saving, but there is no Clean Edges now --- .../components/parameterComponent/index.tsx | 10 ------- .../src/components/promptComponent/index.tsx | 28 ++----------------- .../src/modals/genericModal/index.tsx | 2 +- 3 files changed, 4 insertions(+), 36 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index 88d9e41da..85bf26683 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -17,7 +17,6 @@ import { MAX_LENGTH_TO_SCROLL_TOOLTIP } from "../../../../constants"; import { TabsContext } from "../../../../contexts/tabsContext"; import { typesContext } from "../../../../contexts/typesContext"; import { ParameterComponentType } from "../../../../types/components"; -import { cleanEdges } from "../../../../util/reactflowUtils"; import { classNames, getRandomKeyByssmm, @@ -312,15 +311,6 @@ export default function ParameterComponent({ field_name={name} setNodeClass={(nodeClass) => { data.node = nodeClass; - if (reactFlowInstance) { - cleanEdges({ - flow: { - edges: reactFlowInstance.getEdges(), - nodes: reactFlowInstance.getNodes(), - }, - updateEdge: (edge) => reactFlowInstance.setEdges(edge), - }); - } }} nodeClass={data.node} disabled={disabled} diff --git a/src/frontend/src/components/promptComponent/index.tsx b/src/frontend/src/components/promptComponent/index.tsx index 3d24af0f7..dbf2c7251 100644 --- a/src/frontend/src/components/promptComponent/index.tsx +++ b/src/frontend/src/components/promptComponent/index.tsx @@ -1,4 +1,4 @@ -import { useContext, useEffect, useState } from "react"; +import { useContext, useEffect } from "react"; import GenericModal from "../../modals/genericModal"; import { TextAreaComponentType } from "../../types/components"; @@ -15,17 +15,14 @@ export default function PromptAreaComponent({ disabled, editNode = false, }: TextAreaComponentType) { - const [myValue, setMyValue] = useState(value); const { reactFlowInstance } = useContext(typesContext); useEffect(() => { if (disabled) { - setMyValue(""); onChange(""); } }, [disabled, onChange]); useEffect(() => { - setMyValue(value); if (value !== "" && !editNode) { postValidatePrompt(field_name, value, nodeClass).then((apiReturn) => { if (apiReturn.data) { @@ -36,33 +33,14 @@ export default function PromptAreaComponent({ } }, [value, reactFlowInstance]); - // useEffect(() => { - // if (value !== "" && myValue !== value && reactFlowInstance) { - // // only executed once - // setMyValue(value); - // postValidatePrompt(field_name, value, nodeClass) - // .then((apiReturn) => { - // if (apiReturn.data) { - // setNodeClass(apiReturn.data.frontend_node); - // // need to update reactFlowInstance to re-render the nodes. - // reactFlowInstance.setEdges( - // _.cloneDeep(reactFlowInstance.getEdges()) - // ); - // } - // }) - // .catch((error) => {}); - // } - // }, [reactFlowInstance, field_name, myValue, nodeClass, setNodeClass, value]); - return (
{ - setMyValue(t); onChange(t); }} nodeClass={nodeClass} @@ -77,7 +55,7 @@ export default function PromptAreaComponent({ " input-primary text-muted-foreground " } > - {myValue !== "" ? myValue : "Type your prompt here"} + {value !== "" ? value : "Type your prompt here"} {!editNode && ( { if (apiReturn.data) { - setNodeClass(apiReturn.data?.frontend_node); let inputVariables = apiReturn.data.input_variables ?? []; if (inputVariables && inputVariables.length === 0) { setIsEdit(true); @@ -140,6 +139,7 @@ export default function GenericModal({ setSuccessData({ title: "Prompt is ready", }); + setNodeClass(apiReturn.data?.frontend_node); setModalOpen(closeModal); setValue(inputValue); }