feat(ui): add enhanced user popover + rearrange sidebar (#1246)
Co-authored-by: brios <127139797+balazs-szucs@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { buildAllNavPages, buildHomeNavItems, buildQuickActionNavItems, findPageNavItem } from './nav-catalog';
|
||||
import {
|
||||
buildAllNavPages,
|
||||
buildCreateActionNavItems,
|
||||
buildHomeNavItems,
|
||||
buildQuickActionNavItems,
|
||||
findPageNavItem,
|
||||
} from './nav-catalog';
|
||||
|
||||
const translate = (key: string): string => key;
|
||||
|
||||
@@ -76,4 +82,22 @@ describe('nav-catalog', () => {
|
||||
'uploadBook',
|
||||
]);
|
||||
});
|
||||
|
||||
it('builds create-only actions without upload', () => {
|
||||
const handlers = {
|
||||
createLibrary: vi.fn(),
|
||||
createShelf: vi.fn(),
|
||||
createMagicShelf: vi.fn(),
|
||||
uploadBook: vi.fn(),
|
||||
};
|
||||
|
||||
expect(buildCreateActionNavItems(translate, {
|
||||
canManageLibrary: true,
|
||||
canUpload: true,
|
||||
}, handlers).map((item) => item.id)).toEqual([
|
||||
'createLibrary',
|
||||
'createShelf',
|
||||
'createMagicShelf',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -133,7 +133,7 @@ const SECONDARY_PAGE_DEFINITIONS: readonly PageDefinition[] = [
|
||||
},
|
||||
] as const;
|
||||
|
||||
const ACTION_DEFINITIONS: readonly ActionDefinition[] = [
|
||||
const CREATE_ACTION_DEFINITIONS: readonly ActionDefinition[] = [
|
||||
{
|
||||
id: 'createLibrary',
|
||||
labelKey: 'layout.menu.createLibrary',
|
||||
@@ -153,6 +153,10 @@ const ACTION_DEFINITIONS: readonly ActionDefinition[] = [
|
||||
icon: 'pi-sparkles',
|
||||
run: (handlers) => handlers.createMagicShelf,
|
||||
},
|
||||
] as const;
|
||||
|
||||
const ACTION_DEFINITIONS: readonly ActionDefinition[] = [
|
||||
...CREATE_ACTION_DEFINITIONS,
|
||||
{
|
||||
id: 'uploadBook',
|
||||
labelKey: 'layout.menu.uploadBook',
|
||||
@@ -207,6 +211,21 @@ export function buildQuickActionNavItems(
|
||||
}));
|
||||
}
|
||||
|
||||
export function buildCreateActionNavItems(
|
||||
translate: TranslateFn,
|
||||
permissions: ShellNavPermissions,
|
||||
handlers: ShellActionHandlers,
|
||||
): NavItem[] {
|
||||
return CREATE_ACTION_DEFINITIONS
|
||||
.filter((definition) => isVisible(definition, permissions))
|
||||
.map((definition) => ({
|
||||
id: definition.id,
|
||||
label: translate(definition.labelKey),
|
||||
icon: definition.icon,
|
||||
action: definition.run(handlers),
|
||||
}));
|
||||
}
|
||||
|
||||
const ALL_PAGE_DEFINITIONS: readonly PageDefinition[] = [
|
||||
...HOME_PAGE_DEFINITIONS,
|
||||
...SECONDARY_PAGE_DEFINITIONS,
|
||||
|
||||
Reference in New Issue
Block a user