diff --git a/.changeset/37150-docs-pages-in-app-shell.md b/.changeset/37150-docs-pages-in-app-shell.md new file mode 100644 index 00000000000..4557ba70067 --- /dev/null +++ b/.changeset/37150-docs-pages-in-app-shell.md @@ -0,0 +1,16 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/console': patch +'@objectstack/console': patch +--- + +feat(console): an app's documentation pages draw in the app shell from 768 px up + +Clause-②: no +Metadata-protocol: none + +From 768 px up every app page lost the top bar and keeps the app menu, search, notifications and account in the sidebar. An app's documentation pages (`/apps/APP/docs`, a book, a flat doc link, an article) were the one exception: they kept the top bar at every width and mounted no sidebar. They now draw like every other app page there: no top bar, the resident sidebar with its usual head (the app-name menu, collapse, search, notifications) and foot (the account), and the page header's button group (assistant and help) at the top right. + +The documentation still has one navigation, its own: the sidebar's body carries the docs column (「← Back to APP」, every book of the app with the current one open, a title filter and 「All documentation」) in place of the app's menu. The reader no longer draws that column inside the page there. The app's other docs pages (its docs index, a book with no articles, a book or doc that is not found) carry the same column in the sidebar instead of a back link above the page. + +Unchanged: every docs address resolves to the same page as before, and a phone keeps its app bar, no sidebar and the in-page column. The `/docs` portal is not changed by this release. Nothing to migrate. diff --git a/ui/apps/console/src/pages/DocPage.tsx b/ui/apps/console/src/pages/DocPage.tsx index b27fcd9cda1..0a82d5e5354 100644 --- a/ui/apps/console/src/pages/DocPage.tsx +++ b/ui/apps/console/src/pages/DocPage.tsx @@ -9,14 +9,14 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { Link, Navigate, useHref, useLocation, useNavigate, useParams } from 'react-router-dom'; import { AlertCircle, ChevronDown, ChevronRight, FileQuestion, Layers, Loader2, Menu } from 'lucide-react'; -import { useAdapter } from '@object-ui/app-shell'; +import { useAdapter, useSidebarDocsNavSlot } from '@object-ui/app-shell'; import { MarkdownRenderer, MermaidEnlargeContext, extractToc } from '@object-ui/plugin-markdown'; import { useObjectTranslation } from '@object-ui/i18n'; import { rewriteDocLinks } from './doc-links'; import { conflictCandidates, readsByNameAfter } from './doc-address'; import { DocShell } from './DocShell'; import { useAppDocsBackTo } from './useAppDocsBackTo'; -import { DocsNav, type DocsNavBook } from './DocsNav'; +import { DocsNav, usePackageDocsNavBooks } from './DocsNav'; import { DocRefusal } from './BookPage'; import { useBookData } from './use-book-data'; import { useActiveHeading } from './useActiveHeading'; @@ -249,17 +249,14 @@ export default function DocPage() { const docHref = useCallback((docName: string) => `${base}/${slug}/${docName}`, [base, slug]); // objectstack#35424 — the docs column lists every book of the package the // reader is in: the current book's package, else the route's app package. - const packageBooks = useMemo(() => { + const readerPackage = useMemo(() => { const current = books.find((b) => bookSlug(b) === slug); - const pkg = current ? pkgOfBook(current) : appName; - if (!pkg) return []; - return books - .filter((b) => pkgOfBook(b) === pkg) - .map((b) => ({ - slug: bookSlug(b), - book: labelUncategorized(resolveBookTree(b, allDocs, undefined, authoredBooks), uncategorizedLabel), - })); - }, [books, authoredBooks, allDocs, slug, appName, uncategorizedLabel]); + return current ? pkgOfBook(current) : appName; + }, [books, slug, appName]); + const packageBooks = usePackageDocsNavBooks(readerPackage); + // objectstack#37150 — inside an app from 768 px up the shell sidebar carries + // the column (`DocShell` draws it there); elsewhere the page draws it. + const sidebarNav = useSidebarDocsNavSlot() !== null; const neighbours = useMemo( () => (resolvedBook ? articleNeighbours(resolvedBook, name) : { previous: null, next: null }), [resolvedBook, name], @@ -397,31 +394,35 @@ export default function DocPage() { ) : null; const docsLabel = t('help.documentation', { defaultValue: 'Documentation' }); + const pageNav = sidebarNav ? null : docsNav; + return ( - + {/* objectstack#35424 — the docs column is the page's one navigation. - * Inside an app it sits where the app menu would, full height beside - * the article; on narrow screens it folds into a disclosure above it. */} + * Inside an app from 768 px up it is the shell sidebar's body, where the + * app menu would be (objectstack#37150); elsewhere it sits full height + * beside the article, and on narrow screens it folds into a disclosure + * above it. */}
- {docsNav ? ( + {pageNav ? ( ) : null}
- {docsNav ? ( + {pageNav ? (
{resolvedBook?.label ?? docsLabel} -
{docsNav}
+
{pageNav}
) : null}
diff --git a/ui/apps/console/src/pages/DocShell.tsx b/ui/apps/console/src/pages/DocShell.tsx index 4b8dbcacb26..04e5c0ae755 100644 --- a/ui/apps/console/src/pages/DocShell.tsx +++ b/ui/apps/console/src/pages/DocShell.tsx @@ -8,35 +8,66 @@ import type { ReactNode } from 'react'; import { useParams } from 'react-router-dom'; +import { + SidebarDocsNav, + useShellPageActionsSlot, + useShellSidebarExpandSlot, + useSidebarDocsNavSlot, +} from '@object-ui/app-shell'; import { AppDocsBackLink } from './AppDocsBackLink'; +import { AppDocsNav, DocsNavLandmark } from './DocsNav'; import { useAppDocsBackTo } from './useAppDocsBackTo'; /** - * The frame of the package-documentation pages (ADR-0046), inside the - * console's own top bar. It draws no bar of its own (objectstack#35424): + * The frame of the package-documentation pages (ADR-0046). It draws no bar of + * its own (objectstack#35424): * - * - Under an app (`/apps/:appName/docs/...`, ADR-0048) the app bar above reads - * 「APP / Documentation」, and the reader names its book and article above - * the article. An app's docs routes draw no app menu either, so the bar's - * place holds 「← Back to APP」 (`AppDocsBackLink`) on every page but the - * reader, which carries it in its docs column and passes `backLink={false}`. + * - Under an app (`/apps/:appName/docs/...`, ADR-0048), from 768 px up, the + * page is drawn in the app shell like every other app page + * (objectstack#37150, ruling 7142354097 on objectstack#36107): no top bar, + * the resident sidebar, and the page header's button group and expand + * button, which this frame draws at the page's top. The docs' one + * navigation column (the app's books, 「← Back to APP」 and all + * documentation) is the sidebar's body: the page hands it `nav`, the + * reader's own, else every book of the app (`AppDocsNav`). + * - Under an app on a phone the console's app bar is above the page, and the + * page carries 「← Back to APP」 itself: at the top here, on every page but + * the reader, which carries it in its in-page column and passes + * `backLink={false}`. * - The portal (`/docs/...`) is drawn in Home's frame, whose bar reads * 「PRODUCT / Documentation」 and links to the portal's index (`App.tsx`, * the `docs` variant of `AppHeader`). */ export function DocShell({ backLink = true, + nav, children, }: { - /** Inside an app: draw 「← Back to APP」 above the page. The reader turns it off when its column has it. */ + /** Without the shell sidebar: draw 「← Back to APP」 above the page. The reader turns it off when its column has it. */ backLink?: boolean; + /** The page's own docs column, for the shell sidebar (the reader's); else every book of the app. */ + nav?: ReactNode; children: ReactNode; }) { const { appName } = useParams<{ appName?: string }>(); const backTo = useAppDocsBackTo(); + const sidebarNav = useSidebarDocsNavSlot() !== null; + const renderActions = useShellPageActionsSlot(); + const renderExpand = useShellSidebarExpandSlot(); return (
- {appName && backLink && backTo ? ( + {sidebarNav ? ( + + {nav ?? } + + ) : null} + {renderActions || renderExpand ? ( +
+ {renderExpand?.()} +
{renderActions?.({})}
+
+ ) : null} + {appName && backLink && backTo && !sidebarNav ? (
diff --git a/ui/apps/console/src/pages/DocsNav.tsx b/ui/apps/console/src/pages/DocsNav.tsx index 9438b2b30d7..9c0071d4126 100644 --- a/ui/apps/console/src/pages/DocsNav.tsx +++ b/ui/apps/console/src/pages/DocsNav.tsx @@ -6,15 +6,16 @@ * LICENSE file in the root directory of this source tree. */ -import { useId, useState } from 'react'; -import { Link } from 'react-router-dom'; +import { useCallback, useId, useMemo, useState, type ReactNode } from 'react'; +import { Link, useParams } from 'react-router-dom'; import { ArrowRight, ChevronDown, ChevronRight, Search } from 'lucide-react'; import { useObjectTranslation } from '@object-ui/i18n'; import { AppDocsBackLink } from './AppDocsBackLink'; -import type { AppDocsBackTo } from './useAppDocsBackTo'; +import { useAppDocsBackTo, type AppDocsBackTo } from './useAppDocsBackTo'; import { BookSidebar } from './BookSidebar'; import { bookArticles, filterBookArticles } from './docs-reading'; -import type { ResolvedBook } from './book-nav'; +import { bookSlug, labelUncategorized, pkgOfBook, resolveBookTree, type ResolvedBook } from './book-nav'; +import { useBookData } from './use-book-data'; /** One book of the column: its resolved spine and its URL segment. */ export interface DocsNavBook { @@ -128,3 +129,55 @@ export function DocsNav({
); } + +/** + * Every book of package `pkg`, resolved for the column (objectstack#35424): + * the reader's books, and those of an app's other docs pages. Empty with no + * package. + */ +export function usePackageDocsNavBooks(pkg: string | undefined): DocsNavBook[] { + const { t } = useObjectTranslation(); + const { books, authoredBooks, docs } = useBookData(); + const uncategorizedLabel = t('help.uncategorized', { defaultValue: 'Uncategorized' }); + return useMemo(() => { + if (!pkg) return []; + return books + .filter((b) => pkgOfBook(b) === pkg) + .map((b) => ({ + slug: bookSlug(b), + book: labelUncategorized(resolveBookTree(b, docs, undefined, authoredBooks), uncategorizedLabel), + })); + }, [books, authoredBooks, docs, pkg, uncategorizedLabel]); +} + +/** + * The column as the shell sidebar carries it (objectstack#37150): the same + * column, under its own navigation landmark. + */ +export function DocsNavLandmark({ children }: { children: ReactNode }) { + const { t } = useObjectTranslation(); + return ( + + ); +} + +/** + * The column of an app's docs page other than the reader (the app's docs + * index, a book with no articles, a book or doc not found): the app's books, + * the way back to the app and all documentation. The reader builds its own, + * from the book its article is in. + */ +export function AppDocsNav() { + const { appName, slug } = useParams<{ appName?: string; slug?: string }>(); + const books = usePackageDocsNavBooks(appName); + const backTo = useAppDocsBackTo(); + const docHref = useCallback( + (bookSegment: string, doc: string) => `/apps/${appName}/docs/${bookSegment}/${doc}`, + [appName], + ); + return ( + + ); +} diff --git a/ui/apps/console/src/pages/docs-portal.test.tsx b/ui/apps/console/src/pages/docs-portal.test.tsx index b1aa4ca0ad3..c2962ab9f4d 100644 --- a/ui/apps/console/src/pages/docs-portal.test.tsx +++ b/ui/apps/console/src/pages/docs-portal.test.tsx @@ -126,6 +126,9 @@ const { ADAPTER, WORLD, GATED_REASON } = vi.hoisted(() => { const PLATFORM_CONTENT: Record = { setup_overview: 'ADMIN BODY about permission sets' }; const WORLD = { authored: false, + // objectstack#37150 — the shell's page-header group is handed in (the + // console layout's scope, from 768 px up). + shellActions: false, conflict: false, exact: false, platform: false, @@ -163,6 +166,9 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({ useAdapter: () => ADAPTER, // The apps `/meta/app` serves this caller (objectstack#35424); none by default. useMetadata: () => ({ apps: WORLD.apps }), + // objectstack#37150 — the shell's top-right group, where the layout hands + // it in; outside the shell the real slot answers `null`. + useShellPageActionsSlot: () => (WORLD.shellActions ? () =>
: null), })); // A `{#id}` marker in a doc body stands for a heading with that anchor id. Like @@ -205,6 +211,7 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({ })); // Imported AFTER the mocks so the pages pick up the mocked modules. +import { SidebarDocsNavSlotProvider, SidebarDocsNavTarget } from '@object-ui/app-shell'; import DocsLayout from './DocsLayout'; import DocsIndex from './DocsIndex'; import DocsSlug from './DocsSlug'; @@ -955,3 +962,139 @@ describe('objectstack#35424 — 「All documentation」 groups its books by app expect(screen.getByTestId('where')).toHaveTextContent('/docs/manual/showcase_index'); }); }); + +describe('objectstack#37150 — from 768 px up an app\'s docs pages draw in the app shell', () => { + function Where() { + return
{useLocation().pathname}
; + } + /** + * The app routes' docs tree (`AppContent`) inside the shell's two docs + * places: the sidebar's body (`UnifiedSidebar` draws the target) and the + * page-header group (mocked above). + */ + function InShell({ entry }: { entry: string }) { + return ( + + + +
+ + + }> + } /> + } /> + } /> + + +
+
+
+ ); + } + const sidebar = () => screen.getByTestId('shell-sidebar'); + const page = () => screen.getByTestId('shell-route'); + + beforeEach(() => { + WORLD.shellActions = true; + }); + afterEach(() => { + WORLD.shellActions = false; + }); + + it('the reader\'s one docs column is the sidebar\'s body, not a column in the page', async () => { + render(); + await screen.findByTestId('doc-content'); + expect(screen.getAllByTestId('docs-nav')).toHaveLength(1); + const column = within(sidebar()).getByTestId('docs-nav'); + expect(within(sidebar()).getByRole('navigation', { name: 'Documentation navigation' })).toContainElement(column); + expect(within(column).getByTestId('docs-nav-back')).toHaveAttribute('href', '/apps/crm'); + expect(within(column).getByTestId('docs-nav-all-docs')).toHaveAttribute('href', '/docs'); + expect(within(column).getAllByRole('link', { name: 'CRM Intro' })[0]).toHaveAttribute('aria-current', 'page'); + expect(within(page()).queryByTestId('docs-nav')).toBeNull(); + expect(screen.queryByTestId('docs-back-bar')).toBeNull(); + }); + + it('the page header carries the shell\'s button group, as on every app page', async () => { + render(); + await screen.findByTestId('doc-content'); + expect(within(screen.getByTestId('docs-page-header')).getByTestId('shell-page-actions-stub')).toBeInTheDocument(); + }); + + // ADR-0046 section 6: docs are name-addressed and every URL that resolved + // keeps its answer; the shell changes the frame, never the address. + it.each([ + ['the reader', '/apps/crm/docs/crm/crm_intro'], + ['a book (lands on its first article)', '/apps/crm/docs/crm'], + ['a flat doc permalink (redirects into its book)', '/apps/crm/docs/crm_intro'], + ['the app\'s docs index (one book: lands on it)', '/apps/crm/docs'], + ])('%s, %s, reads the same article in the shell', async (_what, entry) => { + render(); + expect(await screen.findByTestId('doc-content')).toHaveTextContent('Welcome to the CRM'); + expect(screen.getByTestId('where')).toHaveTextContent('/apps/crm/docs/crm/crm_intro'); + expect(within(sidebar()).getByTestId('docs-nav')).toBeInTheDocument(); + expect(within(page()).queryByTestId('docs-nav')).toBeNull(); + }); + + it('a page that is not the reader carries the app\'s column in the sidebar, the way back first', async () => { + render(); + await screen.findByText(/not found/i); + const column = within(sidebar()).getByTestId('docs-nav'); + expect(within(column).getByTestId('docs-nav-back')).toHaveAttribute('href', '/apps/crm'); + expect(within(column).getAllByRole('button', { name: /crm/i })).toHaveLength(1); + expect(screen.queryByTestId('docs-back-bar')).toBeNull(); + expect(screen.getByTestId('docs-page-header')).toBeInTheDocument(); + }); + + describe('a package with several books', () => { + beforeEach(() => { + WORLD.authored = true; + }); + afterEach(() => { + WORLD.authored = false; + }); + + it('its docs index lists the books in the page and every book in the sidebar', async () => { + render(); + await within(page()).findByText('Leads Book'); + const column = within(sidebar()).getByTestId('docs-nav'); + expect(within(column).getByRole('button', { name: /Showcase Manual/ })).toBeInTheDocument(); + expect(within(column).getByRole('button', { name: /Leads Book/ })).toBeInTheDocument(); + expect(within(column).queryByRole('button', { name: /Alpha Manual/ })).toBeNull(); + }); + + // The package container's other URL forms (objectui#11197): a book NAME, + // a book NAME with its doc, and a segment that is both a doc's name and a + // book's name each land where they did, now in the shell. + it.each([ + ['a book NAME', '/apps/com.example.showcase/docs/showcase_manual', '/apps/com.example.showcase/docs/manual/showcase_index', 'INDEX BODY'], + ['a book NAME with its doc', '/apps/com.example.showcase/docs/showcase_manual/showcase_lead_guide', '/apps/com.example.showcase/docs/manual/showcase_lead_guide', 'LEAD BODY'], + ['a doc name that is also a book name (the doc permalink wins)', '/apps/com.example.showcase/docs/showcase_lead_guide', '/apps/com.example.showcase/docs/manual/showcase_lead_guide', 'LEAD BODY'], + ['the canonical SLUG/DOC', '/apps/com.example.showcase/docs/manual/showcase_lead_guide', '/apps/com.example.showcase/docs/manual/showcase_lead_guide', 'LEAD BODY'], + ])('%s, %s, lands on %s in the shell', async (_what, entry, where, body) => { + render(); + expect(await screen.findByTestId('doc-content')).toHaveTextContent(body); + expect(screen.getByTestId('where')).toHaveTextContent(where); + expect(within(sidebar()).getByTestId('docs-nav')).toBeInTheDocument(); + expect(within(page()).queryByTestId('docs-nav')).toBeNull(); + }); + }); + + it('CONTROL — without the shell\'s sidebar (a phone; the /docs portal) the page draws its column and its back link itself', async () => { + WORLD.shellActions = false; + render( + + + }> + } /> + + + , + ); + await screen.findByText(/not found/i); + expect(screen.getByTestId('docs-back-bar')).toBeInTheDocument(); + expect(screen.queryByTestId('docs-page-header')).toBeNull(); + expect(screen.queryByTestId('sidebar-docs-nav')).toBeNull(); + }); +}); diff --git a/ui/packages/app-shell/src/console/ConsoleBootShell.tsx b/ui/packages/app-shell/src/console/ConsoleBootShell.tsx index 5b4ef4be673..58c2fd7b732 100644 --- a/ui/packages/app-shell/src/console/ConsoleBootShell.tsx +++ b/ui/packages/app-shell/src/console/ConsoleBootShell.tsx @@ -11,7 +11,7 @@ * objectui#5619). Each used to draw the full-screen splash. They now draw * {@link ConsoleBootShell}: the chrome's frame (the sidebar at the width the * reader left it, with its head and foot from 768 px up; the 48 px top bar on - * a phone and on a docs page; the route slot) with grey blocks in it and + * a phone; the route slot) with grey blocks in it and * the skeleton of the route the URL names in the slot. The real chrome takes * its place when the gates pass, at the same geometry. * @@ -87,16 +87,17 @@ export function ConsoleBootShell() { // chrome lands. From 768 px up an app draws no top bar: the app menu, the // search and the bell sit in the sidebar's head and the account at its foot // (objectstack#36112). A phone keeps the bar, except on a record page, - // which draws its own (objectstack#28483). A docs page mounts no sidebar - // and keeps the bar at every width (objectstack#35424). + // which draws its own (objectstack#28483). An app's docs page is an app + // page like the others from 768 px up (objectstack#37150); on a phone it + // mounts no sidebar and keeps the bar (objectstack#35424). const phone = usePhoneViewport(); - const docsPage = isAppDocsPath(pathname); + const phoneDocsPage = phone && isAppDocsPath(pathname); const recordPageOwnsTopBar = phone && isRecordPagePath(pathname); - const desktopSidebar = !phone && !docsPage; + const desktopSidebar = !phone; return (
@@ -105,7 +106,7 @@ export function ConsoleBootShell() {
} sidebar={ - docsPage ? undefined : ( + phoneDocsPage ? undefined : ( {desktopSidebar && ( // Where the app menu (and the collapse button), the search and diff --git a/ui/packages/app-shell/src/console/__tests__/ConsoleBootShell-35981.test.tsx b/ui/packages/app-shell/src/console/__tests__/ConsoleBootShell-35981.test.tsx index bc7a43a354a..a1ff520c8cb 100644 --- a/ui/packages/app-shell/src/console/__tests__/ConsoleBootShell-35981.test.tsx +++ b/ui/packages/app-shell/src/console/__tests__/ConsoleBootShell-35981.test.tsx @@ -109,8 +109,9 @@ describe('the console boot fallback (objectstack#35981)', () => { // draws is taken away when the chrome lands: from 768 px up no top bar, // and the sidebar's head (app menu, search, bell) and foot (account) // (objectstack#36112); a phone keeps the bar, but not on a record page - // (objectstack#28483); a docs page has no sidebar and keeps the bar at - // every width (objectstack#35424). + // (objectstack#28483); an app's docs page is drawn like every other app + // page from 768 px up (objectstack#37150), and on a phone has no sidebar + // and keeps the bar (objectstack#35424). const width = window.innerWidth; const setWidth = (w: number) => Object.defineProperty(window, 'innerWidth', { value: w, configurable: true, writable: true }); @@ -120,7 +121,7 @@ describe('the console boot fallback (objectstack#35981)', () => { const foot = () => shell()!.querySelector('[data-boot-sidebar-foot]'); try { setWidth(1440); - for (const path of [RECORD, '/apps/crm/account', '/apps/crm/docsearch']) { + for (const path of [RECORD, '/apps/crm/account', '/apps/crm/docsearch', '/apps/crm/docs/manual/intro']) { at(path, ); expect(header(), path).toBeNull(); expect(sidebar(), path).not.toBeNull(); @@ -128,13 +129,16 @@ describe('the console boot fallback (objectstack#35981)', () => { expect(foot(), path).not.toBeNull(); cleanup(); } - for (const w of [1440, 375]) { - setWidth(w); - at('/apps/crm/docs/manual/intro', ); - expect(sidebar(), `docs @${w}`).toBeNull(); - expect(header(), `docs @${w}`).not.toBeNull(); - cleanup(); - } + setWidth(768); + at('/apps/crm/docs/manual/intro', ); + expect(header(), 'docs @768').toBeNull(); + expect(head(), 'docs @768').not.toBeNull(); + cleanup(); + setWidth(375); + at('/apps/crm/docs/manual/intro', ); + expect(sidebar(), 'docs @375').toBeNull(); + expect(header(), 'docs @375').not.toBeNull(); + cleanup(); setWidth(375); at(RECORD, ); diff --git a/ui/packages/app-shell/src/index.ts b/ui/packages/app-shell/src/index.ts index b84ac89e61b..fc5897709a5 100644 --- a/ui/packages/app-shell/src/index.ts +++ b/ui/packages/app-shell/src/index.ts @@ -97,6 +97,19 @@ export { type SidebarFooterSlotPlace, } from './layout/sidebarFooterSlot.js'; +// objectstack#37150 — the shell sidebar's place for an app's docs navigation, +// drawn by the console's docs pages (the provider and the target are the +// shell's side, mounted by `ConsoleLayout` and `UnifiedSidebar`); and the page +// header's two shell slots (the top-right button group and the sidebar's +// expand button), for a docs page, which draws no `ConsolePageHeader`. +export { + SidebarDocsNav, + SidebarDocsNavSlotProvider, + SidebarDocsNavTarget, + useSidebarDocsNavSlot, +} from './layout/sidebarDocsNavSlot.js'; +export { useShellPageActionsSlot, useShellSidebarExpandSlot } from './layout/shellPageActionsSlot.js'; + // Host-app route policy (ADR-0048) — which app's `/apps//…` URL a // framework-owned, app-INDEPENDENT page should build, and the two predicates it // is defined in terms of. Published from the package root (objectui#4280) diff --git a/ui/packages/app-shell/src/layout/ConsoleLayout.tsx b/ui/packages/app-shell/src/layout/ConsoleLayout.tsx index 10cfe56c2d9..c9ac8f25714 100644 --- a/ui/packages/app-shell/src/layout/ConsoleLayout.tsx +++ b/ui/packages/app-shell/src/layout/ConsoleLayout.tsx @@ -26,6 +26,7 @@ import { UnifiedSidebar } from './UnifiedSidebar.js'; import { PhoneAppNavBar, isPhoneTabRoute } from './PhoneAppNavBar.js'; import { PhoneAppHomeSlotProvider } from './PhoneAppHome.js'; import { PhonePageBarProvider } from './PhonePageBar.js'; +import { SidebarDocsNavSlotProvider } from './sidebarDocsNavSlot.js'; import { useLastApp } from '../context/LastAppProvider.js'; import { rememberAppReturnPage } from '../utils/appReturnPage.js'; import { useMetadata } from '../providers/MetadataProvider.js'; @@ -194,9 +195,15 @@ export function ConsoleLayout({ // the top left goes back. The route slot leaves the bar's height free at its // end. const phoneNavBar = phone && isPhoneTabRoute(location.pathname); - // objectstack#35424 — a docs page draws its own left column (the app's - // books and a way back to the app), so the app menu is not mounted there. + // objectstack#35424 — a docs page has one navigation, the docs' own (the + // app's books and a way back to the app), so the app's menu is not drawn + // there. objectstack#37150 (ruling 7142354097 on objectstack#36107) — from + // 768 px up the page still draws in the app shell like every other app page: + // the sidebar is mounted, its head and foot as everywhere, and its body + // carries the docs' navigation in the menu's place. A phone keeps what it + // had: no sidebar, the app bar, and the column in the page. const docsPage = isAppDocsPath(location.pathname); + const phoneDocsPage = phone && docsPage; // objectstack#35881 — the app this person last had open, where a phone // lands after sign-in. Recorded at every width: it is the person's last app. const { rememberApp } = useLastApp(); @@ -273,27 +280,31 @@ export function ConsoleLayout({ {/* objectstack#35883 — a page's own phone top row, drawn by the app bar. */} + {/* objectstack#37150 — the sidebar's place for an app's docs navigation, + shared by the sidebar (which holds it) and the docs page (which draws + its column into it). */} + ) } // objectstack#36112 — from 768 px up an app draws no top bar: the app // menu, search, bell and account are the sidebar's, the page's buttons - // its own header's. A phone keeps its bar (and its record page draws its - // own instead, objectstack#28483). An app's docs pages keep it at every - // width: they mount no sidebar (objectstack#35424), so the bar is still - // where their account, search and bell are. + // its own header's. An app's docs pages are no exception + // (objectstack#37150). A phone keeps its bar (and its record page draws + // its own instead, objectstack#28483). // // objectstack#36362 — while the design mode is on, its bar takes the // top slot instead, across the whole window, on every route. - showHeader={designMode.active || ((phone || docsPage) && !recordPageOwnsTopBar)} + showHeader={designMode.active || (phone && !recordPageOwnsTopBar)} navbar={ designMode.active ? ( @@ -345,7 +356,7 @@ export function ConsoleLayout({ {/* objectstack#36111 — the pages under the shell draw its top-right button group; objectstack#36112 — and the sidebar's expand button at their headers' left edge while it is collapsed. */} - + {/* ADR-0037: unmistakable watermark while rendering the draft overlay (?preview=draft) — with one-click exit and one-click Publish. */} {/* objectui#12463 — the banners sit in one non-shrinking box, so in @@ -355,8 +366,7 @@ export function ConsoleLayout({ (impersonation, read rate, storage) and the connection notice sit here, the content's width, since no top bar carries them. */} {!phone && } - {/* A docs page's bar draws the connection state itself. */} - {!phone && !docsPage && } + {!phone && } {/* ADR-0045: materialized-but-unlisted app — real and interactive, invisible to end users until the Publish visibility flip. */} @@ -398,6 +408,7 @@ export function ConsoleLayout({ {chatDock.sheet} + diff --git a/ui/packages/app-shell/src/layout/UnifiedSidebar.tsx b/ui/packages/app-shell/src/layout/UnifiedSidebar.tsx index 316bd7606f0..68c20d7ded9 100644 --- a/ui/packages/app-shell/src/layout/UnifiedSidebar.tsx +++ b/ui/packages/app-shell/src/layout/UnifiedSidebar.tsx @@ -103,6 +103,7 @@ import { electSidebarArea, type SidebarAreaRoute } from './sidebarAreaElection.j import type { FavoriteItem } from '../hooks/useFavorites.js'; import { usePhoneAppHomeSlot } from './PhoneAppHome.js'; import { useSidebarFooterSlot } from './sidebarFooterSlot.js'; +import { SidebarDocsNavTarget } from './sidebarDocsNavSlot.js'; /** * The app's menu as the design mode edits it (objectstack#36363). Loaded on @@ -186,6 +187,13 @@ interface UnifiedSidebarProps { * every width, collapsed to the primitive's icon rail. */ railOverlay?: boolean; + /** + * objectstack#37150 — the route is one of the app's documentation pages + * (`isAppDocsPath`): the body holds the docs' navigation, which the page + * draws into `SidebarDocsNavTarget`, in place of the app's menu and its + * recent items (objectstack#35424). The head and the foot are unchanged. + */ + docsNav?: boolean; } function isMetadataDirectoryItem(item: NavigationItem): boolean { @@ -203,7 +211,7 @@ function isOverviewGroup(item: NavigationItem): boolean { return id === 'overview' || label === 'overview'; } -export function UnifiedSidebar({ activeAppName, onAppChange, railOverlay = false }: UnifiedSidebarProps) { +export function UnifiedSidebar({ activeAppName, onAppChange, railOverlay = false, docsNav = false }: UnifiedSidebarProps) { const { isMobile, setOpenMobile } = useSidebar(); const location = useLocation(); const { t, language } = useObjectTranslation(); @@ -832,6 +840,12 @@ export function UnifiedSidebar({ activeAppName, onAppChange, railOverlay = false )} + {docsNav && context === 'app' && activeApp ? ( + // objectstack#37150 — an app's docs page: the docs' own navigation, + // drawn here by the page (it carries its own landmark). + + ) : ( + <> {/* The sidebar's one navigation landmark, so assistive tech can jump to it. The `Sidebar` primitive draws a plain `div` (and a dialog on a phone) and is Shadcn-synced, so the landmark rides inside its @@ -969,6 +983,8 @@ export function UnifiedSidebar({ activeAppName, onAppChange, railOverlay = false )} + + )} {shellChrome && ( diff --git a/ui/packages/app-shell/src/layout/__tests__/ConsoleLayout.noTopBar-36112.test.tsx b/ui/packages/app-shell/src/layout/__tests__/ConsoleLayout.noTopBar-36112.test.tsx index 5533bde6aa6..c4492563164 100644 --- a/ui/packages/app-shell/src/layout/__tests__/ConsoleLayout.noTopBar-36112.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/ConsoleLayout.noTopBar-36112.test.tsx @@ -5,8 +5,8 @@ * at the window's top, the standing banners and the connection notice sit at * the top of the content area, the page header carries the sidebar's expand * button while the sidebar is collapsed, and a route with no shell header gets - * that button at the content's corner. A phone keeps its bar, and so does an - * app's docs page, which mounts no sidebar. + * that button at the content's corner. A phone keeps its bar. An app's docs + * pages are no exception from 768 px up (objectstack#37150). * * Harness: the real `ConsoleLayout` with its real `@object-ui/layout` * `AppShell` and the real `ShellPageActionsScope`; the sidebar, the app bar @@ -106,8 +106,15 @@ describe('an app draws no top bar from 768 px up (objectstack#36112)', () => { } }); - it('control: an app\'s docs pages, which mount no sidebar, keep the bar at every width', () => { - mountAt('/apps/crm/docs/crm_manual', 1440,
Manual
); + it('an app\'s docs pages are no exception (objectstack#37150): the sidebar and no bar from 768 px up; a phone keeps the bar', () => { + for (const width of [768, 1440]) { + mountAt('/apps/crm/docs/crm_manual', width,
Manual
); + expect(document.querySelectorAll('header'), `${width} px`).toHaveLength(0); + expect(screen.queryByTestId('app-bar'), `${width} px`).toBeNull(); + expect(screen.getByTestId('sidebar-stub'), `${width} px`).toBeInTheDocument(); + cleanup(); + } + mountAt('/apps/crm/docs/crm_manual', 390,
Manual
); expect(screen.getByTestId('app-bar')).toBeInTheDocument(); expect(screen.queryByTestId('sidebar-stub')).toBeNull(); }); diff --git a/ui/packages/app-shell/src/layout/__tests__/ConsoleLayout.phoneRecordOneBar-28483.test.tsx b/ui/packages/app-shell/src/layout/__tests__/ConsoleLayout.phoneRecordOneBar-28483.test.tsx index 374057ac5a3..2c9da75ce5e 100644 --- a/ui/packages/app-shell/src/layout/__tests__/ConsoleLayout.phoneRecordOneBar-28483.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/ConsoleLayout.phoneRecordOneBar-28483.test.tsx @@ -31,7 +31,11 @@ vi.mock('../../hooks/useAiSurface', () => ({ useAiSurfaceEnabled: () => ({ enabled: false, isLoading: false }), })); vi.mock('../UnifiedSidebar', () => ({ - UnifiedSidebar: () =>