@alepha/ui 0.25.0 → 0.25.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -5
- package/src/components/account/__tests__/account-router.spec.ts +201 -0
- package/src/components/account/account-connections.tsx +103 -0
- package/src/components/account/account-delete-dialog.tsx +184 -0
- package/src/components/account/account-header.tsx +57 -0
- package/src/components/account/account-keys.tsx +221 -0
- package/src/components/account/account-layout.tsx +63 -0
- package/src/components/account/account-password-dialog.tsx +152 -0
- package/src/components/account/account-profile.tsx +229 -0
- package/src/components/account/account-router-options.tsx +74 -0
- package/src/components/account/account-router-page.tsx +69 -0
- package/src/components/account/account-router.tsx +214 -0
- package/src/components/account/account-security.tsx +150 -0
- package/src/components/account/account-sessions.tsx +140 -0
- package/src/components/admin/__tests__/admin-keys-token-dialog.browser.spec.tsx +62 -0
- package/src/components/admin/__tests__/admin-layout.browser.spec.tsx +82 -0
- package/src/components/admin/__tests__/admin-router-page.spec.ts +54 -0
- package/src/components/admin/__tests__/admin-router.spec.ts +208 -0
- package/src/components/admin/__tests__/admin-user-cell.browser.spec.tsx +99 -0
- package/src/components/admin/__tests__/admin-user-detail.spec.ts +29 -0
- package/src/components/admin/admin-analytics-query-panel.tsx +149 -0
- package/src/components/admin/admin-analytics-results.tsx +95 -0
- package/src/components/admin/admin-analytics.tsx +104 -0
- package/src/components/admin/admin-audits.tsx +12 -15
- package/src/components/admin/admin-files.tsx +10 -18
- package/src/components/admin/admin-jobs-executions-panel.tsx +2 -1
- package/src/components/admin/admin-jobs.tsx +3 -1
- package/src/components/admin/admin-keys-token-dialog.tsx +123 -0
- package/src/components/admin/admin-keys.tsx +54 -3
- package/src/components/admin/admin-layout.tsx +107 -0
- package/src/components/admin/admin-payments.tsx +4 -5
- package/src/components/admin/admin-router-options.tsx +130 -0
- package/src/components/admin/admin-router-page.tsx +74 -0
- package/src/components/admin/admin-router.tsx +379 -0
- package/src/components/admin/admin-sessions.tsx +2 -16
- package/src/components/admin/admin-user-cell.tsx +70 -0
- package/src/components/admin/admin-user-detail-overview-tab.tsx +28 -0
- package/src/components/admin/admin-user-detail-profile-policy.spec.ts +146 -0
- package/src/components/admin/admin-user-detail-profile-policy.ts +147 -0
- package/src/components/admin/admin-user-detail-security-tab.tsx +1 -1
- package/src/components/admin/admin-user-detail.tsx +76 -32
- package/src/components/admin/admin-users-status-filter.tsx +2 -0
- package/src/components/admin/admin-workflows-execution-sheet.tsx +277 -0
- package/src/components/admin/admin-workflows-executions-panel.tsx +170 -0
- package/src/components/admin/admin-workflows-status-badge.tsx +40 -0
- package/src/components/admin/admin-workflows.tsx +207 -0
- package/src/components/alepha-table/alepha-table.tsx +73 -17
- package/src/components/app-actions/__tests__/app-actions.browser.spec.tsx +79 -0
- package/src/components/app-actions/app-actions.tsx +113 -0
- package/src/components/app-shell/app-shell.tsx +122 -0
- package/src/components/auth/auth-reset-password.tsx +81 -8
- package/src/components/button-user/button-user.tsx +58 -1
- package/src/components/control/control.tsx +14 -71
- package/src/components/control-password/control-password.tsx +87 -0
- package/src/components/control-select/__tests__/control-select-clear-label.browser.spec.tsx +101 -0
- package/src/components/control-select/__tests__/control-select-deselect.browser.spec.tsx +126 -0
- package/src/components/control-select/__tests__/control-select-searchable.browser.spec.tsx +142 -0
- package/src/components/control-select/control-select.tsx +133 -111
- package/src/components/control-upload/control-upload.tsx +27 -1
- package/src/components/markdown-view/markdown-view.tsx +6 -0
- package/src/components/nav-shell/nav-page.tsx +3 -3
- package/src/components/settings/__tests__/settings-nav.browser.spec.tsx +123 -0
- package/src/components/settings/__tests__/settings-section.browser.spec.tsx +130 -0
- package/src/components/settings/settings-danger-section.tsx +59 -0
- package/src/components/settings/settings-layout.tsx +56 -0
- package/src/components/settings/settings-nav.tsx +131 -0
- package/src/components/settings/settings-row.tsx +81 -0
- package/src/components/settings/settings-section.tsx +64 -0
- package/src/components/ui/alert-dialog.tsx +1 -1
- package/src/components/ui/avatar.tsx +2 -0
- package/src/components/ui/breadcrumb.tsx +1 -1
- package/src/components/ui/calendar.tsx +11 -6
- package/src/components/ui/card.tsx +5 -5
- package/src/components/ui/carousel.tsx +4 -4
- package/src/components/ui/chart.tsx +2 -0
- package/src/components/ui/collapsible.tsx +2 -0
- package/src/components/ui/combobox.tsx +3 -1
- package/src/components/ui/context-menu.tsx +3 -3
- package/src/components/ui/dialog.tsx +6 -1
- package/src/components/ui/direction.tsx +2 -0
- package/src/components/ui/drawer.tsx +134 -37
- package/src/components/ui/dropdown-menu.tsx +13 -3
- package/src/components/ui/empty.tsx +4 -1
- package/src/components/ui/input-otp.tsx +2 -0
- package/src/components/ui/menubar.tsx +2 -2
- package/src/components/ui/pagination.tsx +2 -2
- package/src/components/ui/popover.tsx +2 -0
- package/src/components/ui/radio-group.tsx +2 -0
- package/src/components/ui/scroll-area.tsx +2 -0
- package/src/components/ui/select.tsx +1 -1
- package/src/components/ui/separator.tsx +2 -0
- package/src/components/ui/sheet.tsx +4 -1
- package/src/components/ui/sidebar.tsx +1 -1
- package/src/components/ui/spinner.tsx +1 -0
- package/src/components/ui/switch.tsx +2 -0
- package/src/components/ui/tabs.tsx +2 -0
- package/src/components/ui/toggle-group.tsx +2 -0
- package/src/components/ui/tooltip.tsx +2 -0
- package/src/lib/__tests__/rehype-safe-img.spec.ts +121 -0
- package/src/lib/i18n-fr.ts +68 -0
- package/src/lib/rehype-safe-img.ts +150 -0
- package/src/lib/resize-image.ts +135 -0
- package/src/styles.css +126 -1
- /package/src/components/{admin/admin-user-detail-provider-labels.ts → auth/provider-labels.ts} +0 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { AppActions } from "@alepha/ui/components/app-actions/app-actions";
|
|
2
|
+
import { NavShell } from "@alepha/ui/components/nav-shell/nav-shell";
|
|
3
|
+
import { Spotlight } from "@alepha/ui/components/nav-shell/spotlight";
|
|
4
|
+
import { cn } from "@alepha/ui/lib/utils";
|
|
5
|
+
import { useStore } from "alepha/react";
|
|
6
|
+
import { useRouter } from "alepha/react/router";
|
|
7
|
+
import { ColorScheme } from "alepha/react/ui";
|
|
8
|
+
import { LayoutDashboard, Search } from "lucide-react";
|
|
9
|
+
import { useState } from "react";
|
|
10
|
+
import { adminRouterOptionsAtom } from "./admin-router-options.tsx";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The admin shell.
|
|
14
|
+
*
|
|
15
|
+
* The sidebar and breadcrumb trail are derived from the route subtree
|
|
16
|
+
* anchored at `admin` — every page carries its own `nav` metadata, so there
|
|
17
|
+
* is no hand-synced list here and an application page that adopts the layout
|
|
18
|
+
* appears in the sidebar without registering anywhere.
|
|
19
|
+
*
|
|
20
|
+
* Four details are load-bearing rather than decorative:
|
|
21
|
+
*
|
|
22
|
+
* - `<ColorScheme />` is mounted here because `/admin` is not a child of the
|
|
23
|
+
* application's own layout. Without it the dark-mode toggle updates the
|
|
24
|
+
* atom and no subscriber applies the class to `<html>` until a full reload.
|
|
25
|
+
* `colorScheme: false` opts out, for applications whose host document owns
|
|
26
|
+
* the `<html>` theme class itself — see `AdminRouterOptions.colorScheme`.
|
|
27
|
+
* - `h-svh` on the wrapper plus `fill` on `NavShell` switches
|
|
28
|
+
* `SidebarProvider` from `min-h-svh` to `h-full`, which is what lets a table
|
|
29
|
+
* body scroll inside the main area instead of pushing the whole page taller.
|
|
30
|
+
* - Spotlight is `root`-scoped to `admin`, so ⌘K searches admin pages only.
|
|
31
|
+
* Its trigger button renders outside the `topbarActions` slot: the open
|
|
32
|
+
* state is local to this component, so a replacement cluster could never
|
|
33
|
+
* rebuild the button — replacing the cluster must not cost the affordance.
|
|
34
|
+
* - `ButtonUser` is given custom `children` rather than its default
|
|
35
|
+
* `onAdminClick` menu: that default item is labelled "Admin Panel" and
|
|
36
|
+
* documented as `router.push("admin")` — the exact opposite of what it
|
|
37
|
+
* would do here, since the account menu already lives inside `/admin` and
|
|
38
|
+
* the only useful action is leaving it. Composing the menu by hand keeps
|
|
39
|
+
* `ButtonUser`'s own default label correct for its normal use outside
|
|
40
|
+
* admin.
|
|
41
|
+
*/
|
|
42
|
+
export const AdminLayout = () => {
|
|
43
|
+
const router = useRouter<any>();
|
|
44
|
+
const [options] = useStore(adminRouterOptionsAtom);
|
|
45
|
+
const [spotlightOpen, setSpotlightOpen] = useState(false);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div className={cn("flex h-svh flex-col", options.className)}>
|
|
49
|
+
{options.colorScheme !== false && <ColorScheme />}
|
|
50
|
+
<NavShell
|
|
51
|
+
root="admin"
|
|
52
|
+
fill
|
|
53
|
+
extraNav={options.extraNav}
|
|
54
|
+
brand={
|
|
55
|
+
options.brand ?? (
|
|
56
|
+
<div className="flex items-center gap-2 px-2 py-1.5 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 group-data-[collapsible=icon]:px-0">
|
|
57
|
+
<LayoutDashboard className="size-4 shrink-0" />
|
|
58
|
+
<span className="text-sm font-semibold tracking-tight group-data-[collapsible=icon]:hidden">
|
|
59
|
+
Admin
|
|
60
|
+
</span>
|
|
61
|
+
</div>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
topbarActions={
|
|
65
|
+
<div className="flex items-center gap-1">
|
|
66
|
+
<button
|
|
67
|
+
type="button"
|
|
68
|
+
onClick={() => setSpotlightOpen(true)}
|
|
69
|
+
className="text-muted-foreground hover:bg-accent hover:text-foreground hidden h-8 items-center gap-2 rounded-md border px-2 text-sm transition-colors sm:flex"
|
|
70
|
+
>
|
|
71
|
+
<Search className="size-4 shrink-0" />
|
|
72
|
+
<span>Search…</span>
|
|
73
|
+
<kbd className="bg-muted text-muted-foreground pointer-events-none ml-2 hidden rounded px-1.5 font-mono text-[10px] md:inline">
|
|
74
|
+
⌘K
|
|
75
|
+
</kbd>
|
|
76
|
+
</button>
|
|
77
|
+
<div
|
|
78
|
+
aria-hidden="true"
|
|
79
|
+
className="bg-border mx-1 h-5 w-px shrink-0"
|
|
80
|
+
/>
|
|
81
|
+
{options.topbarActions ?? (
|
|
82
|
+
<AppActions
|
|
83
|
+
loginRouteName={options.loginRouteName}
|
|
84
|
+
/*
|
|
85
|
+
`adminRouteName` points back at the site, not at admin: the
|
|
86
|
+
account menu already lives inside `/admin`, so the only
|
|
87
|
+
useful destination is out. `AdminMenuItem` still carries the
|
|
88
|
+
`admin:ui` check, which is the right gate for an item only
|
|
89
|
+
an operator should see.
|
|
90
|
+
*/
|
|
91
|
+
adminRouteName={options.homeRouteName ?? "home"}
|
|
92
|
+
labels={{ admin: "Back to site" }}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
95
|
+
</div>
|
|
96
|
+
}
|
|
97
|
+
/>
|
|
98
|
+
<Spotlight
|
|
99
|
+
root="admin"
|
|
100
|
+
open={spotlightOpen}
|
|
101
|
+
onOpenChange={setSpotlightOpen}
|
|
102
|
+
/>
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default AdminLayout;
|
|
@@ -3,6 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
void React;
|
|
4
4
|
|
|
5
5
|
import { AdminPage } from "@alepha/ui/components/admin/admin-page";
|
|
6
|
+
import { AdminUserCell } from "@alepha/ui/components/admin/admin-user-cell";
|
|
6
7
|
import { AlephaTable } from "@alepha/ui/components/alepha-table/alepha-table";
|
|
7
8
|
import { Badge } from "@alepha/ui/components/ui/badge";
|
|
8
9
|
import type {
|
|
@@ -58,11 +59,7 @@ export function AdminPayments() {
|
|
|
58
59
|
},
|
|
59
60
|
customer: {
|
|
60
61
|
label: tr("admin.payments.colCustomer", { default: "Customer" }),
|
|
61
|
-
cell: (p) =>
|
|
62
|
-
<span className="text-muted-foreground font-mono text-xs">
|
|
63
|
-
{p.userId?.slice(0, 8) ?? "—"}
|
|
64
|
-
</span>
|
|
65
|
-
),
|
|
62
|
+
cell: (p) => <AdminUserCell userId={p.userId} user={p.user} />,
|
|
66
63
|
},
|
|
67
64
|
provider: {
|
|
68
65
|
label: tr("admin.payments.colProvider", { default: "Provider" }),
|
|
@@ -91,3 +88,5 @@ export function AdminPayments() {
|
|
|
91
88
|
</AdminPage>
|
|
92
89
|
);
|
|
93
90
|
}
|
|
91
|
+
|
|
92
|
+
export default AdminPayments;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { NavGroup } from "@alepha/ui/components/app-shell/app-shell";
|
|
2
|
+
import { $atom, z } from "alepha";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import type { AdminParametersProps } from "./admin-parameters.tsx";
|
|
5
|
+
import type { AdminUserDetailProps } from "./admin-user-detail.tsx";
|
|
6
|
+
import type { AdminUsersProps } from "./admin-users.tsx";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Everything an application can change about `AdminRouter` without writing
|
|
10
|
+
* its own.
|
|
11
|
+
*
|
|
12
|
+
* The seam is deliberately narrow: chrome slots plus the props of the three
|
|
13
|
+
* pages that accept props. An application wanting different URLs, different
|
|
14
|
+
* page composition or a different shell writes its own router — the same
|
|
15
|
+
* trade `AuthRouter` documents.
|
|
16
|
+
*/
|
|
17
|
+
export interface AdminRouterOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Sidebar header. Lore's back-arrow-plus-title and shop's Poinçon are both
|
|
20
|
+
* just this.
|
|
21
|
+
*/
|
|
22
|
+
brand?: ReactNode;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Replaces the default language / dark-mode / account cluster entirely when
|
|
26
|
+
* set. Supply the whole cluster, not an addition to it.
|
|
27
|
+
*
|
|
28
|
+
* The ⌘K search affordance is not part of the cluster and always renders:
|
|
29
|
+
* the Spotlight state it opens lives inside the layout, where no
|
|
30
|
+
* replacement cluster could reach it.
|
|
31
|
+
*/
|
|
32
|
+
topbarActions?: ReactNode;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Extra class(es) merged onto the shell's root element.
|
|
36
|
+
*
|
|
37
|
+
* Exists for applications whose `/admin` lives inside a document they do
|
|
38
|
+
* not fully own — a host page that paints fixed overlays over the viewport,
|
|
39
|
+
* or hardcodes a theme class on `<html>` — and that need one stable hook to
|
|
40
|
+
* fence the console off from that chrome. Styling inside the shell does not
|
|
41
|
+
* go through this; components carry their own classes.
|
|
42
|
+
*/
|
|
43
|
+
className?: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Set `false` to keep the shell from mounting `<ColorScheme />`.
|
|
47
|
+
*
|
|
48
|
+
* The shell mounts it because `/admin` is normally not a child of the
|
|
49
|
+
* application's own layout, so nothing else would apply the dark-mode
|
|
50
|
+
* atom's class to `<html>`. An application whose host document owns that
|
|
51
|
+
* class itself — a hardcoded `<html class="dark">`, a theme manager of its
|
|
52
|
+
* own — turns this off so entering `/admin` cannot rewrite the document's
|
|
53
|
+
* theme underneath the rest of the app.
|
|
54
|
+
*
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
colorScheme?: boolean;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Nav groups appended after the route-derived ones, for entries that map to
|
|
61
|
+
* no route. Forwarded to `NavShell`'s own `extraNav`.
|
|
62
|
+
*/
|
|
63
|
+
extraNav?: NavGroup[];
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Route name the shell's "leave admin" affordance pushes.
|
|
67
|
+
*
|
|
68
|
+
* @default "home"
|
|
69
|
+
*/
|
|
70
|
+
homeRouteName?: string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Where a bare `/admin` redirects.
|
|
74
|
+
*
|
|
75
|
+
* Defaults to the users list, which is the first entry of the built-in
|
|
76
|
+
* sidebar. An application whose back office is mostly its own pages will
|
|
77
|
+
* want one of those instead.
|
|
78
|
+
*
|
|
79
|
+
* @default "/admin/users"
|
|
80
|
+
*/
|
|
81
|
+
indexPath?: string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Route name the shell's sign-in affordance pushes.
|
|
85
|
+
*
|
|
86
|
+
* `login` is the conventional name because `AuthRouter` mounts a page by
|
|
87
|
+
* that name. This option exists for applications that mount their own auth
|
|
88
|
+
* routes under a different name instead of `AuthRouter`.
|
|
89
|
+
*
|
|
90
|
+
* @default "login"
|
|
91
|
+
*/
|
|
92
|
+
loginRouteName?: string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Props forwarded to the three pages that accept them, keyed by page.
|
|
96
|
+
*
|
|
97
|
+
* Each entry reuses that component's own exported props interface rather
|
|
98
|
+
* than restating its fields, so a prop added to `AdminUsers` is passable the
|
|
99
|
+
* day it exists.
|
|
100
|
+
*/
|
|
101
|
+
pages?: {
|
|
102
|
+
users?: AdminUsersProps;
|
|
103
|
+
userDetail?: AdminUserDetailProps;
|
|
104
|
+
parameters?: AdminParametersProps;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Boot-time configuration for {@link AdminRouter}, following the
|
|
110
|
+
* `linkOptionsAtom` / `oauthOptions` / `mcpStreamableHttpOptions` pattern:
|
|
111
|
+
* the application calls `alepha.set(adminRouterOptionsAtom, { … })` once,
|
|
112
|
+
* before start.
|
|
113
|
+
*
|
|
114
|
+
* The schema is a `z.custom` passthrough because the value carries React
|
|
115
|
+
* nodes and component references, whose shape TypeScript already owns — the
|
|
116
|
+
* exact case `z.custom`'s own documentation names. Nothing here crosses a
|
|
117
|
+
* trust boundary: it is written by the application at boot and read only by
|
|
118
|
+
* the admin shell.
|
|
119
|
+
*
|
|
120
|
+
* Being boot-configured also keeps it out of the SSR payload.
|
|
121
|
+
* `StateManager.exportAtoms()` reads scope `"current"`, so it sees
|
|
122
|
+
* request-scoped writes only and never an atom set on the app store — which
|
|
123
|
+
* matters here, because a `ReactNode` would not survive JSON serialization.
|
|
124
|
+
*/
|
|
125
|
+
export const adminRouterOptionsAtom = $atom({
|
|
126
|
+
name: "alepha.ui.admin.router.options",
|
|
127
|
+
description: "Chrome slots and per-page props for the admin router.",
|
|
128
|
+
schema: z.custom<AdminRouterOptions>(),
|
|
129
|
+
default: {} satisfies AdminRouterOptions,
|
|
130
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { $context } from "alepha";
|
|
2
|
+
import type {
|
|
3
|
+
PageConfigSchema,
|
|
4
|
+
PagePrimitive,
|
|
5
|
+
TPropsDefault,
|
|
6
|
+
TPropsParentDefault,
|
|
7
|
+
} from "alepha/react/router";
|
|
8
|
+
import { $pageNav, type PageNavOptions } from "../nav-shell/nav-page.tsx";
|
|
9
|
+
import { AdminRouter } from "./admin-router.tsx";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* `$pageNav` already parented to {@link AdminRouter}'s `/admin` shell — the
|
|
13
|
+
* one-call form of "a page inside the shared admin shell". It exists because
|
|
14
|
+
* the alternative — injecting `AdminRouter` and writing
|
|
15
|
+
* `parent: this.admin.layout` by hand on every page — puts the rules of that
|
|
16
|
+
* composition nowhere an author will read them.
|
|
17
|
+
*
|
|
18
|
+
* It carries the `$` prefix to sit with the framework's other declarations at
|
|
19
|
+
* a call site, but it is a plain function wrapping `$pageNav` — which in turn
|
|
20
|
+
* wraps `$page` — rather than a `createPrimitive` primitive. Nothing about
|
|
21
|
+
* its lifecycle differs from declaring `$page` yourself.
|
|
22
|
+
*
|
|
23
|
+
* The page appears in the shell's sidebar with no separate registration
|
|
24
|
+
* step: `useNavEntries` walks the parent chain and reads each page's own
|
|
25
|
+
* `nav`, the same as any other page hung off `AdminRouter.layout`.
|
|
26
|
+
*
|
|
27
|
+
* **Calling this registers `AdminRouter`.** Declaring even one page this way
|
|
28
|
+
* mounts the whole `/admin` shell, including its ten built-in pages (Users,
|
|
29
|
+
* Sessions, Jobs, …) — an admin page without the admin shell around it is
|
|
30
|
+
* not a thing. This is the intended reading, but it is a real side effect:
|
|
31
|
+
* an application that wants `/admin` to carry only its own pages, with none
|
|
32
|
+
* of the built-ins, must build its own layout page instead of reaching for
|
|
33
|
+
* this helper.
|
|
34
|
+
*
|
|
35
|
+
* **Take `order: 100` or above, or declare your own `nav.group`.** The
|
|
36
|
+
* built-ins occupy `Identity` (orders 1-3) and `Operations` (orders 4-9),
|
|
37
|
+
* and `useNavEntries` sorts groups by their smallest member — a page at a
|
|
38
|
+
* lower order silently reshuffles the shared sidebar.
|
|
39
|
+
*
|
|
40
|
+
* **Gate with `can: () => this.someApi.someAction.can()`, not with
|
|
41
|
+
* `permission` alone.** A permission named by this page's own `$secure` is
|
|
42
|
+
* self-declaring: `$secure` registers it into `SecurityProvider` at
|
|
43
|
+
* definition time, so an admin holding the `*` wildcard is granted it
|
|
44
|
+
* whether or not any controller backing the page exists — the entry would
|
|
45
|
+
* stay visible over a dead API. An action name resolves against
|
|
46
|
+
* `/api/_links`, a registry built only from actions the server actually
|
|
47
|
+
* registered, so a page whose backend never shipped never appears for
|
|
48
|
+
* anyone to be granted.
|
|
49
|
+
*
|
|
50
|
+
* ```tsx
|
|
51
|
+
* class ShopAdminRouter {
|
|
52
|
+
* products = $pageAdmin({
|
|
53
|
+
* path: "/products",
|
|
54
|
+
* nav: { label: "Catalogue", icon: <Gem />, group: "Commerce", order: 100 },
|
|
55
|
+
* can: () => this.productApi.commerceAdminProductList.can(),
|
|
56
|
+
* lazy: () => import("./AdminProducts.tsx"),
|
|
57
|
+
* });
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export const $pageAdmin = <
|
|
62
|
+
TConfig extends PageConfigSchema = PageConfigSchema,
|
|
63
|
+
TProps extends object = TPropsDefault,
|
|
64
|
+
TPropsParent extends object = TPropsParentDefault,
|
|
65
|
+
>(
|
|
66
|
+
options: Omit<PageNavOptions<TConfig, TProps, TPropsParent>, "parent">,
|
|
67
|
+
): PagePrimitive<TConfig, TProps, TPropsParent> => {
|
|
68
|
+
const { alepha } = $context();
|
|
69
|
+
const admin = alepha.inject(AdminRouter);
|
|
70
|
+
return $pageNav<TConfig, TProps, TPropsParent>({
|
|
71
|
+
...options,
|
|
72
|
+
parent: admin.layout,
|
|
73
|
+
} as PageNavOptions<TConfig, TProps, TPropsParent>);
|
|
74
|
+
};
|