Fix: remove id of webhook/email actions on copy (#8729)

This commit is contained in:
shamoon
2025-01-14 05:44:40 -08:00
committed by GitHub
parent 18e3ad8b22
commit ab87aedfc7
4 changed files with 67 additions and 10 deletions

View File

@@ -186,6 +186,57 @@ describe('WorkflowsComponent', () => {
expect(editDialog.dialogMode).toEqual(EditDialogMode.CREATE)
})
it('should null ids on copy', () => {
const workflow = {
id: 1,
name: 'Workflow 1',
order: 1,
enabled: true,
triggers: [
{
id: 1,
type: WorkflowTriggerType.Consumption,
sources: [DocumentSource.ConsumeFolder],
filter_filename: '*',
},
],
actions: [
{
id: 1,
type: WorkflowActionType.Email,
email: {
id: 1,
subject: 'foo',
body: 'bar',
to: 'baz',
include_document: true,
},
},
{
id: 2,
type: WorkflowActionType.Webhook,
webhook: {
id: 2,
url: 'foo',
use_params: false,
params: {},
body: 'bar',
headers: {},
include_document: true,
},
},
],
}
let modal: NgbModalRef
modalService.activeInstances.subscribe((m) => (modal = m[m.length - 1]))
component.copyWorkflow(workflow)
expect(modal).not.toBeUndefined()
const editDialog = modal.componentInstance as WorkflowEditDialogComponent
expect(editDialog.object.id).toBeNull()
expect(editDialog.object.triggers[0].id).toBeNull()
expect(editDialog.object.actions[0].id).toBeNull()
})
it('should support delete, show notification on error / success', () => {
let modal: NgbModalRef
modalService.activeInstances.subscribe((m) => (modal = m[m.length - 1]))

View File

@@ -110,6 +110,12 @@ export class WorkflowsComponent
clone.actions = [
...workflow.actions.map((a) => {
a.id = null
if (a.webhook) {
a.webhook.id = null
}
if (a.email) {
a.email.id = null
}
return a
}),
]