feat: delete node delete vars

This commit is contained in:
Joel 2025-04-28 16:26:46 +08:00
parent 99221010bd
commit cc85e53ffc
2 changed files with 12 additions and 5 deletions

View File

@ -21,10 +21,10 @@ const useInspectVarsCrud = () => {
setInspectVarValue,
renameInspectVarName: renameInspectVarNameInStore,
deleteAllInspectVars: deleteAllInspectVarsInStore,
hasNodeInspectVars,
deleteNodeInspectVars: deleteNodeInspectVarsInStore,
deleteInspectVar: deleteInspectVarInStore,
isInspectVarEdited,
getLastRunVar,
} = workflowStore.getState()
const { data: conversationVars } = useConversationVarValues(appId)
@ -61,7 +61,9 @@ const useInspectVarsCrud = () => {
}
const deleteNodeInspectorVars = async (nodeId: string) => {
await doDeleteNodeInspectorVars(nodeId)
if (hasNodeInspectVars(nodeId))
await doDeleteNodeInspectorVars(nodeId)
deleteNodeInspectVarsInStore(nodeId)
}
@ -95,9 +97,10 @@ const useInspectVarsCrud = () => {
}
const resetToLastRunVar = (nodeId: string, key: string) => {
const lastRunVar = getLastRunVar(nodeId, key)
if (lastRunVar)
editInspectVarValue(nodeId, key, lastRunVar)
// const lastRunVar = getLastRunVar(nodeId, key)
// if (lastRunVar)
// editInspectVarValue(nodeId, key, lastRunVar)
// TODO
}
// console.log(conversationVars, systemVars)

View File

@ -60,6 +60,7 @@ import {
useWorkflowReadOnly,
} from './use-workflow'
import { WorkflowHistoryEvent, useWorkflowHistory } from './use-workflow-history'
import useInspectVarsCrud from './use-inspect-vars-crud'
export const useNodesInteractions = () => {
const { t } = useTranslation()
@ -530,6 +531,8 @@ export const useNodesInteractions = () => {
setEnteringNodePayload(undefined)
}, [store, handleNodeConnect, getNodesReadOnly, workflowStore, reactflow])
const { deleteNodeInspectorVars } = useInspectVarsCrud()
const handleNodeDelete = useCallback((nodeId: string) => {
if (getNodesReadOnly())
return
@ -551,6 +554,7 @@ export const useNodesInteractions = () => {
if (currentNode.data.type === BlockEnum.Start)
return
deleteNodeInspectorVars(nodeId)
if (currentNode.data.type === BlockEnum.Iteration) {
const iterationChildren = nodes.filter(node => node.parentId === currentNode.id)