Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

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

shamoonab87aedfc75c
diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf
index e685ced3d..ac79752b5 100644
--- a/src-ui/messages.xlf
+++ b/src-ui/messages.xlf
@@ -2214,7 +2214,7 @@
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
- <context context-type="linenumber">131</context>
+ <context context-type="linenumber">137</context>
</context-group>
</trans-unit>
<trans-unit id="1980187861066369604" datatype="html">
@@ -2553,7 +2553,7 @@
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
- <context context-type="linenumber">133</context>
+ <context context-type="linenumber">139</context>
</context-group>
</trans-unit>
<trans-unit id="857903183180440990" datatype="html">
@@ -8611,49 +8611,49 @@
<source>Confirm delete workflow</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
- <context context-type="linenumber">129</context>
+ <context context-type="linenumber">135</context>
</context-group>
</trans-unit>
<trans-unit id="6874008462443189248" datatype="html">
<source>This operation will permanently delete this workflow.</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
- <context context-type="linenumber">130</context>
+ <context context-type="linenumber">136</context>
</context-group>
</trans-unit>
<trans-unit id="1848226135059921165" datatype="html">
<source>Deleted workflow</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
- <context context-type="linenumber">139</context>
+ <context context-type="linenumber">145</context>
</context-group>
</trans-unit>
<trans-unit id="3177411222429626224" datatype="html">
<source>Error deleting workflow.</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
- <context context-type="linenumber">144</context>
+ <context context-type="linenumber">150</context>
</context-group>
</trans-unit>
<trans-unit id="5459159218551862653" datatype="html">
<source>Enabled workflow</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
- <context context-type="linenumber">155</context>
+ <context context-type="linenumber">161</context>
</context-group>
</trans-unit>
<trans-unit id="6035681056091592756" datatype="html">
<source>Disabled workflow</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
- <context context-type="linenumber">156</context>
+ <context context-type="linenumber">162</context>
</context-group>
</trans-unit>
<trans-unit id="1376040678213338380" datatype="html">
<source>Error toggling workflow.</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
- <context context-type="linenumber">162</context>
+ <context context-type="linenumber">168</context>
</context-group>
</trans-unit>
<trans-unit id="2649252321173430744" datatype="html">
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 7cbb6b6f2..5184dcd10 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
@@ -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>
diff --git a/src-ui/src/app/components/manage/workflows/workflows.component.spec.ts b/src-ui/src/app/components/manage/workflows/workflows.component.spec.ts
index 9f97ab743..636e03d54 100644
--- a/src-ui/src/app/components/manage/workflows/workflows.component.spec.ts
+++ b/src-ui/src/app/components/manage/workflows/workflows.component.spec.ts
@@ -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]))
diff --git a/src-ui/src/app/components/manage/workflows/workflows.component.ts b/src-ui/src/app/components/manage/workflows/workflows.component.ts
index 9c1bc1ad4..b1f9ff6d0 100644
--- a/src-ui/src/app/components/manage/workflows/workflows.component.ts
+++ b/src-ui/src/app/components/manage/workflows/workflows.component.ts
@@ -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
}),
]