mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-05 20:06:01 +08:00
chore: handle inspect var edit
This commit is contained in:
parent
4c6c50f7d0
commit
831ca8513b
@ -1,6 +1,6 @@
|
||||
import { fetchNodeInspectVars } from '@/service/workflow'
|
||||
import { useWorkflowStore } from '../store'
|
||||
import type { ValueSelector, VarType } from '../types'
|
||||
import type { ValueSelector } from '../types'
|
||||
import {
|
||||
useConversationVarValues,
|
||||
useDeleteAllInspectorVars,
|
||||
@ -18,12 +18,12 @@ const useInspectVarsCrud = () => {
|
||||
appId,
|
||||
nodesWithInspectVars,
|
||||
setNodeInspectVars,
|
||||
getInspectVar,
|
||||
setInspectVarValue,
|
||||
renameInspectVarName: renameInspectVarNameInStore,
|
||||
deleteAllInspectVars: deleteAllInspectVarsInStore,
|
||||
deleteNodeInspectVars: deleteNodeInspectVarsInStore,
|
||||
deleteInspectVar: deleteInspectVarInStore,
|
||||
isInspectVarEdited,
|
||||
getLastRunVar,
|
||||
} = workflowStore.getState()
|
||||
|
||||
@ -90,21 +90,17 @@ const useInspectVarsCrud = () => {
|
||||
renameInspectVarNameInStore(nodeId, varId, selector)
|
||||
}
|
||||
|
||||
const editInspectVarValueType = (varId: string, valueType: VarType) => {
|
||||
console.log('edit var value type', varId, valueType)
|
||||
}
|
||||
|
||||
const isInspectVarEdited = (nodeId: string, key: string) => {
|
||||
return getInspectVar(nodeId, key) !== getLastRunVar(nodeId, key)
|
||||
const editInspectVarValueType = (nodeId: string) => {
|
||||
deleteNodeInspectorVars(nodeId)
|
||||
}
|
||||
|
||||
const resetToLastRunVar = (nodeId: string, key: string) => {
|
||||
const lastRunVar = getLastRunVar(nodeId, key)
|
||||
if (lastRunVar)
|
||||
setInspectVarValue(nodeId, key, lastRunVar)
|
||||
editInspectVarValue(nodeId, key, lastRunVar)
|
||||
}
|
||||
|
||||
console.log(conversationVars, systemVars)
|
||||
// console.log(conversationVars, systemVars)
|
||||
|
||||
return {
|
||||
conversationVars: conversationVars || [],
|
||||
|
@ -23,7 +23,8 @@ type InspectVarsActions = {
|
||||
setInspectVarValue: (nodeId: string, name: string, value: any) => void
|
||||
renameInspectVarName: (nodeId: string, varId: string, selector: ValueSelector) => void
|
||||
deleteInspectVar: (nodeId: string, varId: string) => void
|
||||
getInspectVar: (nodeId: string, name: string) => any // The big value is null
|
||||
getInspectVar: (nodeId: string, name: string) => any
|
||||
isInspectVarEdited: (nodeId: string, name: string) => boolean
|
||||
}
|
||||
|
||||
export type InspectVarsSliceShape = InspectVarsState & InspectVarsActions
|
||||
@ -104,8 +105,10 @@ export const createInspectVarsSlice: StateCreator<InspectVarsSliceShape> = (set,
|
||||
const needChangeVarIndex = draft.vars.findIndex((varItem) => {
|
||||
return varItem.id === varId
|
||||
})
|
||||
if (needChangeVarIndex !== -1)
|
||||
if (needChangeVarIndex !== -1) {
|
||||
draft.vars[needChangeVarIndex].value = value
|
||||
draft.vars[needChangeVarIndex].edited = true
|
||||
}
|
||||
})
|
||||
}
|
||||
return node
|
||||
@ -147,7 +150,7 @@ export const createInspectVarsSlice: StateCreator<InspectVarsSliceShape> = (set,
|
||||
state.nodesWithInspectVars = nodes
|
||||
}))
|
||||
},
|
||||
getInspectVar(nodeId, name) {
|
||||
getInspectVar: (nodeId, name) => {
|
||||
const node = get().getNodeInspectVars(nodeId)
|
||||
if (!node)
|
||||
return undefined
|
||||
@ -157,5 +160,12 @@ export const createInspectVarsSlice: StateCreator<InspectVarsSliceShape> = (set,
|
||||
})?.value
|
||||
return variable
|
||||
},
|
||||
isInspectVarEdited: (nodeId, name) => {
|
||||
const inspectVar = get().getInspectVar(nodeId, name)
|
||||
if (!inspectVar)
|
||||
return false
|
||||
|
||||
return inspectVar.edited
|
||||
},
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user