From e94d9a4c703cd5b0c5777f66d8b96987a2a553f0 Mon Sep 17 00:00:00 2001 From: sirily11 <32106111+sirily11@users.noreply.github.com> Date: Tue, 7 Jul 2026 04:28:15 +0800 Subject: [PATCH] fix: add customization support to admin --- docs/code/admin-next.md | 38 +++++++ .../admin-next/src/components/admin-shell.tsx | 100 ++++++++++-------- .../src/components/resource-view.test.tsx | 86 +++++++++++++++ .../src/components/resource-view.tsx | 2 +- packages/admin-next/src/server/admin-app.tsx | 15 +++ 5 files changed, 196 insertions(+), 45 deletions(-) create mode 100644 packages/admin-next/src/components/resource-view.test.tsx diff --git a/docs/code/admin-next.md b/docs/code/admin-next.md index f60a90a..ffde318 100644 --- a/docs/code/admin-next.md +++ b/docs/code/admin-next.md @@ -91,3 +91,41 @@ defaulting to `view`. For generic table resources, rows with a `dynamicPath` navigate to `{basePath}/{resourceId}/{dynamicPath}` and render a read-only detail view from the resource's table schema plus the detail response. + +## Customizing the header + +`AdminApp` renders a full-width app header above the sidebar and content. Two +optional props customize it so the host does not need to render its own header +(which would produce a duplicated bar): + +- `title`: brand shown at the top-left. Accepts a string or any React node + (e.g. a logo). Defaults to `"Admin"`. +- `headerActions`: content rendered at the top-right — typically the signed-in + user and a sign-out control. Because `AdminApp` is a Server Component, you can + pass a server-action `
+ } + /> + ); +} +``` diff --git a/packages/admin-next/src/components/admin-shell.tsx b/packages/admin-next/src/components/admin-shell.tsx index 02558a5..ea36ff5 100644 --- a/packages/admin-next/src/components/admin-shell.tsx +++ b/packages/admin-next/src/components/admin-shell.tsx @@ -28,6 +28,10 @@ export interface AdminShellProps { }; actions: AdminActions; error?: string; + /** Brand shown at the top-left of the app header. Defaults to "Admin". */ + title?: React.ReactNode; + /** Custom content rendered at the top-right of the app header. */ + headerActions?: React.ReactNode; } /** Look up a lucide icon by its kebab/pascal name, with a sane fallback. */ @@ -50,54 +54,62 @@ export function AdminShell({ initialView, actions, error, + title, + headerActions, }: AdminShellProps): React.JSX.Element { return (