From 4883064e84c23c0e5cd524cfb66f5fd40cd3d9c3 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Sat, 8 Jul 2023 09:12:24 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(alerts/error):=20remove=20un?= =?UTF-8?q?necessary=20line=20break=20in=20ErrorAlert=20component=20?= =?UTF-8?q?=E2=9C=A8=20feat(modals/EditNodeModal):=20add=20ability=20to=20?= =?UTF-8?q?set=20nodeClass=20in=20EditNodeModal=20component=20=F0=9F=90=9B?= =?UTF-8?q?=20fix(modals/genericModal):=20handle=20optional=20chaining=20f?= =?UTF-8?q?or=20error=20response=20data=20in=20GenericModal=20component=20?= =?UTF-8?q?=F0=9F=94=A5=20chore(modals/promptModal):=20remove=20unused=20i?= =?UTF-8?q?mport=20and=20checkPrompt=20function=20in=20PromptAreaModal=20c?= =?UTF-8?q?omponent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/alerts/error/index.tsx | 3 +- .../src/modals/EditNodeModal/index.tsx | 4 +++ .../src/modals/genericModal/index.tsx | 2 +- src/frontend/src/modals/promptModal/index.tsx | 31 ------------------- 4 files changed, 7 insertions(+), 33 deletions(-) diff --git a/src/frontend/src/alerts/error/index.tsx b/src/frontend/src/alerts/error/index.tsx index ed395018e..dd3f4bba7 100644 --- a/src/frontend/src/alerts/error/index.tsx +++ b/src/frontend/src/alerts/error/index.tsx @@ -20,6 +20,7 @@ export default function ErrorAlert({ }, 5000); } }, [id, removeAlert, show]); + return (

{title}

- {list.length !== 0 ? ( + {list?.length !== 0 && list?.some(item => item !== null && item !== undefined) ? (
    {list.map((item, index) => ( diff --git a/src/frontend/src/modals/EditNodeModal/index.tsx b/src/frontend/src/modals/EditNodeModal/index.tsx index 2c2191ed4..130241ad2 100644 --- a/src/frontend/src/modals/EditNodeModal/index.tsx +++ b/src/frontend/src/modals/EditNodeModal/index.tsx @@ -269,6 +269,10 @@ export default function EditNodeModal({ data }: { data: NodeDataType }) { field_name={n} editNode={true} disabled={false} + nodeClass={data.node} + setNodeClass={(nodeClass) => { + data.node = nodeClass; + }} value={data.node.template[n].value ?? ""} onChange={(t: string) => { handleOnNewValue(t, n); diff --git a/src/frontend/src/modals/genericModal/index.tsx b/src/frontend/src/modals/genericModal/index.tsx index ba3fb672f..9eb714c9b 100644 --- a/src/frontend/src/modals/genericModal/index.tsx +++ b/src/frontend/src/modals/genericModal/index.tsx @@ -162,7 +162,7 @@ export default function GenericModal({ setIsEdit(true); return setErrorData({ title: "There is something wrong with this prompt, please review it", - list: [error.response.data.detail], + list: [error?.response?.data?.detail], }); }); } diff --git a/src/frontend/src/modals/promptModal/index.tsx b/src/frontend/src/modals/promptModal/index.tsx index 54fd46528..a1b3aa4ba 100644 --- a/src/frontend/src/modals/promptModal/index.tsx +++ b/src/frontend/src/modals/promptModal/index.tsx @@ -4,7 +4,6 @@ import { Fragment, useContext, useRef, useState } from "react"; import { alertContext } from "../../contexts/alertContext"; import { darkContext } from "../../contexts/darkContext"; import { PopUpContext } from "../../contexts/popUpContext"; -import { checkPrompt } from "../../controllers/API"; export default function PromptAreaModal({ value, setValue, @@ -105,36 +104,6 @@ export default function PromptAreaModal({ type="button" className="node-modal-button" onClick={() => { - checkPrompt(myValue) - .then((apiReturn) => { - if (apiReturn.data) { - let inputVariables = - apiReturn.data.input_variables; - if (inputVariables.length === 0) { - setErrorData({ - title: - "The template you are attempting to use does not contain any variables for data entry.", - }); - } else { - setSuccessData({ - title: "Prompt is ready", - }); - setModalOpen(false); - setValue(myValue); - } - } else { - setErrorData({ - title: "Something went wrong, please try again", - }); - } - }) - .catch((error) => { - return setErrorData({ - title: - "There is something wrong with this prompt, please review it", - list: [error.response.data.detail], - }); - }); }} > Check & Save