From bc0cd4a6c2ae84e67aafbfaaf18f8bc4923fafef Mon Sep 17 00:00:00 2001 From: Jens Vannerum Date: Mon, 16 Dec 2024 10:42:21 +0100 Subject: [PATCH] 121787: fix remaining browse issues --- package-lock.json | 6 ------ package.json | 1 - .../browse-by/browse-by-date/browse-by-date.component.ts | 6 ++++-- .../browse-by-metadata/browse-by-metadata.component.ts | 5 ++++- .../browse-by/browse-by-page/browse-by-page.component.ts | 4 ++-- .../browse-by-switcher.component.spec.ts | 2 +- .../browse-by-switcher/browse-by-switcher.component.ts | 4 ++-- .../browse-by-title/browse-by-title.component.ts | 6 ++++-- src/app/menu-resolver.service.ts | 7 ++++--- src/app/menu.resolver.spec.ts | 9 ++++++--- 10 files changed, 27 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index d80fa228032..79455f7256c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,7 +63,6 @@ "mirador-dl-plugin": "^0.13.0", "mirador-share-plugin": "^0.16.0", "morgan": "^1.10.0", - "ng": "^0.0.0", "ng2-file-upload": "5.0.0", "ng2-nouislider": "^2.0.0", "ngx-infinite-scroll": "^16.0.0", @@ -16843,11 +16842,6 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, - "node_modules/ng": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/ng/-/ng-0.0.0.tgz", - "integrity": "sha512-HwR40IBJa1ZU+CIGyuy7vSCN3xFYlSRfw5eIwwKOdOMNNNIl8KhT6PXKmHuFEFYpfrbOMaCYtr4QOJ3gkkubcg==" - }, "node_modules/ng-mocks": { "version": "14.13.1", "resolved": "https://registry.npmjs.org/ng-mocks/-/ng-mocks-14.13.1.tgz", diff --git a/package.json b/package.json index f3dc96e2da0..206b025da36 100644 --- a/package.json +++ b/package.json @@ -150,7 +150,6 @@ "mirador-dl-plugin": "^0.13.0", "mirador-share-plugin": "^0.16.0", "morgan": "^1.10.0", - "ng": "^0.0.0", "ng2-file-upload": "5.0.0", "ng2-nouislider": "^2.0.0", "ngx-infinite-scroll": "^16.0.0", diff --git a/src/app/browse-by/browse-by-date/browse-by-date.component.ts b/src/app/browse-by/browse-by-date/browse-by-date.component.ts index 5f825add8ca..11818ff5f15 100644 --- a/src/app/browse-by/browse-by-date/browse-by-date.component.ts +++ b/src/app/browse-by/browse-by-date/browse-by-date.component.ts @@ -18,7 +18,10 @@ import { combineLatest as observableCombineLatest, Observable, } from 'rxjs'; -import { map, tap, take } from 'rxjs/operators'; +import { + map, + take, +} from 'rxjs/operators'; import { ThemedBrowseByComponent } from 'src/app/shared/browse-by/themed-browse-by.component'; import { @@ -53,7 +56,6 @@ import { VarDirective } from '../../shared/utils/var.directive'; import { BrowseByMetadataComponent, browseParamsToOptions, - getBrowseSearchOptions, } from '../browse-by-metadata/browse-by-metadata.component'; @Component({ diff --git a/src/app/browse-by/browse-by-metadata/browse-by-metadata.component.ts b/src/app/browse-by/browse-by-metadata/browse-by-metadata.component.ts index 48416d68948..d17c2a1a7b4 100644 --- a/src/app/browse-by/browse-by-metadata/browse-by-metadata.component.ts +++ b/src/app/browse-by/browse-by-metadata/browse-by-metadata.component.ts @@ -23,7 +23,10 @@ import { of as observableOf, Subscription, } from 'rxjs'; -import { map, take, tap } from 'rxjs/operators'; +import { + map, + take, +} from 'rxjs/operators'; import { ThemedBrowseByComponent } from 'src/app/shared/browse-by/themed-browse-by.component'; import { diff --git a/src/app/browse-by/browse-by-page/browse-by-page.component.ts b/src/app/browse-by/browse-by-page/browse-by-page.component.ts index 1a204264d15..670b5a7711c 100644 --- a/src/app/browse-by/browse-by-page/browse-by-page.component.ts +++ b/src/app/browse-by/browse-by-page/browse-by-page.component.ts @@ -23,7 +23,7 @@ import { BrowseBySwitcherComponent } from '../browse-by-switcher/browse-by-switc }) export class BrowseByPageComponent implements OnInit { - browseByType$: Observable; + browseByType$: Observable<{type: BrowseByDataType }>; constructor( protected route: ActivatedRoute, @@ -35,7 +35,7 @@ export class BrowseByPageComponent implements OnInit { */ ngOnInit(): void { this.browseByType$ = this.route.data.pipe( - map((data: { browseDefinition: BrowseDefinition }) => data.browseDefinition.getRenderType()), + map((data: { browseDefinition: BrowseDefinition }) => ({ type: data.browseDefinition.getRenderType() })), ); } diff --git a/src/app/browse-by/browse-by-switcher/browse-by-switcher.component.spec.ts b/src/app/browse-by/browse-by-switcher/browse-by-switcher.component.spec.ts index d56671577ed..8539365f668 100644 --- a/src/app/browse-by/browse-by-switcher/browse-by-switcher.component.spec.ts +++ b/src/app/browse-by/browse-by-switcher/browse-by-switcher.component.spec.ts @@ -85,7 +85,7 @@ describe('BrowseBySwitcherComponent', () => { types.forEach((type: NonHierarchicalBrowseDefinition) => { describe(`when switching to a browse-by page for "${type.id}"`, () => { beforeEach(async () => { - comp.browseByType = type.dataType; + comp.browseByType = type as any; comp.ngOnChanges({ browseByType: new SimpleChange(undefined, type.dataType, true), }); diff --git a/src/app/browse-by/browse-by-switcher/browse-by-switcher.component.ts b/src/app/browse-by/browse-by-switcher/browse-by-switcher.component.ts index c1e3dae79f0..53be5fa786d 100644 --- a/src/app/browse-by/browse-by-switcher/browse-by-switcher.component.ts +++ b/src/app/browse-by/browse-by-switcher/browse-by-switcher.component.ts @@ -24,7 +24,7 @@ export class BrowseBySwitcherComponent extends AbstractComponentLoaderComponent< @Input() context: Context; - @Input() browseByType: BrowseByDataType; + @Input() browseByType: { type: BrowseByDataType }; @Input() displayTitle: boolean; @@ -43,7 +43,7 @@ export class BrowseBySwitcherComponent extends AbstractComponentLoaderComponent< ]; public getComponent(): GenericConstructor { - return getComponentByBrowseByType(this.browseByType, this.context, this.themeService.getThemeName()); + return getComponentByBrowseByType(this.browseByType.type, this.context, this.themeService.getThemeName()); } } diff --git a/src/app/browse-by/browse-by-title/browse-by-title.component.ts b/src/app/browse-by/browse-by-title/browse-by-title.component.ts index 9ccc74f7cff..296386d9d94 100644 --- a/src/app/browse-by/browse-by-title/browse-by-title.component.ts +++ b/src/app/browse-by/browse-by-title/browse-by-title.component.ts @@ -9,7 +9,10 @@ import { import { Params } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; import { combineLatest as observableCombineLatest } from 'rxjs'; -import { map, take, distinctUntilChanged, tap } from 'rxjs/operators'; +import { + map, + take, +} from 'rxjs/operators'; import { SortDirection, @@ -28,7 +31,6 @@ import { VarDirective } from '../../shared/utils/var.directive'; import { BrowseByMetadataComponent, browseParamsToOptions, - getBrowseSearchOptions, } from '../browse-by-metadata/browse-by-metadata.component'; @Component({ diff --git a/src/app/menu-resolver.service.ts b/src/app/menu-resolver.service.ts index 9a0b8f5989f..683111b32ad 100644 --- a/src/app/menu-resolver.service.ts +++ b/src/app/menu-resolver.service.ts @@ -7,8 +7,9 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { combineLatest, combineLatest as observableCombineLatest, + mergeMap, Observable, - of as observableOf, mergeMap, + of as observableOf, } from 'rxjs'; import { filter, @@ -18,6 +19,7 @@ import { } from 'rxjs/operators'; import { PUBLICATION_CLAIMS_PATH } from './admin/admin-notifications/admin-notifications-routing-paths'; +import { AuthService } from './core/auth/auth.service'; import { BrowseService } from './core/browse/browse.service'; import { ConfigurationDataService } from './core/data/configuration-data.service'; import { AuthorizationDataService } from './core/data/feature-authorization/authorization-data.service'; @@ -48,7 +50,6 @@ import { OnClickMenuItemModel } from './shared/menu/menu-item/models/onclick.mod import { TextMenuItemModel } from './shared/menu/menu-item/models/text.model'; import { MenuItemType } from './shared/menu/menu-item-type.model'; import { MenuState } from './shared/menu/menu-state.model'; -import { AuthService } from './core/auth/auth.service'; /** * Creates all of the app's menus @@ -155,7 +156,7 @@ export class MenuResolverService { */ createAdminMenuIfLoggedIn$() { return this.authService.isAuthenticated().pipe( - mergeMap((isAuthenticated) => isAuthenticated ? this.createAdminMenu$() : observableOf(true)) + mergeMap((isAuthenticated) => isAuthenticated ? this.createAdminMenu$() : observableOf(true)), ); } diff --git a/src/app/menu.resolver.spec.ts b/src/app/menu.resolver.spec.ts index 386bbb0cae4..720c0711044 100644 --- a/src/app/menu.resolver.spec.ts +++ b/src/app/menu.resolver.spec.ts @@ -26,7 +26,9 @@ import { ConfigurationDataServiceStub } from './shared/testing/configuration-dat import { MenuServiceStub } from './shared/testing/menu-service.stub'; import { createPaginatedList } from './shared/testing/utils.test'; import createSpy = jasmine.createSpy; +import { AuthService } from './core/auth/auth.service'; import { MenuResolverService } from './menu-resolver.service'; +import { AuthServiceStub } from './shared/testing/auth-service.stub'; const BOOLEAN = { t: true, f: false }; const MENU_STATE = { @@ -80,6 +82,7 @@ describe('menuResolver', () => { { provide: ScriptDataService, useValue: scriptService }, { provide: ConfigurationDataService, useValue: configurationDataService }, { provide: NgbModal, useValue: mockNgbModal }, + { provide: AuthService, useValue: AuthServiceStub }, MenuResolverService, ], schemas: [NO_ERRORS_SCHEMA], @@ -94,19 +97,19 @@ describe('menuResolver', () => { describe('resolve', () => { it('should create all menus', (done) => { spyOn(resolver, 'createPublicMenu$').and.returnValue(observableOf(true)); - spyOn(resolver, 'createAdminMenu$').and.returnValue(observableOf(true)); + spyOn(resolver, 'createAdminMenuIfLoggedIn$').and.returnValue(observableOf(true)); resolver.resolve(null, null).subscribe(resolved => { expect(resolved).toBeTrue(); expect(resolver.createPublicMenu$).toHaveBeenCalled(); - expect(resolver.createAdminMenu$).toHaveBeenCalled(); + expect(resolver.createAdminMenuIfLoggedIn$).toHaveBeenCalled(); done(); }); }); it('should return an Observable that emits true as soon as all menus are created', () => { spyOn(resolver, 'createPublicMenu$').and.returnValue(cold('--(t|)', BOOLEAN)); - spyOn(resolver, 'createAdminMenu$').and.returnValue(cold('----(t|)', BOOLEAN)); + spyOn(resolver, 'createAdminMenuIfLoggedIn$').and.returnValue(cold('----(t|)', BOOLEAN)); expect(resolver.resolve(null, null)).toBeObservable(cold('----(t|)', BOOLEAN)); });