From ade66f42285c8a89d941538918a19e0ed6f256d4 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 5 Sep 2026 16:26:55 -0700 Subject: [PATCH] Fix the bulk editor to be a link to bundles --- .../bulk-editor/bulk-editor.component.spec.ts | 33 ++++++++++--------- .../bulk-editor/bulk-editor.component.ts | 8 ++--- 2 files changed, 21 insertions(+), 20 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 b8696a958..74a8c54f4 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 @@ -7,6 +7,7 @@ import { import { EventEmitter, signal } from '@angular/core' import { ComponentFixture, TestBed } from '@angular/core/testing' import { By } from '@angular/platform-browser' +import { Router } from '@angular/router' import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons' import { of, throwError } from 'rxjs' @@ -46,7 +47,6 @@ import { StoragePathEditDialogComponent } from '../../common/edit-dialog/storage import { TagEditDialogComponent } from '../../common/edit-dialog/tag-edit-dialog/tag-edit-dialog.component' import { FilterableDropdownComponent } from '../../common/filterable-dropdown/filterable-dropdown.component' import { ShareLinkBundleDialogComponent } from '../../common/share-link-bundle-dialog/share-link-bundle-dialog.component' -import { ShareLinkBundleManageDialogComponent } from '../../common/share-link-bundle-manage-dialog/share-link-bundle-manage-dialog.component' import { BulkEditorComponent } from './bulk-editor.component' const selectionData: SelectionData = { @@ -82,6 +82,7 @@ describe('BulkEditorComponent', () => { let customFieldsService: CustomFieldsService let httpTestingController: HttpTestingController let shareLinkBundleService: ShareLinkBundleService + let router: Router beforeEach(async () => { TestBed.configureTestingModule({ @@ -172,6 +173,10 @@ describe('BulkEditorComponent', () => { delete: jest.fn(), }, }, + { + provide: Router, + useValue: { navigate: jest.fn().mockResolvedValue(true) }, + }, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting(), ], @@ -189,6 +194,7 @@ describe('BulkEditorComponent', () => { customFieldsService = TestBed.inject(CustomFieldsService) httpTestingController = TestBed.inject(HttpTestingController) shareLinkBundleService = TestBed.inject(ShareLinkBundleService) + router = TestBed.inject(Router) fixture = TestBed.createComponent(BulkEditorComponent) component = fixture.componentInstance @@ -1824,9 +1830,9 @@ describe('BulkEditorComponent', () => { }, } - const openSpy = jest.spyOn(modalService, 'open') - openSpy.mockReturnValueOnce(modalRef as NgbModalRef) - openSpy.mockReturnValueOnce({} as NgbModalRef) + const openSpy = jest + .spyOn(modalService, 'open') + .mockReturnValueOnce(modalRef as NgbModalRef) ;(shareLinkBundleService.createBundle as jest.Mock).mockReturnValueOnce( of({ id: 42 }) ) @@ -1860,11 +1866,9 @@ describe('BulkEditorComponent', () => { dialogInstance.onOpenManage() expect(modalRef.close).toHaveBeenCalled() - expect(openSpy).toHaveBeenNthCalledWith( - 2, - ShareLinkBundleManageDialogComponent, - expect.objectContaining({ backdrop: 'static', size: 'lg' }) - ) + expect(router.navigate).toHaveBeenCalledWith(['/share-links'], { + queryParams: { type: 'bundles' }, + }) openSpy.mockRestore() }) @@ -1917,13 +1921,10 @@ describe('BulkEditorComponent', () => { openSpy.mockRestore() }) - it('should open share link bundle management dialog', () => { - const openSpy = jest.spyOn(modalService, 'open') + it('should navigate to share link bundle management', () => { component.manageShareLinkBundles() - expect(openSpy).toHaveBeenCalledWith( - ShareLinkBundleManageDialogComponent, - expect.objectContaining({ backdrop: 'static', size: 'lg' }) - ) - openSpy.mockRestore() + expect(router.navigate).toHaveBeenCalledWith(['/share-links'], { + queryParams: { type: 'bundles' }, + }) }) }) 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 fb7c20776..c8d23c1bb 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 @@ -12,6 +12,7 @@ import { FormsModule, ReactiveFormsModule, } from '@angular/forms' +import { Router } from '@angular/router' import { NgbDropdownModule, NgbModal, @@ -69,7 +70,6 @@ import { import { ToggleableItemState } from '../../common/filterable-dropdown/toggleable-dropdown-button/toggleable-dropdown-button.component' import { PermissionsDialogComponent } from '../../common/permissions-dialog/permissions-dialog.component' import { ShareLinkBundleDialogComponent } from '../../common/share-link-bundle-dialog/share-link-bundle-dialog.component' -import { ShareLinkBundleManageDialogComponent } from '../../common/share-link-bundle-manage-dialog/share-link-bundle-manage-dialog.component' import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component' import { CustomFieldsBulkEditDialogComponent } from './custom-fields-bulk-edit-dialog/custom-fields-bulk-edit-dialog.component' @@ -104,6 +104,7 @@ export class BulkEditorComponent public readonly permissionService = inject(PermissionsService) private savedViewService = inject(SavedViewService) private readonly shareLinkBundleService = inject(ShareLinkBundleService) + private readonly router = inject(Router) tagSelectionModel = new FilterableDropdownSelectionModel(true) correspondentSelectionModel = new FilterableDropdownSelectionModel() @@ -1135,9 +1136,8 @@ export class BulkEditorComponent } manageShareLinkBundles() { - this.modalService.open(ShareLinkBundleManageDialogComponent, { - backdrop: 'static', - size: 'lg', + void this.router.navigate(['/share-links'], { + queryParams: { type: 'bundles' }, }) }