From 1e52b69997ef000926f42a678ce73095cd18cae3 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 29 Jan 2026 09:31:52 -0800 Subject: [PATCH] Handle on frontend --- .../workflow-edit-dialog.component.html | 2 +- .../workflow-edit-dialog.component.spec.ts | 29 +++++++++++++++++++ .../workflow-edit-dialog.component.ts | 21 +++++++++++++- src-ui/src/app/data/workflow-action.ts | 2 +- 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html index 0ac0a9eba..7f086ec63 100644 --- a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html +++ b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html @@ -434,7 +434,7 @@

- One or more passwords separated by commas or new lines. The workflow will try them in order until one succeeds. + One password per line. The workflow will try them in order until one succeeds.

{ component.removeSelectedCustomField(3, formGroup) expect(formGroup.get('assign_custom_fields').value).toEqual([]) }) + + it('should handle parsing of passwords from array to string and back on save', () => { + const passwordAction: WorkflowAction = { + id: 1, + type: WorkflowActionType.PasswordRemoval, + passwords: ['pass1', 'pass2'], + } + component.object = { + name: 'Workflow with Passwords', + id: 1, + order: 1, + enabled: true, + triggers: [], + actions: [passwordAction], + } + component.ngOnInit() + + const formActions = component.objectForm.get('actions') as FormArray + expect(formActions.value[0].passwords).toBe('pass1\npass2') + formActions.at(0).get('passwords').setValue('pass1\npass2\npass3') + component.save() + + expect(component.objectForm.get('actions').value[0].passwords).toEqual([ + 'pass1', + 'pass2', + 'pass3', + ]) + }) }) diff --git a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts index bbe9e8af0..cde5b552c 100644 --- a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts +++ b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts @@ -1206,12 +1206,25 @@ export class WorkflowEditDialogComponent headers: new FormControl(action.webhook?.headers), include_document: new FormControl(!!action.webhook?.include_document), }), - passwords: new FormControl(action.passwords), + passwords: new FormControl( + this.formatPasswords(action.passwords ?? []) + ), }), { emitEvent } ) } + private formatPasswords(passwords: string[] = []): string { + return passwords.join('\n') + } + + private parsePasswords(value: string = ''): string[] { + return value + .split(/[\n,]+/) + .map((entry) => entry.trim()) + .filter((entry) => entry.length > 0) + } + private updateAllTriggerActionFields(emitEvent: boolean = false) { this.triggerFields.clear({ emitEvent: false }) this.object?.triggers.forEach((trigger) => { @@ -1336,6 +1349,7 @@ export class WorkflowEditDialogComponent headers: null, include_document: false, }, + passwords: [], } this.object.actions.push(action) this.createActionField(action) @@ -1372,6 +1386,11 @@ export class WorkflowEditDialogComponent if (action.type !== WorkflowActionType.Email) { action.email = null } + if (action.type === WorkflowActionType.PasswordRemoval) { + action.passwords = this.parsePasswords(action.passwords as any) + } else { + delete action.passwords + } }) super.save() } diff --git a/src-ui/src/app/data/workflow-action.ts b/src-ui/src/app/data/workflow-action.ts index fcbb7454b..ff1509693 100644 --- a/src-ui/src/app/data/workflow-action.ts +++ b/src-ui/src/app/data/workflow-action.ts @@ -99,5 +99,5 @@ export interface WorkflowAction extends ObjectWithId { webhook?: WorkflowActionWebhook - passwords?: string + passwords?: string[] }