feat: var assigner var inspect change

pull/21369/head
Joel 1 year ago
parent fea02b74b7
commit 40d2a410d1

@ -66,7 +66,7 @@ const useInspectVarsCrud = () => {
} }
const deleteNodeInspectorVars = async (nodeId: string) => { const deleteNodeInspectorVars = async (nodeId: string) => {
// console.log('delete node inspector vars', nodeId) console.log('delete node inspector vars', nodeId)
if (hasNodeInspectVars(nodeId)) if (hasNodeInspectVars(nodeId))
await doDeleteNodeInspectorVars(nodeId) await doDeleteNodeInspectorVars(nodeId)
@ -103,6 +103,7 @@ const useInspectVarsCrud = () => {
}, [data, currNodeId, currEditVarId, getNodeInspectVars, editInspectVarValue]) }, [data, currNodeId, currEditVarId, getNodeInspectVars, editInspectVarValue])
const renameInspectVarName = async (nodeId: string, oldName: string, newName: string) => { const renameInspectVarName = async (nodeId: string, oldName: string, newName: string) => {
console.log('rename:', nodeId, oldName, newName)
const varId = getVarId(nodeId, oldName) const varId = getVarId(nodeId, oldName)
if (!varId) if (!varId)
return return

@ -12,8 +12,13 @@ import {
useNodesReadOnly, useNodesReadOnly,
useWorkflow, useWorkflow,
} from '@/app/components/workflow/hooks' } from '@/app/components/workflow/hooks'
import useInspectVarsCrud from '../../hooks/use-inspect-vars-crud'
const useConfig = (id: string, payload: VariableAssignerNodeType) => { const useConfig = (id: string, payload: VariableAssignerNodeType) => {
const {
deleteNodeInspectorVars,
renameInspectVarName,
} = useInspectVarsCrud()
const { nodesReadOnly: readOnly } = useNodesReadOnly() const { nodesReadOnly: readOnly } = useNodesReadOnly()
const { handleOutVarRenameChange, isVarUsedInNodes, removeUsedVarInNodes } = useWorkflow() const { handleOutVarRenameChange, isVarUsedInNodes, removeUsedVarInNodes } = useWorkflow()
@ -113,7 +118,8 @@ const useConfig = (id: string, payload: VariableAssignerNodeType) => {
draft.advanced_settings.group_enabled = enabled draft.advanced_settings.group_enabled = enabled
}) })
setInputs(newInputs) setInputs(newInputs)
}, [handleOutVarRenameChange, id, inputs, isVarUsedInNodes, setInputs, showRemoveVarConfirm]) deleteNodeInspectorVars(id)
}, [deleteNodeInspectorVars, handleOutVarRenameChange, id, inputs, isVarUsedInNodes, setInputs, showRemoveVarConfirm])
const handleAddGroup = useCallback(() => { const handleAddGroup = useCallback(() => {
let maxInGroupName = 1 let maxInGroupName = 1
@ -134,7 +140,8 @@ const useConfig = (id: string, payload: VariableAssignerNodeType) => {
}) })
}) })
setInputs(newInputs) setInputs(newInputs)
}, [inputs, setInputs]) deleteNodeInspectorVars(id)
}, [deleteNodeInspectorVars, id, inputs, setInputs])
const handleVarGroupNameChange = useCallback((groupId: string) => { const handleVarGroupNameChange = useCallback((groupId: string) => {
return (name: string) => { return (name: string) => {
@ -144,8 +151,9 @@ const useConfig = (id: string, payload: VariableAssignerNodeType) => {
}) })
handleOutVarRenameChange(id, [id, inputs.advanced_settings.groups[index].group_name, 'output'], [id, name, 'output']) handleOutVarRenameChange(id, [id, inputs.advanced_settings.groups[index].group_name, 'output'], [id, name, 'output'])
setInputs(newInputs) setInputs(newInputs)
renameInspectVarName(id, inputs.advanced_settings.groups[index].group_name, name)
} }
}, [handleOutVarRenameChange, id, inputs, setInputs]) }, [handleOutVarRenameChange, id, inputs, renameInspectVarName, setInputs])
const onRemoveVarConfirm = useCallback(() => { const onRemoveVarConfirm = useCallback(() => {
removedVars.forEach((v) => { removedVars.forEach((v) => {

Loading…
Cancel
Save