From 0acd8bcb1ea8cbb3f3db4bdeec929b53141eb789 Mon Sep 17 00:00:00 2001
From: Alex <25013571+alexhb1@users.noreply.github.com>
Date: Thu, 30 Jul 2026 20:47:24 +0100
Subject: [PATCH] refactor(ui): switch library and shelf menu to app-menu
(#2057)
---
.../book-browser/book-browser.component.html | 27 +-
.../book-browser.component.spec.ts | 9 -
.../book-browser/book-browser.component.ts | 33 +-
.../library-shelf-menu.component.spec.ts | 82 +++
.../library-shelf-menu.component.ts | 157 +++++
.../library-shelf-menu.service.spec.ts | 248 +++-----
.../service/library-shelf-menu.service.ts | 543 +++++++-----------
.../app.sidebar-item-row.component.html | 45 +-
.../app.sidebar-item-row.component.spec.ts | 97 +---
.../app.sidebar-item-row.component.ts | 30 +-
.../layout-sidebar/app.sidebar.component.html | 32 +-
.../layout-sidebar/app.sidebar.component.scss | 4 -
.../app.sidebar.component.spec.ts | 9 -
.../layout-sidebar/app.sidebar.component.ts | 59 +-
.../layout-sidebar/sidebar-sections.spec.ts | 28 +-
.../layout/layout-sidebar/sidebar-sections.ts | 23 +-
.../layout/navigation/nav-catalog.spec.ts | 19 -
.../shared/layout/navigation/nav-catalog.ts | 15 -
.../layout/navigation/nav-item.model.ts | 4 +-
.../src/app/shared/ui/menu/menu.styles.ts | 2 +-
frontend/src/assets/styles/compat.scss | 9 -
frontend/src/i18n/en/book.json | 1 +
22 files changed, 631 insertions(+), 845 deletions(-)
create mode 100644 frontend/src/app/features/book/components/library-shelf-menu/library-shelf-menu.component.spec.ts
create mode 100644 frontend/src/app/features/book/components/library-shelf-menu/library-shelf-menu.component.ts
diff --git a/frontend/src/app/features/book/components/book-browser/book-browser.component.html b/frontend/src/app/features/book/components/book-browser/book-browser.component.html
index e3b8de086..f9e1ffec9 100644
--- a/frontend/src/app/features/book/components/book-browser/book-browser.component.html
+++ b/frontend/src/app/features/book/components/book-browser/book-browser.component.html
@@ -28,19 +28,24 @@
}
- @if (userService.currentUser(); as currentUser) {
- @if (entityType !== EntityType.ALL_BOOKS && entityType !== EntityType.UNSHELVED &&
- (currentUser.permissions.admin || currentUser.permissions.canManageLibrary)) {
-
- }
+ [attr.aria-label]="'common.moreActionsFor' | transloco: {label: menuTarget.entity.name}"
+ [appMenuTriggerFor]="entityMenu.menu()">
+
+
+ }
+
}
}
diff --git a/frontend/src/app/features/book/components/book-browser/book-browser.component.spec.ts b/frontend/src/app/features/book/components/book-browser/book-browser.component.spec.ts
index b342982d5..0d3823e4b 100644
--- a/frontend/src/app/features/book/components/book-browser/book-browser.component.spec.ts
+++ b/frontend/src/app/features/book/components/book-browser/book-browser.component.spec.ts
@@ -8,7 +8,6 @@ import {ConfirmationService, MessageService} from '@openng/optimus-ui/api';
import {PageTitleService} from '../../../../shared/service/page-title.service';
import {BookService} from '../../service/book.service';
import {BookMetadataManageService} from '../../service/book-metadata-manage.service';
-import {LibraryShelfMenuService} from '../../service/library-shelf-menu.service';
import {Book} from '../../model/book.model';
import {SortDirection, SortOption} from '../../model/sort.model';
import {UserService} from '../../../settings/user-management/user.service';
@@ -294,14 +293,6 @@ function createHarness(options?: {
getMetadataMenuItems: vi.fn(() => []),
},
},
- {
- provide: LibraryShelfMenuService,
- useValue: {
- initializeLibraryMenuItems: vi.fn(() => []),
- initializeMagicShelfMenuItems: vi.fn(() => []),
- initializeShelfMenuItems: vi.fn(() => []),
- },
- },
{provide: PageTitleService, useValue: {setPageTitle: vi.fn()}},
{provide: LoadingService, useValue: {show: vi.fn(), hide: vi.fn()}},
{provide: LocalStorageService, useValue: {get: vi.fn(), set: vi.fn()}},
diff --git a/frontend/src/app/features/book/components/book-browser/book-browser.component.ts b/frontend/src/app/features/book/components/book-browser/book-browser.component.ts
index 7f0f808eb..f1d5f8faa 100644
--- a/frontend/src/app/features/book/components/book-browser/book-browser.component.ts
+++ b/frontend/src/app/features/book/components/book-browser/book-browser.component.ts
@@ -11,13 +11,15 @@ import {DynamicDialogRef} from '@openng/optimus-ui/dynamicdialog';
import {Library} from '../../model/library.model';
import {SortDirection, SortOption} from '../../model/sort.model';
import {Book} from '../../model/book.model';
-import {LibraryShelfMenuService} from '../../service/library-shelf-menu.service';
+import {
+ LibraryShelfMenuComponent,
+ type LibraryShelfMenuTarget,
+} from '../library-shelf-menu/library-shelf-menu.component';
import {BookTableComponent} from './book-table/book-table.component';
-import {Button} from '@openng/optimus-ui/button';
+import {Button, ButtonDirective} from '@openng/optimus-ui/button';
import {NgClass} from '@angular/common';
import {BookCardComponent} from './book-card/book-card.component';
-import {Menu} from '@openng/optimus-ui/menu';
import {InputText} from '@openng/optimus-ui/inputtext';
import {FormsModule} from '@angular/forms';
import {BookFilterComponent} from './book-filter/book-filter.component';
@@ -59,6 +61,7 @@ import {filterBooksByFilters} from './filters/sidebar-filter';
import {LayoutService} from '../../../../shared/layout/layout.service';
import {createGridDensity} from '../../../../shared/util/grid-density.util';
import {DeferredRenderState} from './deferred-render-state';
+import {AppMenuTriggerDirective} from '../../../../shared/ui/menu/app-menu-trigger.directive';
export enum EntityType {
LIBRARY = 'Library',
@@ -81,9 +84,10 @@ const MOBILE_COLUMNS_STORAGE_KEY = 'mobileColumnsPreference';
styleUrls: ['./book-browser.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [
- Button, BookCardComponent, Menu, InputText, FormsModule,
+ Button, ButtonDirective, BookCardComponent, InputText, FormsModule,
BookTableComponent, BookFilterComponent, Tooltip, NgClass, Popover,
Checkbox, Divider, MultiSelect, TieredMenu, Badge, MultiSortPopoverComponent, TranslocoDirective, TranslocoPipe, GridDensityButtonsComponent,
+ LibraryShelfMenuComponent, AppMenuTriggerDirective,
],
providers: [SeriesCollapseFilter],
})
@@ -105,7 +109,6 @@ export class BookBrowserComponent implements AfterViewInit {
private bookMetadataManageService = inject(BookMetadataManageService);
private dialogHelperService = inject(BookDialogHelperService);
private bookMenuService = inject(BookMenuService);
- private libraryShelfMenuService = inject(LibraryShelfMenuService);
private pageTitle = inject(PageTitleService);
private loadingService = inject(LoadingService);
private bookNavigationService = inject(BookNavigationService);
@@ -187,19 +190,17 @@ export class BookBrowserComponent implements AfterViewInit {
const {entityId, entityType} = this.entityInfo();
return this.entityService.getEntity(entityId, entityType);
});
- readonly entityOptions = computed