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

View File

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