mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-12 00:19:48 +00:00
Fix: remove id of webhook/email actions on copy (#8729)
This commit is contained in:
@@ -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]))
|
||||
|
@@ -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
|
||||
}),
|
||||
]
|
||||
|
Reference in New Issue
Block a user