mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-15 13:56:53 +08:00
Feature/newnew workflow loop node (#14863)
Co-authored-by: arkunzz <4873204@qq.com>
This commit is contained in:
@@ -35,7 +35,7 @@ export enum ComparisonOperator {
|
||||
notExists = 'not exists',
|
||||
}
|
||||
|
||||
export interface Condition {
|
||||
export type Condition = {
|
||||
id: string
|
||||
varType: VarType
|
||||
variable_selector?: ValueSelector
|
||||
@@ -46,7 +46,7 @@ export interface Condition {
|
||||
sub_variable_condition?: CaseItem
|
||||
}
|
||||
|
||||
export interface CaseItem {
|
||||
export type CaseItem = {
|
||||
case_id: string
|
||||
logical_operator: LogicalOperator
|
||||
conditions: Condition[]
|
||||
@@ -57,6 +57,7 @@ export type IfElseNodeType = CommonNodeType & {
|
||||
conditions?: Condition[]
|
||||
cases: CaseItem[]
|
||||
isInIteration: boolean
|
||||
isInLoop: boolean
|
||||
}
|
||||
|
||||
export type HandleAddCondition = (caseId: string, valueSelector: ValueSelector, varItem: Var) => void
|
||||
|
||||
@@ -57,6 +57,7 @@ const useConfig = (id: string, payload: IfElseNodeType) => {
|
||||
} = useIsVarFileAttribute({
|
||||
nodeId: id,
|
||||
isInIteration: payload.isInIteration,
|
||||
isInLoop: payload.isInLoop,
|
||||
})
|
||||
|
||||
const varsIsVarFileAttribute = useMemo(() => {
|
||||
|
||||
@@ -7,10 +7,12 @@ import { VarType } from '../../types'
|
||||
type Params = {
|
||||
nodeId: string
|
||||
isInIteration: boolean
|
||||
isInLoop: boolean
|
||||
}
|
||||
const useIsVarFileAttribute = ({
|
||||
nodeId,
|
||||
isInIteration,
|
||||
isInLoop,
|
||||
}: Params) => {
|
||||
const isChatMode = useIsChatMode()
|
||||
const store = useStoreApi()
|
||||
@@ -20,6 +22,7 @@ const useIsVarFileAttribute = ({
|
||||
} = store.getState()
|
||||
const currentNode = getNodes().find(n => n.id === nodeId)
|
||||
const iterationNode = isInIteration ? getNodes().find(n => n.id === currentNode!.parentId) : null
|
||||
const loopNode = isInLoop ? getNodes().find(n => n.id === currentNode!.parentId) : null
|
||||
const availableNodes = useMemo(() => {
|
||||
return getBeforeNodesInSameBranch(nodeId)
|
||||
}, [getBeforeNodesInSameBranch, nodeId])
|
||||
@@ -29,7 +32,7 @@ const useIsVarFileAttribute = ({
|
||||
return false
|
||||
const parentVariable = variable.slice(0, 2)
|
||||
const varType = getCurrentVariableType({
|
||||
parentNode: iterationNode,
|
||||
parentNode: isInIteration ? iterationNode : loopNode,
|
||||
valueSelector: parentVariable,
|
||||
availableNodes,
|
||||
isChatMode,
|
||||
|
||||
Reference in New Issue
Block a user