Skip to content

Commit

Permalink
fix(workflow): handle else condition branch addition error in if-else…
Browse files Browse the repository at this point in the history
… node (#10257)
  • Loading branch information
GeorgeCaoJ authored and Nov1c444 committed Nov 5, 2024
1 parent a0f2b6c commit e666004
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions web/app/components/workflow/nodes/if-else/use-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,24 @@ const useConfig = (id: string, payload: IfElseNodeType) => {
})

const handleAddCase = useCallback(() => {
const newInputs = produce(inputs, () => {
if (inputs.cases) {
const newInputs = produce(inputs, (draft) => {
if (draft.cases) {
const case_id = uuid4()
inputs.cases.push({
draft.cases.push({
case_id,
logical_operator: LogicalOperator.and,
conditions: [],
})
if (inputs._targetBranches) {
const elseCaseIndex = inputs._targetBranches.findIndex(branch => branch.id === 'false')
if (draft._targetBranches) {
const elseCaseIndex = draft._targetBranches.findIndex(branch => branch.id === 'false')
if (elseCaseIndex > -1) {
inputs._targetBranches = branchNameCorrect([
...inputs._targetBranches.slice(0, elseCaseIndex),
draft._targetBranches = branchNameCorrect([
...draft._targetBranches.slice(0, elseCaseIndex),
{
id: case_id,
name: '',
},
...inputs._targetBranches.slice(elseCaseIndex),
...draft._targetBranches.slice(elseCaseIndex),
])
}
}
Expand Down

0 comments on commit e666004

Please sign in to comment.