mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Fix: remove id of webhook/email actions on copy (#8729)
This commit is contained in:
@@ -180,7 +180,7 @@
|
||||
<input type="hidden" formControlName="id" />
|
||||
<pngx-input-select i18n-title title="Action type" [horizontal]="true" [items]="actionTypeOptions" formControlName="type"></pngx-input-select>
|
||||
@switch(formGroup.get('type').value) {
|
||||
@case ( WorkflowActionType.Assignment) {
|
||||
@case (WorkflowActionType.Assignment) {
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<pngx-input-text i18n-title title="Assign title" formControlName="assign_title" i18n-hint hint="Can include some placeholders, see <a target='_blank' href='https://docs.paperless-ngx.com/usage/#workflows'>documentation</a>." [error]="error?.actions?.[i]?.assign_title"></pngx-input-text>
|
||||
|
@@ -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