import { AppShell as ShellLayout, type Crumb } from "@refs/design-system"; import { useRouteLoaderData, useSubmit } from "react-router"; import type { loader as rootLoader } from "../root"; import { PendingView, under, useIntendedPath } from "./pending"; export { AuthPage, PageHeader } from "@refs/design-system"; /** * The app frame around a page. `keeps` is the path a layout inside this frame stays on screen for; a navigation * under it is that layout's to show, and every other one replaces the whole page. */ export function AppShell({ crumbs, subnav, keeps, full, children }: { crumbs?: Crumb[]; subnav?: React.ReactNode; keeps?: string; full?: boolean; children: React.ReactNode }) { const root = useRouteLoaderData("root"); const pathname = useIntendedPath(); const submit = useSubmit(); const state = { org: root?.org ?? "", namespace: root?.namespace ?? null, namespaces: root?.namespaces ?? [], showWaitlist: root?.can.reviewWaitlist ?? false, user: root?.user ?? null, showMembers: root?.can.manageMembers ?? false, showSecrets: root?.can.manageCiSecrets ?? false, showLabels: root?.can.manageLabels ?? false, pathname, onSignOut: () => submit(null, { method: "post", action: "/logout" }), onSwitchNamespace: (namespace: string) => submit({ namespace }, { method: "post", action: "/switch" }), }; return ( !keeps || !under(to, keeps)}> {children} ); }