]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix: remove id of webhook/email actions on copy (#8729)
authorshamoon <4887959+shamoon@users.noreply.github.com>
Tue, 14 Jan 2025 13:44:40 +0000 (05:44 -0800)
committerGitHub <noreply@github.com>
Tue, 14 Jan 2025 13:44:40 +0000 (05:44 -0800)
src-ui/messages.xlf
src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html
src-ui/src/app/components/manage/workflows/workflows.component.spec.ts
src-ui/src/app/components/manage/workflows/workflows.component.ts

index e685ced3d06e22ddaa8ebb4a33b5adb0c9e9c329..ac79752b5202080ff909654be9d16ae70193c7f9 100644 (file)
         </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">
         </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">
         <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">
index 7cbb6b6f27a0d81f6d6574739640caade6f1b67c..5184dcd100f679fa6bee0e21b0f9dad4bc6add9b 100644 (file)
     <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>
index 9f97ab7435940b7a7d3871364310de9b156f06eb..636e03d54b5b7cb4626b57d769542dc45b706de6 100644 (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]))
index 9c1bc1ad4aac1010e91a84db24da488a84caca43..b1f9ff6d0c724e333722269707fca6d97131b772 100644 (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
       }),
     ]