Fixed bug where prompt modal not saving, but there is no Clean Edges now
This commit is contained in:
parent
dbb9b8ab81
commit
62bcfdeaa9
3 changed files with 4 additions and 36 deletions
|
|
@ -17,7 +17,6 @@ import { MAX_LENGTH_TO_SCROLL_TOOLTIP } from "../../../../constants";
|
||||||
import { TabsContext } from "../../../../contexts/tabsContext";
|
import { TabsContext } from "../../../../contexts/tabsContext";
|
||||||
import { typesContext } from "../../../../contexts/typesContext";
|
import { typesContext } from "../../../../contexts/typesContext";
|
||||||
import { ParameterComponentType } from "../../../../types/components";
|
import { ParameterComponentType } from "../../../../types/components";
|
||||||
import { cleanEdges } from "../../../../util/reactflowUtils";
|
|
||||||
import {
|
import {
|
||||||
classNames,
|
classNames,
|
||||||
getRandomKeyByssmm,
|
getRandomKeyByssmm,
|
||||||
|
|
@ -312,15 +311,6 @@ export default function ParameterComponent({
|
||||||
field_name={name}
|
field_name={name}
|
||||||
setNodeClass={(nodeClass) => {
|
setNodeClass={(nodeClass) => {
|
||||||
data.node = nodeClass;
|
data.node = nodeClass;
|
||||||
if (reactFlowInstance) {
|
|
||||||
cleanEdges({
|
|
||||||
flow: {
|
|
||||||
edges: reactFlowInstance.getEdges(),
|
|
||||||
nodes: reactFlowInstance.getNodes(),
|
|
||||||
},
|
|
||||||
updateEdge: (edge) => reactFlowInstance.setEdges(edge),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
nodeClass={data.node}
|
nodeClass={data.node}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { useContext, useEffect, useState } from "react";
|
import { useContext, useEffect } from "react";
|
||||||
import GenericModal from "../../modals/genericModal";
|
import GenericModal from "../../modals/genericModal";
|
||||||
import { TextAreaComponentType } from "../../types/components";
|
import { TextAreaComponentType } from "../../types/components";
|
||||||
|
|
||||||
|
|
@ -15,17 +15,14 @@ export default function PromptAreaComponent({
|
||||||
disabled,
|
disabled,
|
||||||
editNode = false,
|
editNode = false,
|
||||||
}: TextAreaComponentType) {
|
}: TextAreaComponentType) {
|
||||||
const [myValue, setMyValue] = useState(value);
|
|
||||||
const { reactFlowInstance } = useContext(typesContext);
|
const { reactFlowInstance } = useContext(typesContext);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
setMyValue("");
|
|
||||||
onChange("");
|
onChange("");
|
||||||
}
|
}
|
||||||
}, [disabled, onChange]);
|
}, [disabled, onChange]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setMyValue(value);
|
|
||||||
if (value !== "" && !editNode) {
|
if (value !== "" && !editNode) {
|
||||||
postValidatePrompt(field_name, value, nodeClass).then((apiReturn) => {
|
postValidatePrompt(field_name, value, nodeClass).then((apiReturn) => {
|
||||||
if (apiReturn.data) {
|
if (apiReturn.data) {
|
||||||
|
|
@ -36,33 +33,14 @@ export default function PromptAreaComponent({
|
||||||
}
|
}
|
||||||
}, [value, reactFlowInstance]);
|
}, [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 (
|
return (
|
||||||
<div className={disabled ? "pointer-events-none w-full " : " w-full"}>
|
<div className={disabled ? "pointer-events-none w-full " : " w-full"}>
|
||||||
<GenericModal
|
<GenericModal
|
||||||
type={"prompt"}
|
type={"prompt"}
|
||||||
value={myValue}
|
value={value}
|
||||||
buttonText="Check & Save"
|
buttonText="Check & Save"
|
||||||
modalTitle="Edit Prompt"
|
modalTitle="Edit Prompt"
|
||||||
setValue={(t: string) => {
|
setValue={(t: string) => {
|
||||||
setMyValue(t);
|
|
||||||
onChange(t);
|
onChange(t);
|
||||||
}}
|
}}
|
||||||
nodeClass={nodeClass}
|
nodeClass={nodeClass}
|
||||||
|
|
@ -77,7 +55,7 @@ export default function PromptAreaComponent({
|
||||||
" input-primary text-muted-foreground "
|
" input-primary text-muted-foreground "
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{myValue !== "" ? myValue : "Type your prompt here"}
|
{value !== "" ? value : "Type your prompt here"}
|
||||||
</span>
|
</span>
|
||||||
{!editNode && (
|
{!editNode && (
|
||||||
<ExternalLink
|
<ExternalLink
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,6 @@ export default function GenericModal({
|
||||||
postValidatePrompt(field_name, inputValue, nodeClass)
|
postValidatePrompt(field_name, inputValue, nodeClass)
|
||||||
.then((apiReturn) => {
|
.then((apiReturn) => {
|
||||||
if (apiReturn.data) {
|
if (apiReturn.data) {
|
||||||
setNodeClass(apiReturn.data?.frontend_node);
|
|
||||||
let inputVariables = apiReturn.data.input_variables ?? [];
|
let inputVariables = apiReturn.data.input_variables ?? [];
|
||||||
if (inputVariables && inputVariables.length === 0) {
|
if (inputVariables && inputVariables.length === 0) {
|
||||||
setIsEdit(true);
|
setIsEdit(true);
|
||||||
|
|
@ -140,6 +139,7 @@ export default function GenericModal({
|
||||||
setSuccessData({
|
setSuccessData({
|
||||||
title: "Prompt is ready",
|
title: "Prompt is ready",
|
||||||
});
|
});
|
||||||
|
setNodeClass(apiReturn.data?.frontend_node);
|
||||||
setModalOpen(closeModal);
|
setModalOpen(closeModal);
|
||||||
setValue(inputValue);
|
setValue(inputValue);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue