mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-04 03:27:12 -05:00 
			
		
		
		
	Fix: remove id of webhook/email actions on copy (#8729)
This commit is contained in:
		
							parent
							
								
									18e3ad8b22
								
							
						
					
					
						commit
						ab87aedfc7
					
				@ -2214,7 +2214,7 @@
 | 
				
			|||||||
        </context-group>
 | 
					        </context-group>
 | 
				
			||||||
        <context-group purpose="location">
 | 
					        <context-group purpose="location">
 | 
				
			||||||
          <context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
 | 
					          <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>
 | 
					        </context-group>
 | 
				
			||||||
      </trans-unit>
 | 
					      </trans-unit>
 | 
				
			||||||
      <trans-unit id="1980187861066369604" datatype="html">
 | 
					      <trans-unit id="1980187861066369604" datatype="html">
 | 
				
			||||||
@ -2553,7 +2553,7 @@
 | 
				
			|||||||
        </context-group>
 | 
					        </context-group>
 | 
				
			||||||
        <context-group purpose="location">
 | 
					        <context-group purpose="location">
 | 
				
			||||||
          <context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
 | 
					          <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>
 | 
					        </context-group>
 | 
				
			||||||
      </trans-unit>
 | 
					      </trans-unit>
 | 
				
			||||||
      <trans-unit id="857903183180440990" datatype="html">
 | 
					      <trans-unit id="857903183180440990" datatype="html">
 | 
				
			||||||
@ -8611,49 +8611,49 @@
 | 
				
			|||||||
        <source>Confirm delete workflow</source>
 | 
					        <source>Confirm delete workflow</source>
 | 
				
			||||||
        <context-group purpose="location">
 | 
					        <context-group purpose="location">
 | 
				
			||||||
          <context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
 | 
					          <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>
 | 
					        </context-group>
 | 
				
			||||||
      </trans-unit>
 | 
					      </trans-unit>
 | 
				
			||||||
      <trans-unit id="6874008462443189248" datatype="html">
 | 
					      <trans-unit id="6874008462443189248" datatype="html">
 | 
				
			||||||
        <source>This operation will permanently delete this workflow.</source>
 | 
					        <source>This operation will permanently delete this workflow.</source>
 | 
				
			||||||
        <context-group purpose="location">
 | 
					        <context-group purpose="location">
 | 
				
			||||||
          <context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
 | 
					          <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>
 | 
					        </context-group>
 | 
				
			||||||
      </trans-unit>
 | 
					      </trans-unit>
 | 
				
			||||||
      <trans-unit id="1848226135059921165" datatype="html">
 | 
					      <trans-unit id="1848226135059921165" datatype="html">
 | 
				
			||||||
        <source>Deleted workflow</source>
 | 
					        <source>Deleted workflow</source>
 | 
				
			||||||
        <context-group purpose="location">
 | 
					        <context-group purpose="location">
 | 
				
			||||||
          <context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
 | 
					          <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>
 | 
					        </context-group>
 | 
				
			||||||
      </trans-unit>
 | 
					      </trans-unit>
 | 
				
			||||||
      <trans-unit id="3177411222429626224" datatype="html">
 | 
					      <trans-unit id="3177411222429626224" datatype="html">
 | 
				
			||||||
        <source>Error deleting workflow.</source>
 | 
					        <source>Error deleting workflow.</source>
 | 
				
			||||||
        <context-group purpose="location">
 | 
					        <context-group purpose="location">
 | 
				
			||||||
          <context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
 | 
					          <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>
 | 
					        </context-group>
 | 
				
			||||||
      </trans-unit>
 | 
					      </trans-unit>
 | 
				
			||||||
      <trans-unit id="5459159218551862653" datatype="html">
 | 
					      <trans-unit id="5459159218551862653" datatype="html">
 | 
				
			||||||
        <source>Enabled workflow</source>
 | 
					        <source>Enabled workflow</source>
 | 
				
			||||||
        <context-group purpose="location">
 | 
					        <context-group purpose="location">
 | 
				
			||||||
          <context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
 | 
					          <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>
 | 
					        </context-group>
 | 
				
			||||||
      </trans-unit>
 | 
					      </trans-unit>
 | 
				
			||||||
      <trans-unit id="6035681056091592756" datatype="html">
 | 
					      <trans-unit id="6035681056091592756" datatype="html">
 | 
				
			||||||
        <source>Disabled workflow</source>
 | 
					        <source>Disabled workflow</source>
 | 
				
			||||||
        <context-group purpose="location">
 | 
					        <context-group purpose="location">
 | 
				
			||||||
          <context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
 | 
					          <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>
 | 
					        </context-group>
 | 
				
			||||||
      </trans-unit>
 | 
					      </trans-unit>
 | 
				
			||||||
      <trans-unit id="1376040678213338380" datatype="html">
 | 
					      <trans-unit id="1376040678213338380" datatype="html">
 | 
				
			||||||
        <source>Error toggling workflow.</source>
 | 
					        <source>Error toggling workflow.</source>
 | 
				
			||||||
        <context-group purpose="location">
 | 
					        <context-group purpose="location">
 | 
				
			||||||
          <context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
 | 
					          <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>
 | 
					        </context-group>
 | 
				
			||||||
      </trans-unit>
 | 
					      </trans-unit>
 | 
				
			||||||
      <trans-unit id="2649252321173430744" datatype="html">
 | 
					      <trans-unit id="2649252321173430744" datatype="html">
 | 
				
			||||||
 | 
				
			|||||||
@ -180,7 +180,7 @@
 | 
				
			|||||||
    <input type="hidden" formControlName="id" />
 | 
					    <input type="hidden" formControlName="id" />
 | 
				
			||||||
    <pngx-input-select i18n-title title="Action type" [horizontal]="true" [items]="actionTypeOptions" formControlName="type"></pngx-input-select>
 | 
					    <pngx-input-select i18n-title title="Action type" [horizontal]="true" [items]="actionTypeOptions" formControlName="type"></pngx-input-select>
 | 
				
			||||||
    @switch(formGroup.get('type').value) {
 | 
					    @switch(formGroup.get('type').value) {
 | 
				
			||||||
      @case ( WorkflowActionType.Assignment) {
 | 
					      @case (WorkflowActionType.Assignment) {
 | 
				
			||||||
        <div class="row">
 | 
					        <div class="row">
 | 
				
			||||||
          <div class="col">
 | 
					          <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>
 | 
					            <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)
 | 
					    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', () => {
 | 
					  it('should support delete, show notification on error / success', () => {
 | 
				
			||||||
    let modal: NgbModalRef
 | 
					    let modal: NgbModalRef
 | 
				
			||||||
    modalService.activeInstances.subscribe((m) => (modal = m[m.length - 1]))
 | 
					    modalService.activeInstances.subscribe((m) => (modal = m[m.length - 1]))
 | 
				
			||||||
 | 
				
			|||||||
@ -110,6 +110,12 @@ export class WorkflowsComponent
 | 
				
			|||||||
    clone.actions = [
 | 
					    clone.actions = [
 | 
				
			||||||
      ...workflow.actions.map((a) => {
 | 
					      ...workflow.actions.map((a) => {
 | 
				
			||||||
        a.id = null
 | 
					        a.id = null
 | 
				
			||||||
 | 
					        if (a.webhook) {
 | 
				
			||||||
 | 
					          a.webhook.id = null
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (a.email) {
 | 
				
			||||||
 | 
					          a.email.id = null
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        return a
 | 
					        return a
 | 
				
			||||||
      }),
 | 
					      }),
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user