removing edges after remove handle on prompt
This commit is contained in:
parent
b6aa4d9449
commit
6b17215a7b
3 changed files with 16 additions and 8 deletions
|
|
@ -16,6 +16,7 @@ import { PopUpContext } from "../../../../contexts/popUpContext";
|
||||||
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,
|
||||||
|
|
@ -302,7 +303,13 @@ export default function ParameterComponent({
|
||||||
field_name={name}
|
field_name={name}
|
||||||
setNodeClass={(nodeClass) => {
|
setNodeClass={(nodeClass) => {
|
||||||
data.node = nodeClass;
|
data.node = nodeClass;
|
||||||
// cleanEdges({ flow: { edges: reactFlowInstance.getEdges(), nodes: reactFlowInstance.getNodes() }, updateEdge: (edge) => reactFlowInstance.setEdges(edge) });
|
cleanEdges({
|
||||||
|
flow: {
|
||||||
|
edges: reactFlowInstance.getEdges(),
|
||||||
|
nodes: reactFlowInstance.getNodes(),
|
||||||
|
},
|
||||||
|
updateEdge: (edge) => reactFlowInstance.setEdges(edge),
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
nodeClass={data.node}
|
nodeClass={data.node}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
|
|
||||||
|
|
@ -135,10 +135,9 @@ 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);
|
setNodeClass(apiReturn.data?.frontend_node);
|
||||||
|
let inputVariables = apiReturn.data.input_variables ?? [];
|
||||||
let inputVariables = apiReturn.data.input_variables;
|
if (inputVariables && inputVariables.length === 0) {
|
||||||
if (inputVariables.length === 0) {
|
|
||||||
setIsEdit(true);
|
setIsEdit(true);
|
||||||
setNoticeData({
|
setNoticeData({
|
||||||
title: "Your template does not have any variables.",
|
title: "Your template does not have any variables.",
|
||||||
|
|
@ -159,6 +158,7 @@ export default function GenericModal({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
console.log(error);
|
||||||
setIsEdit(true);
|
setIsEdit(true);
|
||||||
return setErrorData({
|
return setErrorData({
|
||||||
title: "There is something wrong with this prompt, please review it",
|
title: "There is something wrong with this prompt, please review it",
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ export function cleanEdges({
|
||||||
flow: { edges, nodes },
|
flow: { edges, nodes },
|
||||||
updateEdge,
|
updateEdge,
|
||||||
}: cleanEdgesType) {
|
}: cleanEdgesType) {
|
||||||
|
console.log(nodes, "nodes");
|
||||||
let newEdges = _.cloneDeep(edges);
|
let newEdges = _.cloneDeep(edges);
|
||||||
edges.forEach((edge) => {
|
edges.forEach((edge) => {
|
||||||
// check if the source and target node still exists
|
// check if the source and target node still exists
|
||||||
|
|
@ -20,8 +21,8 @@ export function cleanEdges({
|
||||||
if (targetHandle) {
|
if (targetHandle) {
|
||||||
const field = targetHandle.split("|")[1];
|
const field = targetHandle.split("|")[1];
|
||||||
const id =
|
const id =
|
||||||
(targetNode.data.node.template[field].input_types?.join(";") ??
|
(targetNode.data.node.template[field]?.input_types?.join(";") ??
|
||||||
targetNode.data.node.template[field].type) +
|
targetNode.data.node.template[field]?.type) +
|
||||||
"|" +
|
"|" +
|
||||||
field +
|
field +
|
||||||
"|" +
|
"|" +
|
||||||
|
|
@ -42,6 +43,6 @@ export function cleanEdges({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log("cleanEdges", newEdges);
|
console.log("clean end", newEdges);
|
||||||
updateEdge(newEdges);
|
updateEdge(newEdges);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue