mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
fix(workflow): handle else condition branch addition error in if-else node (#10257)
This commit is contained in:
parent
2cd976846a
commit
0858108423
|
@ -78,24 +78,24 @@ const useConfig = (id: string, payload: IfElseNodeType) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleAddCase = useCallback(() => {
|
const handleAddCase = useCallback(() => {
|
||||||
const newInputs = produce(inputs, () => {
|
const newInputs = produce(inputs, (draft) => {
|
||||||
if (inputs.cases) {
|
if (draft.cases) {
|
||||||
const case_id = uuid4()
|
const case_id = uuid4()
|
||||||
inputs.cases.push({
|
draft.cases.push({
|
||||||
case_id,
|
case_id,
|
||||||
logical_operator: LogicalOperator.and,
|
logical_operator: LogicalOperator.and,
|
||||||
conditions: [],
|
conditions: [],
|
||||||
})
|
})
|
||||||
if (inputs._targetBranches) {
|
if (draft._targetBranches) {
|
||||||
const elseCaseIndex = inputs._targetBranches.findIndex(branch => branch.id === 'false')
|
const elseCaseIndex = draft._targetBranches.findIndex(branch => branch.id === 'false')
|
||||||
if (elseCaseIndex > -1) {
|
if (elseCaseIndex > -1) {
|
||||||
inputs._targetBranches = branchNameCorrect([
|
draft._targetBranches = branchNameCorrect([
|
||||||
...inputs._targetBranches.slice(0, elseCaseIndex),
|
...draft._targetBranches.slice(0, elseCaseIndex),
|
||||||
{
|
{
|
||||||
id: case_id,
|
id: case_id,
|
||||||
name: '',
|
name: '',
|
||||||
},
|
},
|
||||||
...inputs._targetBranches.slice(elseCaseIndex),
|
...draft._targetBranches.slice(elseCaseIndex),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user