From be1ee757a45dcd9d84dabef3a78d0c53b57de7fe Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 14 Sep 2023 22:31:21 -0300 Subject: [PATCH] fix(parameterComponent): add readonly prop to CodeAreaComponent and PromptAreaComponent based on dynamic property in template fix(GenericNode): remove console.log statement fix(codeAreaComponent): add readonly prop to CodeAreaModal fix(codeTabsComponent): add readonly prop to CodeAreaComponent and PromptAreaComponent fix(promptComponent): add readonly prop to GenericModal fix(EditNodeModal): add readonly prop to CodeAreaComponent fix(codeAreaModal): add readonly prop to AceEditor in CodeAreaModal fix(genericModal): add readonly prop to Textarea in GenericModal fix(reactflowUtils): remove unnecessary code in updateGroupNodeTemplate function --- src/backend/langflow/template/frontend_node/prompts.py | 1 + .../GenericNode/components/parameterComponent/index.tsx | 2 ++ src/frontend/src/CustomNodes/GenericNode/index.tsx | 1 + src/frontend/src/components/codeAreaComponent/index.tsx | 2 ++ src/frontend/src/components/codeTabsComponent/index.tsx | 2 ++ src/frontend/src/components/promptComponent/index.tsx | 4 +++- src/frontend/src/modals/EditNodeModal/index.tsx | 2 ++ src/frontend/src/modals/codeAreaModal/index.tsx | 4 +++- src/frontend/src/modals/genericModal/index.tsx | 7 +++++-- src/frontend/src/types/components/index.ts | 2 ++ src/frontend/src/utils/reactflowUtils.ts | 3 --- 11 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/backend/langflow/template/frontend_node/prompts.py b/src/backend/langflow/template/frontend_node/prompts.py index da5d2a300..c48628a8f 100644 --- a/src/backend/langflow/template/frontend_node/prompts.py +++ b/src/backend/langflow/template/frontend_node/prompts.py @@ -43,6 +43,7 @@ class PromptFrontendNode(FrontendNode): # All prompt fields should be password=False field.password = False + field.dynamic = True class PromptTemplateNode(FrontendNode): diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index f41fa8068..71c3e3ab0 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -299,6 +299,7 @@ export default function ParameterComponent({ ) : left === true && type === "code" ? (
{ data.node = nodeClass; @@ -334,6 +335,7 @@ export default function ParameterComponent({ ) : left === true && type === "prompt" ? (
{ data.node = nodeClass; diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 3efefd9ac..46bb56617 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -74,6 +74,7 @@ export default function GenericNode({ setValidationStatus(null); } }, [sseData, data.id]); + console.log(data.node) return ( <> diff --git a/src/frontend/src/components/codeAreaComponent/index.tsx b/src/frontend/src/components/codeAreaComponent/index.tsx index a402fb3ed..d83383c9d 100644 --- a/src/frontend/src/components/codeAreaComponent/index.tsx +++ b/src/frontend/src/components/codeAreaComponent/index.tsx @@ -12,6 +12,7 @@ export default function CodeAreaComponent({ nodeClass, dynamic, setNodeClass, + readonly=false }: CodeAreaComponentType) { const [myValue, setMyValue] = useState( typeof value == "string" ? value : JSON.stringify(value) @@ -30,6 +31,7 @@ export default function CodeAreaComponent({ return (
{ if (disabled) { @@ -22,7 +23,7 @@ export default function PromptAreaComponent({ }, [disabled]); useEffect(() => { - if (value !== "" && !editNode) { + if (value !== "" && !editNode && !readonly) { postValidatePrompt(field_name!, value, nodeClass!).then((apiReturn) => { if (apiReturn.data) { setNodeClass!(apiReturn.data.frontend_node); @@ -35,6 +36,7 @@ export default function PromptAreaComponent({ return (
-
diff --git a/src/frontend/src/modals/genericModal/index.tsx b/src/frontend/src/modals/genericModal/index.tsx index b29c5acf8..29d9ea3bc 100644 --- a/src/frontend/src/modals/genericModal/index.tsx +++ b/src/frontend/src/modals/genericModal/index.tsx @@ -34,6 +34,7 @@ export default function GenericModal({ nodeClass, setNodeClass, children, + readonly=false, }: genericModalPropsType): JSX.Element { const [myButtonText] = useState(buttonText); const [myModalTitle] = useState(modalTitle); @@ -194,7 +195,7 @@ export default function GenericModal({ "flex h-full w-full" )} > - {type === TypeModal.PROMPT && isEdit ? ( + {type === TypeModal.PROMPT && isEdit && !readonly ? (