diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.spec.ts b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.spec.ts index 5296c7f0ae..b5e455dfc5 100644 --- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.spec.ts +++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.spec.ts @@ -686,6 +686,8 @@ describe('BulkEditorComponent', () => { }) it('should run a workflow on the selection via the run workflow dialog', () => { + const toast = jest.spyOn(toastService, 'show') + const infoToast = jest.spyOn(toastService, 'showInfo') let modal: NgbModalRef modalService.activeInstances.subscribe((m) => (modal = m[0])) jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true) @@ -712,7 +714,12 @@ describe('BulkEditorComponent', () => { workflow: 5, filter_documents: false, }) - req.flush(true) + req.flush({ result: 'OK' }) + expect(infoToast).toHaveBeenCalledWith( + 'Workflow will run on the selected documents in the background.' + ) + expect(toast.mock.calls.at(-1)[0].actionName).toBeUndefined() + expect(documentListViewService.selected.size).toBe(0) httpTestingController.match( `${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true` ) // list reload diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts index 066f941bff..5bea36804a 100644 --- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts +++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -322,10 +322,23 @@ export class BulkEditorComponent modal.componentInstance.confirmClicked .pipe(takeUntil(this.unsubscribeNotifier)) .subscribe(() => { - this.executeBulkEditMethod(modal, 'run_workflow', { - workflow: modal.componentInstance.workflowId, - filter_documents: !modal.componentInstance.force, - }) + modal.componentInstance.buttonsEnabled.set(false) + this.documentService + .bulkEdit(this.getSelectionQuery(), 'run_workflow', { + workflow: modal.componentInstance.workflowId, + filter_documents: !modal.componentInstance.force, + }) + .pipe(first()) + .subscribe({ + next: () => { + modal.close() + this.list.selectNone() + this.toastService.showInfo( + $localize`Workflow will run on the selected documents in the background.` + ) + }, + error: (error) => this.handleOperationError(modal, error), + }) }) }