|
|
|
@ -10,6 +10,7 @@ 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: StartNodeType) => {
|
|
|
|
const useConfig = (id: string, payload: StartNodeType) => {
|
|
|
|
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
|
|
|
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
|
|
|
@ -18,6 +19,11 @@ const useConfig = (id: string, payload: StartNodeType) => {
|
|
|
|
|
|
|
|
|
|
|
|
const { inputs, setInputs } = useNodeCrud<StartNodeType>(id, payload)
|
|
|
|
const { inputs, setInputs } = useNodeCrud<StartNodeType>(id, payload)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
|
|
|
deleteNodeInspectorVars,
|
|
|
|
|
|
|
|
renameInspectVarName,
|
|
|
|
|
|
|
|
} = useInspectVarsCrud()
|
|
|
|
|
|
|
|
|
|
|
|
const [isShowAddVarModal, {
|
|
|
|
const [isShowAddVarModal, {
|
|
|
|
setTrue: showAddVarModal,
|
|
|
|
setTrue: showAddVarModal,
|
|
|
|
setFalse: hideAddVarModal,
|
|
|
|
setFalse: hideAddVarModal,
|
|
|
|
@ -46,8 +52,12 @@ const useConfig = (id: string, payload: StartNodeType) => {
|
|
|
|
if (moreInfo?.payload?.type === ChangeType.changeVarName) {
|
|
|
|
if (moreInfo?.payload?.type === ChangeType.changeVarName) {
|
|
|
|
const changedVar = newList[moreInfo.index]
|
|
|
|
const changedVar = newList[moreInfo.index]
|
|
|
|
handleOutVarRenameChange(id, [id, inputs.variables[moreInfo.index].variable], [id, changedVar.variable])
|
|
|
|
handleOutVarRenameChange(id, [id, inputs.variables[moreInfo.index].variable], [id, changedVar.variable])
|
|
|
|
|
|
|
|
renameInspectVarName(id, inputs.variables[moreInfo.index].variable, changedVar.variable)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else { // edit var type
|
|
|
|
|
|
|
|
deleteNodeInspectorVars(id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [handleOutVarRenameChange, id, inputs, isVarUsedInNodes, setInputs, showRemoveVarConfirm])
|
|
|
|
}, [deleteNodeInspectorVars, handleOutVarRenameChange, id, inputs, isVarUsedInNodes, renameInspectVarName, setInputs, showRemoveVarConfirm])
|
|
|
|
|
|
|
|
|
|
|
|
const removeVarInNode = useCallback(() => {
|
|
|
|
const removeVarInNode = useCallback(() => {
|
|
|
|
const newInputs = produce(inputs, (draft) => {
|
|
|
|
const newInputs = produce(inputs, (draft) => {
|
|
|
|
@ -63,7 +73,8 @@ const useConfig = (id: string, payload: StartNodeType) => {
|
|
|
|
draft.variables.push(payload)
|
|
|
|
draft.variables.push(payload)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
setInputs(newInputs)
|
|
|
|
setInputs(newInputs)
|
|
|
|
}, [inputs, setInputs])
|
|
|
|
deleteNodeInspectorVars(id)
|
|
|
|
|
|
|
|
}, [deleteNodeInspectorVars, id, inputs, setInputs])
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
readOnly,
|
|
|
|
readOnly,
|
|
|
|
isChatMode,
|
|
|
|
isChatMode,
|
|
|
|
|