Skip to content

fix(workflow): handle else condition branch addition error in if-else node #10257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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