|
|
|
@ -23,18 +23,15 @@ import { useConfigsMap } from './use-configs-map'
|
|
|
|
|
|
|
|
|
|
|
|
export const useInspectVarsCrud = () => {
|
|
|
|
export const useInspectVarsCrud = () => {
|
|
|
|
const workflowStore = useWorkflowStore()
|
|
|
|
const workflowStore = useWorkflowStore()
|
|
|
|
const nodesWithInspectVars = useStore(s => s.nodesWithInspectVars)
|
|
|
|
const appId = useStore(s => s.appId)
|
|
|
|
const {
|
|
|
|
const setNodeInspectVars = useStore(s => s.setNodeInspectVars)
|
|
|
|
appId,
|
|
|
|
const setInspectVarValue = useStore(s => s.setInspectVarValue)
|
|
|
|
setNodeInspectVars,
|
|
|
|
const renameInspectVarNameInStore = useStore(s => s.renameInspectVarName)
|
|
|
|
setInspectVarValue,
|
|
|
|
const deleteAllInspectVarsInStore = useStore(s => s.deleteAllInspectVars)
|
|
|
|
renameInspectVarName: renameInspectVarNameInStore,
|
|
|
|
const deleteNodeInspectVarsInStore = useStore(s => s.deleteNodeInspectVars)
|
|
|
|
deleteAllInspectVars: deleteAllInspectVarsInStore,
|
|
|
|
const deleteInspectVarInStore = useStore(s => s.deleteInspectVar)
|
|
|
|
deleteNodeInspectVars: deleteNodeInspectVarsInStore,
|
|
|
|
const setNodesWithInspectVars = useStore(s => s.setNodesWithInspectVars)
|
|
|
|
deleteInspectVar: deleteInspectVarInStore,
|
|
|
|
const resetToLastRunVarInStore = useStore(s => s.resetToLastRunVar)
|
|
|
|
setNodesWithInspectVars,
|
|
|
|
|
|
|
|
resetToLastRunVar: resetToLastRunVarInStore,
|
|
|
|
|
|
|
|
} = workflowStore.getState()
|
|
|
|
|
|
|
|
const { conversationVarsUrl, systemVarsUrl } = useConfigsMap()
|
|
|
|
const { conversationVarsUrl, systemVarsUrl } = useConfigsMap()
|
|
|
|
const invalidateConversationVarValues = useInvalidateConversationVarValues(conversationVarsUrl)
|
|
|
|
const invalidateConversationVarValues = useInvalidateConversationVarValues(conversationVarsUrl)
|
|
|
|
const { mutateAsync: doResetConversationVar } = useResetConversationVar(appId)
|
|
|
|
const { mutateAsync: doResetConversationVar } = useResetConversationVar(appId)
|
|
|
|
@ -49,9 +46,10 @@ export const useInspectVarsCrud = () => {
|
|
|
|
const { handleCancelNodeSuccessStatus } = useNodesInteractionsWithoutSync()
|
|
|
|
const { handleCancelNodeSuccessStatus } = useNodesInteractionsWithoutSync()
|
|
|
|
const { handleEdgeCancelRunningStatus } = useEdgesInteractionsWithoutSync()
|
|
|
|
const { handleEdgeCancelRunningStatus } = useEdgesInteractionsWithoutSync()
|
|
|
|
const getNodeInspectVars = useCallback((nodeId: string) => {
|
|
|
|
const getNodeInspectVars = useCallback((nodeId: string) => {
|
|
|
|
|
|
|
|
const { nodesWithInspectVars } = workflowStore.getState()
|
|
|
|
const node = nodesWithInspectVars.find(node => node.nodeId === nodeId)
|
|
|
|
const node = nodesWithInspectVars.find(node => node.nodeId === nodeId)
|
|
|
|
return node
|
|
|
|
return node
|
|
|
|
}, [nodesWithInspectVars])
|
|
|
|
}, [workflowStore])
|
|
|
|
|
|
|
|
|
|
|
|
const getVarId = useCallback((nodeId: string, varName: string) => {
|
|
|
|
const getVarId = useCallback((nodeId: string, varName: string) => {
|
|
|
|
const node = getNodeInspectVars(nodeId)
|
|
|
|
const node = getNodeInspectVars(nodeId)
|
|
|
|
@ -109,6 +107,7 @@ export const useInspectVarsCrud = () => {
|
|
|
|
|
|
|
|
|
|
|
|
// after last run would call this
|
|
|
|
// after last run would call this
|
|
|
|
const appendNodeInspectVars = useCallback((nodeId: string, payload: VarInInspect[], allNodes: Node[]) => {
|
|
|
|
const appendNodeInspectVars = useCallback((nodeId: string, payload: VarInInspect[], allNodes: Node[]) => {
|
|
|
|
|
|
|
|
const { nodesWithInspectVars } = workflowStore.getState()
|
|
|
|
const nodes = produce(nodesWithInspectVars, (draft) => {
|
|
|
|
const nodes = produce(nodesWithInspectVars, (draft) => {
|
|
|
|
const nodeInfo = allNodes.find(node => node.id === nodeId)
|
|
|
|
const nodeInfo = allNodes.find(node => node.id === nodeId)
|
|
|
|
if (nodeInfo) {
|
|
|
|
if (nodeInfo) {
|
|
|
|
@ -129,14 +128,15 @@ export const useInspectVarsCrud = () => {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
setNodesWithInspectVars(nodes)
|
|
|
|
setNodesWithInspectVars(nodes)
|
|
|
|
handleCancelNodeSuccessStatus(nodeId)
|
|
|
|
handleCancelNodeSuccessStatus(nodeId)
|
|
|
|
}, [nodesWithInspectVars, setNodesWithInspectVars, handleCancelNodeSuccessStatus])
|
|
|
|
}, [workflowStore, setNodesWithInspectVars, handleCancelNodeSuccessStatus])
|
|
|
|
|
|
|
|
|
|
|
|
const hasNodeInspectVar = useCallback((nodeId: string, varId: string) => {
|
|
|
|
const hasNodeInspectVar = useCallback((nodeId: string, varId: string) => {
|
|
|
|
|
|
|
|
const { nodesWithInspectVars } = workflowStore.getState()
|
|
|
|
const targetNode = nodesWithInspectVars.find(item => item.nodeId === nodeId)
|
|
|
|
const targetNode = nodesWithInspectVars.find(item => item.nodeId === nodeId)
|
|
|
|
if(!targetNode || !targetNode.vars)
|
|
|
|
if(!targetNode || !targetNode.vars)
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
return targetNode.vars.some(item => item.id === varId)
|
|
|
|
return targetNode.vars.some(item => item.id === varId)
|
|
|
|
}, [nodesWithInspectVars])
|
|
|
|
}, [workflowStore])
|
|
|
|
|
|
|
|
|
|
|
|
const deleteInspectVar = useCallback(async (nodeId: string, varId: string) => {
|
|
|
|
const deleteInspectVar = useCallback(async (nodeId: string, varId: string) => {
|
|
|
|
if(hasNodeInspectVar(nodeId, varId)) {
|
|
|
|
if(hasNodeInspectVar(nodeId, varId)) {
|
|
|
|
|