This commit is contained in:
Cristhian Zanforlin Lousa 2023-09-27 23:51:29 -03:00
commit 3f964ea60b
4 changed files with 28 additions and 24 deletions

View file

@ -529,7 +529,7 @@ export const URL_EXCLUDED_FROM_ERROR_RETRIES = [
"http://localhost:7860/login",
];
export const skipNodeUpdate = ["CustomComponent"];
export const skipNodeUpdate = ["CustomComponent", "PromptTemplate"];
export const CONTROL_INPUT_STATE = {
password: "",

View file

@ -33,6 +33,7 @@ export default function GenericModal({
}: genericModalPropsType): JSX.Element {
const [myButtonText] = useState(buttonText);
const [myModalTitle] = useState(modalTitle);
const [modalOpen, setModalOpen] = useState(false);
const [myModalType] = useState(type);
const [inputValue, setInputValue] = useState(value);
const [isEdit, setIsEdit] = useState(true);
@ -85,7 +86,7 @@ export default function GenericModal({
useEffect(() => {
setInputValue(value);
}, [value]);
}, [value, modalOpen]);
const coloredContent = (inputValue || "")
.replace(/</g, "&lt;")
@ -109,11 +110,6 @@ export default function GenericModal({
postValidatePrompt(field_name, inputValue, nodeClass!)
.then((apiReturn) => {
if (apiReturn.data) {
setValue(inputValue);
apiReturn.data.frontend_node["template"]["template"]["value"] =
inputValue;
setNodeClass!(apiReturn?.data?.frontend_node);
let inputVariables = apiReturn.data.input_variables ?? [];
if (inputVariables && inputVariables.length === 0) {
setIsEdit(true);
@ -121,6 +117,15 @@ export default function GenericModal({
title: "Your template does not have any variables.",
});
setModalOpen(false);
if (
JSON.stringify(apiReturn.data?.frontend_node) !==
JSON.stringify({})
)
setNodeClass!(apiReturn.data?.frontend_node);
setModalOpen(closeModal);
setValue(inputValue);
apiReturn.data.frontend_node["template"]["template"]["value"] =
inputValue;
} else {
setIsEdit(false);
setSuccessData({
@ -133,6 +138,8 @@ export default function GenericModal({
setNodeClass!(apiReturn.data?.frontend_node);
setModalOpen(closeModal);
setValue(inputValue);
apiReturn.data.frontend_node["template"]["template"]["value"] =
inputValue;
}
} else {
setIsEdit(true);
@ -142,16 +149,15 @@ export default function GenericModal({
}
})
.catch((error) => {
console.log(error);
setIsEdit(true);
return setErrorData({
title: "There is something wrong with this prompt, please review it",
list: [error?.response?.data?.detail],
list: [error.toString()],
});
});
}
const [modalOpen, setModalOpen] = useState(false);
return (
<BaseModal
onChangeOpenModal={(open) => {}}

View file

@ -114,13 +114,11 @@ export default function Page({
}
}
if (!isWrappedWithClass(event, "nodelete")) {
console.log(event);
if (
(event.key === "Delete" || event.key === "Backspace") &&
lastSelection
) {
event.preventDefault();
console.log(lastSelection);
deleteNode(lastSelection.nodes.map((node) => node.id));
}
}

View file

@ -135,18 +135,18 @@ export type TooltipComponentType = {
children: ReactElement;
title: string | ReactElement;
placement?:
| "bottom-end"
| "bottom-start"
| "bottom"
| "left-end"
| "left-start"
| "left"
| "right-end"
| "right-start"
| "right"
| "top-end"
| "top-start"
| "top";
| "bottom-end"
| "bottom-start"
| "bottom"
| "left-end"
| "left-start"
| "left"
| "right-end"
| "right-start"
| "right"
| "top-end"
| "top-start"
| "top";
};
export type ProgressBarType = {