From 2f623bad7b8f43541a02c8aa20b33b20cf77138d Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 7 Nov 2026 08:20:54 -0800 Subject: [PATCH] Add back the queued notificaiton + link --- .../bulk-editor/bulk-editor.component.spec.ts | 61 ++++++++++++------- .../bulk-editor/bulk-editor.component.ts | 25 +++++++- 2 files changed, 62 insertions(+), 24 deletions(-) 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 909a7b820f..34540ac687 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 @@ -1546,27 +1546,46 @@ describe('BulkEditorComponent', () => { ) }) - it('closes a queued permissions dialog without refreshing before completion', () => { - let modal: NgbModalRef - modalService.activeInstances.subscribe((instances) => { - if (instances.length) modal = instances[0] - }) - const reload = jest.spyOn(documentListViewService, 'reload') - component.setPermissions() - const close = jest.spyOn(modal, 'close') - modal.componentInstance.confirmClicked.emit({ - permissions: {}, - merge: true, - }) - const req = httpTestingController.expectOne( - `${environment.apiBaseUrl}documents/bulk_edit/` - ) - req.flush({ result: 'OK', task_id: 'queued-operation' }) - expect(close).toHaveBeenCalledTimes(1) - expect(reload).not.toHaveBeenCalled() - expect(documentListViewService.selected.size).toBe(0) - expect(documentListViewService.allSelected).toBe(false) - }) + it.each([true, false])( + 'shows queued feedback and gates the task link on permission (%s)', + (canViewTasks) => { + jest + .spyOn(permissionsService, 'currentUserCan') + .mockReturnValue(canViewTasks) + const queued = jest.spyOn(toastService, 'show') + let modal: NgbModalRef + modalService.activeInstances.subscribe((instances) => { + if (instances.length) modal = instances[0] + }) + const reload = jest.spyOn(documentListViewService, 'reload') + component.setPermissions() + const close = jest.spyOn(modal, 'close') + modal.componentInstance.confirmClicked.emit({ + permissions: {}, + merge: true, + }) + const req = httpTestingController.expectOne( + `${environment.apiBaseUrl}documents/bulk_edit/` + ) + req.flush({ result: 'OK', task_id: 'queued-operation' }) + expect(close).toHaveBeenCalledTimes(1) + const notification = queued.mock.calls.at(-1)[0] + expect(notification.content).toBe('Bulk operation queued.') + if (canViewTasks) { + expect(notification.actionName).toBe('View task') + notification.action() + expect(router.navigate).toHaveBeenCalledWith(['/tasks'], { + queryParams: { task_id: 'queued-operation' }, + }) + } else { + expect(notification.action).toBeUndefined() + expect(notification.actionName).toBeUndefined() + } + expect(reload).not.toHaveBeenCalled() + expect(documentListViewService.selected.size).toBe(0) + expect(documentListViewService.allSelected).toBe(false) + } + ) it('should support bulk permissions update', () => { let modal: NgbModalRef 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 647946768c..94f742366d 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 @@ -299,14 +299,31 @@ export class BulkEditorComponent .bulkEdit(overrideSelection ?? this.getSelectionQuery(), method, args) .pipe(first()) .subscribe({ - next: () => this.handleOperationQueued(modal), + next: ({ task_id }) => this.handleOperationQueued(modal, task_id), error: (error) => this.handleOperationError(modal, error), }) } - private handleOperationQueued(modal: NgbModalRef) { + private handleOperationQueued(modal: NgbModalRef, taskId: string) { modal?.close() this.list.selectNone() + const canViewTasks = this.permissionService.currentUserCan( + PermissionAction.View, + PermissionType.PaperlessTask + ) + this.toastService.show({ + content: $localize`Bulk operation queued.`, + delay: 5000, + ...(canViewTasks + ? { + actionName: $localize`View task`, + action: () => + this.router.navigate(['/tasks'], { + queryParams: { task_id: taskId }, + }), + } + : {}), + }) } private executeDocumentAction( @@ -1093,7 +1110,9 @@ export class BulkEditorComponent dialog.selection = this.getSelectionQuery() dialog.selectionCount = this.getSelectionSize() - dialog.succeeded.subscribe(() => this.handleOperationQueued(null)) + dialog.succeeded.subscribe(({ task_id }) => + this.handleOperationQueued(null, task_id) + ) dialog.failed.subscribe((error) => { this.toastService.showError( $localize`Error updating custom fields.`,