Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

refactor(erp): one module sidebar, owned by the shell

Sidwebworksca8dc5885efa
diff --git a/.claude/skills/carbon-design/references/page-archetypes.md b/.claude/skills/carbon-design/references/page-archetypes.md
index 56db520adc..30fb72c52b 100644
--- a/.claude/skills/carbon-design/references/page-archetypes.md
+++ b/.claude/skills/carbon-design/references/page-archetypes.md
@@ -54,6 +54,13 @@ unless they start with `apps/` or `packages/`.
Both set `handle.module` so the rail stays highlighted. A detail route nested under a module
folder hides the sub-nav with `handle.hideModuleSidebar` (`utils/handle.ts`).
+There is ONE sub-nav, owned by the shell (`ModuleSidebarLayout`, rendered in `x+/_layout.tsx`).
+A module `_layout.tsx` does not render a sidebar: it names its sub-nav component on the route
+handle (`handle.sidebar`, a small component that calls `use{Module}Submodules` and returns
+`<GroupedContentSidebar groups={groups} />`) and its default export is only the page column.
+The frame, its width and its collapsed state therefore persist from module to module; only the
+links change.
+
## 3. Archetype A — Module list page
```
diff --git a/apps/erp/app/components/Layout/Navigation/CollapsibleSidebar.tsx b/apps/erp/app/components/Layout/Navigation/CollapsibleSidebar.tsx
index e13a313686..2edec1e019 100644
--- a/apps/erp/app/components/Layout/Navigation/CollapsibleSidebar.tsx
+++ b/apps/erp/app/components/Layout/Navigation/CollapsibleSidebar.tsx
@@ -23,9 +23,10 @@ import {
} from "react";
import { LuPanelLeft } from "react-icons/lu";
import type { Location } from "react-router";
-import { useLocation, useNavigation } from "react-router";
+import { useLocation, useMatches, useNavigation } from "react-router";
import { useOptimisticLocation } from "~/hooks";
import { useUIStore } from "~/stores/ui";
+import type { Handle } from "~/utils/handle";
interface CollapsibleSidebarContextValue {
hasSidebar: boolean;
@@ -46,7 +47,10 @@ export function useCollapsibleSidebar() {
return context;
}
-export function CollapsibleSidebarProvider({ children }: PropsWithChildren) {
+function CollapsibleSidebarProvider({
+ hasSidebar,
+ children
+}: PropsWithChildren<{ hasSidebar: boolean }>) {
const isMobile = useIsMobile();
const isSidebarOpen = useUIStore((state) => state.isSidebarOpen);
const setSidebarOpen = useUIStore((state) => state.setSidebarOpen);
@@ -55,9 +59,8 @@ export function CollapsibleSidebarProvider({ children }: PropsWithChildren) {
(state) => state.setHasContentSidebar
);
- // Every module layout mounts its own provider. Opening on mount undid a
- // collapse on each module change, and on a phone opened the drawer for a
- // frame before closing it, so only a change of breakpoint moves it.
+ // Only a change of breakpoint moves it: opening on mount would undo the
+ // user's collapse, and on a phone open the drawer for a frame.
const wasMobile = useRef(false);
useEffect(() => {
if (isMobile) setSidebarOpen(false);
@@ -66,16 +69,16 @@ export function CollapsibleSidebarProvider({ children }: PropsWithChildren) {
}, [isMobile, setSidebarOpen]);
// Tell the (global) Topbar that this route has a content sub-nav, so it can
- // surface a mobile "Sections" trigger. Cleared when the module unmounts.
+ // surface a mobile "Sections" trigger.
useEffect(() => {
- setHasContentSidebar(true);
+ setHasContentSidebar(hasSidebar);
return () => setHasContentSidebar(false);
- }, [setHasContentSidebar]);
+ }, [hasSidebar, setHasContentSidebar]);
return (
<CollapsibleSidebarContext.Provider
value={{
- hasSidebar: true,
+ hasSidebar,
isOpen: isSidebarOpen,
onToggle: toggleSidebar
}}
@@ -123,7 +126,43 @@ export function useSidebarLocation(isInside: (pathname: string) => boolean) {
return pending && isInside(pending.pathname) ? pending : current;
}
-export const CollapsibleSidebar = ({
+/**
+ * The one module sidebar, rendered by the app shell around every page. A
+ * module layout names its sub-navigation on its route handle (`sidebar`) and
+ * the shell renders it here, so the sidebar's frame, width and collapsed
+ * state stay put from module to module and only its links change. Pages
+ * outside a module (detail pages) have none and get the full width.
+ */
+export function ModuleSidebarLayout({ children }: PropsWithChildren) {
+ const matches = useMatches();
+ const handles = matches.map((match) => match.handle as Handle | undefined);
+ const Sidebar = handles.some((handle) => handle?.hideModuleSidebar)
+ ? undefined
+ : handles.find((handle) => handle?.sidebar)?.sidebar;
+
+ return (
+ <CollapsibleSidebarProvider hasSidebar={Boolean(Sidebar)}>
+ {/* `contents` when there is no sidebar: the page lays out exactly as if
+ this wrapper were not here, and stays in the same place in the tree. */}
+ <div
+ className={
+ Sidebar
+ ? "grid grid-cols-[auto_minmax(0,1fr)] w-full h-full"
+ : "contents"
+ }
+ >
+ {Sidebar ? (
+ <CollapsibleSidebar>
+ <Sidebar />
+ </CollapsibleSidebar>
+ ) : null}
+ {children}
+ </div>
+ </CollapsibleSidebarProvider>
+ );
+}
+
+const CollapsibleSidebar = ({
children,
width = 240
}: PropsWithChildren<{ width?: number }>) => {
@@ -182,7 +221,9 @@ export const CollapsibleSidebar = ({
return (
<motion.div
animate={isOpen ? "visible" : "hidden"}
- initial={shouldReduceMotion ? false : variants.visible}
+ // No enter animation: arriving from a page without a sidebar must not
+ // replay the collapse.
+ initial={false}
transition={
shouldReduceMotion
? { duration: 0 }
diff --git a/apps/erp/app/components/Layout/Navigation/ContentSidebar.tsx b/apps/erp/app/components/Layout/Navigation/ContentSidebar.tsx
index b5fc717e32..ba6c6e3e51 100644
--- a/apps/erp/app/components/Layout/Navigation/ContentSidebar.tsx
+++ b/apps/erp/app/components/Layout/Navigation/ContentSidebar.tsx
@@ -6,7 +6,7 @@ import { Button, VStack } from "@carbon/react";
import { Link } from "react-router";
import { useUrlParams } from "~/hooks";
import type { Route } from "~/types";
-import { CollapsibleSidebar, useSidebarLocation } from "./CollapsibleSidebar";
+import { useSidebarLocation } from "./CollapsibleSidebar";
const ContentSidebar = ({ links }: { links: Route[] }) => {
const location = useSidebarLocation((pathname) =>
@@ -16,34 +16,32 @@ const ContentSidebar = ({ links }: { links: Route[] }) => {
const filter = params.get("q") ?? undefined;
return (
- <CollapsibleSidebar>
- <div className="overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent h-full w-full pb-8">
- <VStack>
- <VStack spacing={1} className="p-2">
- {links.map((route) => {
- const isActive =
- location.pathname.includes(route.to) && route.q === filter;
- return (
- <Button
- key={route.name}
- asChild
- leftIcon={route.icon}
- variant={isActive ? "active" : "ghost"}
- className="w-full justify-start"
+ <div className="overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent h-full w-full pb-8">
+ <VStack>
+ <VStack spacing={1} className="p-2">
+ {links.map((route) => {
+ const isActive =
+ location.pathname.includes(route.to) && route.q === filter;
+ return (
+ <Button
+ key={route.name}
+ asChild
+ leftIcon={route.icon}
+ variant={isActive ? "active" : "ghost"}
+ className="w-full justify-start"
+ >
+ <Link
+ to={route.to + (route.q ? `?q=${route.q}` : "")}
+ prefetch="intent"
>
- <Link
- to={route.to + (route.q ? `?q=${route.q}` : "")}
- prefetch="intent"
- >
- {route.name}
- </Link>
- </Button>
- );
- })}
- </VStack>
+ {route.name}
+ </Link>
+ </Button>
+ );
+ })}
</VStack>
- </div>
- </CollapsibleSidebar>
+ </VStack>
+ </div>
);
};
diff --git a/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsx b/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsx
index c9a01dd80b..e9287410e9 100644
--- a/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsx
+++ b/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsx
@@ -30,7 +30,7 @@ import { Link, useSubmit } from "react-router";
import { ConfirmDelete } from "~/components/Modals";
import type { RouteGroup } from "~/types";
import { path } from "~/utils/path";
-import { CollapsibleSidebar, useSidebarLocation } from "./CollapsibleSidebar";
+import { useSidebarLocation } from "./CollapsibleSidebar";
type GroupedRoute = RouteGroup["routes"][number];
@@ -47,11 +47,9 @@ const matchesRoute = (
const GroupedContentSidebar = ({
groups,
- width = 240,
exactMatch = false
}: {
groups: RouteGroup[];
- width?: number;
exactMatch?: boolean;
}) => {
const { t } = useLingui();
@@ -92,7 +90,7 @@ const GroupedContentSidebar = ({
};
return (
- <CollapsibleSidebar width={width}>
+ <>
<div className="overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent h-full w-full pb-8">
<VStack>
{groups.map((group) => (
@@ -191,7 +189,7 @@ const GroupedContentSidebar = ({
}}
/>
)}
- </CollapsibleSidebar>
+ </>
);
};
diff --git a/apps/erp/app/components/Layout/Navigation/index.ts b/apps/erp/app/components/Layout/Navigation/index.ts
index dd4374a7b0..ed71c9fcfc 100644
--- a/apps/erp/app/components/Layout/Navigation/index.ts
+++ b/apps/erp/app/components/Layout/Navigation/index.ts
@@ -3,9 +3,8 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import {
- CollapsibleSidebar,
- CollapsibleSidebarProvider,
- CollapsibleSidebarTrigger
+ CollapsibleSidebarTrigger,
+ ModuleSidebarLayout
} from "./CollapsibleSidebar";
import ContentSidebar from "./ContentSidebar";
import DetailSidebar from "./DetailSidebar";
@@ -14,12 +13,11 @@ import GroupedContentSidebar from "./GroupedContentSidebar";
import PrimaryNavigation from "./PrimaryNavigation";
export {
- CollapsibleSidebar,
- CollapsibleSidebarProvider,
CollapsibleSidebarTrigger,
ContentSidebar,
DetailSidebar,
DetailsTopbar,
GroupedContentSidebar,
+ ModuleSidebarLayout,
PrimaryNavigation
};
diff --git a/apps/erp/app/components/Layout/index.ts b/apps/erp/app/components/Layout/index.ts
index 8aeef7463a..5ed7924d53 100644
--- a/apps/erp/app/components/Layout/index.ts
+++ b/apps/erp/app/components/Layout/index.ts
@@ -5,11 +5,11 @@
import Background from "./Background";
import {
- CollapsibleSidebar,
ContentSidebar,
DetailSidebar,
DetailsTopbar,
GroupedContentSidebar,
+ ModuleSidebarLayout,
PrimaryNavigation
} from "./Navigation";
import { PanelProvider, ResizablePanels, usePanels } from "./Panels";
@@ -18,11 +18,11 @@ import Topbar from "./Topbar";
export {
Background,
- CollapsibleSidebar,
ContentSidebar,
DetailSidebar,
DetailsTopbar,
GroupedContentSidebar,
+ ModuleSidebarLayout,
PanelProvider,
PrimaryNavigation,
ResizablePanels,
diff --git a/apps/erp/app/routes/x+/_layout.tsx b/apps/erp/app/routes/x+/_layout.tsx
index 589f97a63b..6f2bbbbc44 100644
--- a/apps/erp/app/routes/x+/_layout.tsx
+++ b/apps/erp/app/routes/x+/_layout.tsx
@@ -64,7 +64,11 @@ import {
} from "react-router";
import { RealtimeDataProvider } from "~/components";
import ChangelogPanel from "~/components/ChangelogPanel";
-import { PrimaryNavigation, Topbar } from "~/components/Layout";
+import {
+ ModuleSidebarLayout,
+ PrimaryNavigation,
+ Topbar
+} from "~/components/Layout";
import MfaEnrollmentRequired from "~/components/MfaEnrollmentRequired";
import SessionLockOverlay from "~/components/SessionLockOverlay";
import ShortcutHelp from "~/components/ShortcutHelp";
@@ -537,7 +541,9 @@ export default function AuthenticatedRoute() {
<div className="flex flex-1 flex-col min-w-0 overflow-hidden bg-card md:mt-2 md:mr-2 md:mb-2 md:rounded-2xl md:border md:border-border shadow-md relative z-10">
<Topbar />
<main className="flex-1 overflow-y-auto scrollbar-hide relative">
- <Outlet />
+ <ModuleSidebarLayout>
+ <Outlet />
+ </ModuleSidebarLayout>
</main>
</div>
</SidebarProvider>
diff --git a/apps/erp/app/routes/x+/account+/_layout.tsx b/apps/erp/app/routes/x+/account+/_layout.tsx
index ea54153abe..af1353b2ae 100644
--- a/apps/erp/app/routes/x+/account+/_layout.tsx
+++ b/apps/erp/app/routes/x+/account+/_layout.tsx
@@ -7,7 +7,6 @@ import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
import { Outlet } from "react-router";
import { GroupedContentSidebar } from "~/components/Layout";
-import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
import useAccountSubmodules from "~/modules/account/ui/useAccountSubmodules";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -16,31 +15,27 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | My Account" }];
};
+function AccountSidebar() {
+ const { groups } = useAccountSubmodules();
+ return <GroupedContentSidebar groups={groups} />;
+}
+
export const handle: Handle = {
breadcrumb: msg`Account`,
to: path.to.profile,
- module: "account"
+ module: "account",
+ sidebar: AccountSidebar
};
export default function AccountRoute() {
- const { groups } = useAccountSubmodules();
-
return (
- <CollapsibleSidebarProvider>
- <div className="grid grid-cols-[auto_minmax(0,1fr)] w-full h-full bg-card">
- <GroupedContentSidebar groups={groups} />
- <VStack
- spacing={0}
- className="overflow-y-auto scrollbar-hide h-[calc(100dvh-var(--topbar-height)-var(--content-inset))]"
- >
- <VStack
- spacing={4}
- className="py-12 px-4 max-w-[60rem] h-full mx-auto"
- >
- <Outlet />
- </VStack>
- </VStack>
- </div>
- </CollapsibleSidebarProvider>
+ <VStack
+ spacing={0}
+ className="overflow-y-auto scrollbar-hide h-[calc(100dvh-var(--topbar-height)-var(--content-inset))]"
+ >
+ <VStack spacing={4} className="py-12 px-4 max-w-[60rem] h-full mx-auto">
+ <Outlet />
+ </VStack>
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/accounting+/_layout.tsx b/apps/erp/app/routes/x+/accounting+/_layout.tsx
index 7c5ed807fa..62a18f651d 100644
--- a/apps/erp/app/routes/x+/accounting+/_layout.tsx
+++ b/apps/erp/app/routes/x+/accounting+/_layout.tsx
@@ -16,7 +16,6 @@ import type {
} from "react-router";
import { Outlet, redirect } from "react-router";
import { GroupedContentSidebar } from "~/components/Layout";
-import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
import {
getAccountsList,
getBaseCurrency,
@@ -31,10 +30,16 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | Accounting" }];
};
+function AccountingSidebar() {
+ const { groups } = useAccountingSubmodules();
+ return <GroupedContentSidebar groups={groups} />;
+}
+
export const handle: Handle = {
breadcrumb: msg`Accounting`,
to: path.to.accounting,
- module: "accounting"
+ module: "accounting",
+ sidebar: AccountingSidebar
};
export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
@@ -83,17 +88,10 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function AccountingRoute() {
- const { groups } = useAccountingSubmodules();
-
return (
- <CollapsibleSidebarProvider>
- <div className="grid grid-cols-[auto_minmax(0,1fr)] w-full h-full bg-card">
- <GroupedContentSidebar groups={groups} />
- <VStack spacing={0} className="relative h-full">
- <Outlet />
- <AccountingBetaGate />
- </VStack>
- </div>
- </CollapsibleSidebarProvider>
+ <VStack spacing={0} className="relative h-full">
+ <Outlet />
+ <AccountingBetaGate />
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/documents+/_layout.tsx b/apps/erp/app/routes/x+/documents+/_layout.tsx
index 89cfc9a770..8f0cd480e2 100644
--- a/apps/erp/app/routes/x+/documents+/_layout.tsx
+++ b/apps/erp/app/routes/x+/documents+/_layout.tsx
@@ -6,10 +6,7 @@ import { VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
import { Outlet } from "react-router";
-import {
- CollapsibleSidebarProvider,
- ContentSidebar
-} from "~/components/Layout/Navigation";
+import { ContentSidebar } from "~/components/Layout/Navigation";
import { useDocumentsSubmodules } from "~/modules/documents";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -18,23 +15,22 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | Documents" }];
};
+function DocumentsSidebar() {
+ const { links } = useDocumentsSubmodules();
+ return <ContentSidebar links={links} />;
+}
+
export const handle: Handle = {
breadcrumb: msg`Documents`,
to: path.to.documents,
- module: "documents"
+ module: "documents",
+ sidebar: DocumentsSidebar
};
export default function DocumentsRoute() {
- const { links } = useDocumentsSubmodules();
-
return (
- <CollapsibleSidebarProvider>
- <div className="grid grid-cols-[auto_minmax(0,1fr)] w-full h-full">
- <ContentSidebar links={links} />
- <VStack spacing={0} className="h-full">
- <Outlet />
- </VStack>
- </div>
- </CollapsibleSidebarProvider>
+ <VStack spacing={0} className="h-full">
+ <Outlet />
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/get-started+/_layout.tsx b/apps/erp/app/routes/x+/get-started+/_layout.tsx
index 8f1603af06..54731670f6 100644
--- a/apps/erp/app/routes/x+/get-started+/_layout.tsx
+++ b/apps/erp/app/routes/x+/get-started+/_layout.tsx
@@ -44,7 +44,6 @@ import {
useNavigate
} from "react-router";
import { GroupedContentSidebar } from "~/components/Layout";
-import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
import { useSettings, useUser } from "~/hooks";
import {
setCustomerPreview,
@@ -133,9 +132,15 @@ const resolveVideoUrl = (videoKey: string): string | undefined => {
return video?.academyUrl ?? video?.videoUrl;
};
+function GetStartedSidebar() {
+ const { groups } = useImplementationSubmodules();
+ return <GroupedContentSidebar groups={groups} exactMatch />;
+}
+
export const handle: Handle = {
breadcrumb: msg`Get Started`,
- to: path.to.getStarted
+ to: path.to.getStarted,
+ sidebar: GetStartedSidebar
};
export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
@@ -177,7 +182,6 @@ export default function GetStartedLayout() {
(settings as { accountingEnabled?: boolean }).accountingEnabled ?? false;
const previewingAsCustomer = useCustomerPreview();
useImplementationRealtime(company.id);
- const { groups } = useImplementationSubmodules();
const loaderData = useLoaderData<typeof loader>();
const fetcher = useFetcher();
@@ -258,29 +262,22 @@ export default function GetStartedLayout() {
);
return (
- <CollapsibleSidebarProvider>
- <div className="bg-card grid grid-cols-[auto_minmax(0,1fr)] grid-rows-[minmax(0,1fr)] w-full h-full overflow-hidden">
- <GroupedContentSidebar groups={groups} exactMatch />
- <div className="relative min-w-0 overflow-hidden bg-card">
- <div ref={scrollRef} className="relative z-10 h-full overflow-y-auto">
- {isInternal ? (
- <PreviewBar previewing={previewingAsCustomer} />
- ) : null}
- <div className="p-8">
- <HubProvider
- data={hubData}
- flags={flags}
- dispatch={dispatch}
- resolveScreenUrl={resolveScreenUrl}
- resolveVideoUrl={resolveVideoUrl}
- >
- <Outlet />
- </HubProvider>
- </div>
- </div>
+ <div className="relative min-w-0 h-[calc(100dvh-var(--topbar-height)-var(--content-inset))] overflow-hidden bg-card">
+ <div ref={scrollRef} className="relative z-10 h-full overflow-y-auto">
+ {isInternal ? <PreviewBar previewing={previewingAsCustomer} /> : null}
+ <div className="p-8">
+ <HubProvider
+ data={hubData}
+ flags={flags}
+ dispatch={dispatch}
+ resolveScreenUrl={resolveScreenUrl}
+ resolveVideoUrl={resolveVideoUrl}
+ >
+ <Outlet />
+ </HubProvider>
</div>
</div>
- </CollapsibleSidebarProvider>
+ </div>
);
}
diff --git a/apps/erp/app/routes/x+/inventory+/_layout.tsx b/apps/erp/app/routes/x+/inventory+/_layout.tsx
index 663e32d7a2..f77d08a133 100644
--- a/apps/erp/app/routes/x+/inventory+/_layout.tsx
+++ b/apps/erp/app/routes/x+/inventory+/_layout.tsx
@@ -13,7 +13,6 @@ import type {
} from "react-router";
import { Outlet } from "react-router";
import { GroupedContentSidebar } from "~/components/Layout";
-import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
import { useInventorySubmodules } from "~/modules/inventory";
import { getUnitOfMeasuresList } from "~/modules/items";
import { getLocationsList } from "~/modules/resources";
@@ -24,10 +23,16 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | Inventory" }];
};
+function InventorySidebar() {
+ const { groups } = useInventorySubmodules();
+ return <GroupedContentSidebar groups={groups} />;
+}
+
export const handle: Handle = {
breadcrumb: msg`Inventory`,
to: path.to.inventory,
- module: "inventory"
+ module: "inventory",
+ sidebar: InventorySidebar
};
export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
@@ -50,16 +55,9 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function InventoryRoute() {
- const { groups } = useInventorySubmodules();
-
return (
- <CollapsibleSidebarProvider>
- <div className="grid grid-cols-[auto_minmax(0,1fr)] w-full h-full">
- <GroupedContentSidebar groups={groups} />
- <VStack spacing={0} className="h-full">
- <Outlet />
- </VStack>
- </div>
- </CollapsibleSidebarProvider>
+ <VStack spacing={0} className="h-full">
+ <Outlet />
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/invoicing+/_layout.tsx b/apps/erp/app/routes/x+/invoicing+/_layout.tsx
index 777314c593..bcc83a381f 100644
--- a/apps/erp/app/routes/x+/invoicing+/_layout.tsx
+++ b/apps/erp/app/routes/x+/invoicing+/_layout.tsx
@@ -13,7 +13,6 @@ import type {
} from "react-router";
import { Outlet } from "react-router";
import { GroupedContentSidebar } from "~/components/Layout";
-import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
import useInvoicingSubmodules from "~/modules/invoicing/ui/useInvoicingSubmodules";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -22,10 +21,16 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | Invoicing" }];
};
+function InvoicingSidebar() {
+ const { groups } = useInvoicingSubmodules();
+ return <GroupedContentSidebar groups={groups} />;
+}
+
export const handle: Handle = {
breadcrumb: msg`Invoicing`,
to: path.to.invoicing,
- module: "invoicing"
+ module: "invoicing",
+ sidebar: InvoicingSidebar
};
export const shouldRevalidate: ShouldRevalidateFunction = (args) =>
@@ -40,16 +45,9 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function InvoicingRoute() {
- const { groups } = useInvoicingSubmodules();
-
return (
- <CollapsibleSidebarProvider>
- <div className="grid grid-cols-[auto_minmax(0,1fr)] w-full h-full">
- <GroupedContentSidebar groups={groups} />
- <VStack spacing={0} className="h-full">
- <Outlet />
- </VStack>
- </div>
- </CollapsibleSidebarProvider>
+ <VStack spacing={0} className="h-full">
+ <Outlet />
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/items+/_layout.tsx b/apps/erp/app/routes/x+/items+/_layout.tsx
index 0f108880ef..1ca64eb745 100644
--- a/apps/erp/app/routes/x+/items+/_layout.tsx
+++ b/apps/erp/app/routes/x+/items+/_layout.tsx
@@ -5,9 +5,8 @@
import { VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
-import { Outlet, useMatches } from "react-router";
+import { Outlet } from "react-router";
import { GroupedContentSidebar } from "~/components/Layout";
-import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
import useItemsSubmodules from "~/modules/items/ui/useItemsSubmodules";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -16,35 +15,22 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | Items" }];
};
+function ItemsSidebar() {
+ const { groups } = useItemsSubmodules();
+ return <GroupedContentSidebar groups={groups} />;
+}
+
export const handle: Handle = {
breadcrumb: msg`Items`,
to: path.to.parts,
- module: "items"
+ module: "items",
+ sidebar: ItemsSidebar
};
export default function PartsRoute() {
- const { groups } = useItemsSubmodules();
- // A full-screen detail view (the change-order workspace) can opt out of the
- // module sidebar via its route handle so we don't stack two left sidebars.
- const matches = useMatches();
- const hideSidebar = matches.some(
- (m) => (m.handle as Handle | undefined)?.hideModuleSidebar
- );
-
return (
- <CollapsibleSidebarProvider>
- <div
- className={
- hideSidebar
- ? "w-full h-full"
- : "grid grid-cols-[auto_minmax(0,1fr)] w-full h-full"
- }
- >
- {!hideSidebar && <GroupedContentSidebar groups={groups} />}
- <VStack spacing={0} className="h-full">
- <Outlet />
- </VStack>
- </div>
- </CollapsibleSidebarProvider>
+ <VStack spacing={0} className="h-full">
+ <Outlet />
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/people+/_layout.tsx b/apps/erp/app/routes/x+/people+/_layout.tsx
index eeae5f6fa4..dd196a7a48 100644
--- a/apps/erp/app/routes/x+/people+/_layout.tsx
+++ b/apps/erp/app/routes/x+/people+/_layout.tsx
@@ -7,7 +7,6 @@ import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
import { Outlet } from "react-router";
import { GroupedContentSidebar } from "~/components/Layout";
-import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
import usePeopleSubmodules from "~/modules/people/ui/usePeopleSubmodules";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -16,23 +15,22 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | People" }];
};
+function PeopleSidebar() {
+ const { groups } = usePeopleSubmodules();
+ return <GroupedContentSidebar groups={groups} />;
+}
+
export const handle: Handle = {
breadcrumb: msg`People`,
to: path.to.people,
- module: "people"
+ module: "people",
+ sidebar: PeopleSidebar
};
export default function PeopleRoute() {
- const { groups } = usePeopleSubmodules();
-
return (
- <CollapsibleSidebarProvider>
- <div className="grid grid-cols-[auto_minmax(0,1fr)] w-full h-full">
- <GroupedContentSidebar groups={groups} />
- <VStack spacing={0} className="h-full">
- <Outlet />
- </VStack>
- </div>
- </CollapsibleSidebarProvider>
+ <VStack spacing={0} className="h-full">
+ <Outlet />
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/production+/_layout.tsx b/apps/erp/app/routes/x+/production+/_layout.tsx
index 91fcc8f1d3..735fac7d50 100644
--- a/apps/erp/app/routes/x+/production+/_layout.tsx
+++ b/apps/erp/app/routes/x+/production+/_layout.tsx
@@ -7,7 +7,6 @@ import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
import { Outlet } from "react-router";
import { GroupedContentSidebar } from "~/components/Layout";
-import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
import useProductionSubmodules from "~/modules/production/ui/useProductionSubmodules";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -16,23 +15,22 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | Production" }];
};
+function ProductionSidebar() {
+ const { groups } = useProductionSubmodules();
+ return <GroupedContentSidebar groups={groups} />;
+}
+
export const handle: Handle = {
breadcrumb: msg`Production`,
to: path.to.production,
- module: "production"
+ module: "production",
+ sidebar: ProductionSidebar
};
export default function ProductionRoute() {
- const { groups } = useProductionSubmodules();
-
return (
- <CollapsibleSidebarProvider>
- <div className="grid grid-cols-[auto_minmax(0,1fr)] w-full h-full">
- <GroupedContentSidebar groups={groups} />
- <VStack spacing={0} className="h-full">
- <Outlet />
- </VStack>
- </div>
- </CollapsibleSidebarProvider>
+ <VStack spacing={0} className="h-full">
+ <Outlet />
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/purchasing+/_layout.tsx b/apps/erp/app/routes/x+/purchasing+/_layout.tsx
index d9732a1520..a759f449cf 100644
--- a/apps/erp/app/routes/x+/purchasing+/_layout.tsx
+++ b/apps/erp/app/routes/x+/purchasing+/_layout.tsx
@@ -7,7 +7,6 @@ import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
import { Outlet } from "react-router";
import { GroupedContentSidebar } from "~/components/Layout";
-import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
import usePurchasingSubmodules from "~/modules/purchasing/ui/usePurchasingSubmodules";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -16,23 +15,22 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | Purchasing" }];
};
+function PurchasingSidebar() {
+ const { groups } = usePurchasingSubmodules();
+ return <GroupedContentSidebar groups={groups} />;
+}
+
export const handle: Handle = {
breadcrumb: msg`Purchasing`,
to: path.to.purchasing,
- module: "purchasing"
+ module: "purchasing",
+ sidebar: PurchasingSidebar
};
export default function UsersRoute() {
- const { groups } = usePurchasingSubmodules();
-
return (
- <CollapsibleSidebarProvider>
- <div className="grid grid-cols-[auto_minmax(0,1fr)] w-full h-full">
- <GroupedContentSidebar groups={groups} />
- <VStack spacing={0} className="h-full">
- <Outlet />
- </VStack>
- </div>
- </CollapsibleSidebarProvider>
+ <VStack spacing={0} className="h-full">
+ <Outlet />
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/quality+/_layout.tsx b/apps/erp/app/routes/x+/quality+/_layout.tsx
index 98dd664fa6..013ae1f80b 100644
--- a/apps/erp/app/routes/x+/quality+/_layout.tsx
+++ b/apps/erp/app/routes/x+/quality+/_layout.tsx
@@ -7,7 +7,6 @@ import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
import { Outlet } from "react-router";
import { GroupedContentSidebar } from "~/components/Layout";
-import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
import useQualitySubmodules from "~/modules/quality/ui/useQualitySubmodules";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -16,23 +15,22 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | Quality" }];
};
+function QualitySidebar() {
+ const { groups } = useQualitySubmodules();
+ return <GroupedContentSidebar groups={groups} />;
+}
+
export const handle: Handle = {
breadcrumb: msg`Quality`,
to: path.to.quality,
- module: "quality"
+ module: "quality",
+ sidebar: QualitySidebar
};
export default function QualityRoute() {
- const { groups } = useQualitySubmodules();
-
return (
- <CollapsibleSidebarProvider>
- <div className="grid grid-cols-[auto_minmax(0,1fr)] w-full h-full">
- <GroupedContentSidebar groups={groups} />
- <VStack spacing={0} className="h-full">
- <Outlet />
- </VStack>
- </div>
- </CollapsibleSidebarProvider>
+ <VStack spacing={0} className="h-full">
+ <Outlet />
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/resources+/_layout.tsx b/apps/erp/app/routes/x+/resources+/_layout.tsx
index f199aea755..3f7006bd3d 100644
--- a/apps/erp/app/routes/x+/resources+/_layout.tsx
+++ b/apps/erp/app/routes/x+/resources+/_layout.tsx
@@ -7,7 +7,6 @@ import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
import { Outlet } from "react-router";
import { GroupedContentSidebar } from "~/components/Layout";
-import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
import { useResourcesSubmodules } from "~/modules/resources";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -16,23 +15,22 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | Resources" }];
};
+function ResourcesSidebar() {
+ const { groups } = useResourcesSubmodules();
+ return <GroupedContentSidebar groups={groups} />;
+}
+
export const handle: Handle = {
breadcrumb: msg`Resources`,
to: path.to.resources,
- module: "resources"
+ module: "resources",
+ sidebar: ResourcesSidebar
};
export default function ResourcesRoute() {
- const { groups } = useResourcesSubmodules();
-
return (
- <CollapsibleSidebarProvider>
- <div className="grid grid-cols-[auto_minmax(0,1fr)] w-full h-full">
- <GroupedContentSidebar groups={groups} />
- <VStack spacing={0} className="h-full">
- <Outlet />
- </VStack>
- </div>
- </CollapsibleSidebarProvider>
+ <VStack spacing={0} className="h-full">
+ <Outlet />
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/sales+/_layout.tsx b/apps/erp/app/routes/x+/sales+/_layout.tsx
index f724ae5cc7..2b68f9170a 100644
--- a/apps/erp/app/routes/x+/sales+/_layout.tsx
+++ b/apps/erp/app/routes/x+/sales+/_layout.tsx
@@ -7,7 +7,6 @@ import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
import { Outlet } from "react-router";
import { GroupedContentSidebar } from "~/components/Layout";
-import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
import useSalesSubmodules from "~/modules/sales/ui/useSalesSubmodules";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -16,23 +15,22 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | Sales" }];
};
+function SalesSidebar() {
+ const { groups } = useSalesSubmodules();
+ return <GroupedContentSidebar groups={groups} />;
+}
+
export const handle: Handle = {
breadcrumb: msg`Sales`,
to: path.to.sales,
- module: "sales"
+ module: "sales",
+ sidebar: SalesSidebar
};
export default function SalesRoute() {
- const { groups } = useSalesSubmodules();
-
return (
- <CollapsibleSidebarProvider>
- <div className="grid grid-cols-[auto_minmax(0,1fr)] w-full h-full">
- <GroupedContentSidebar groups={groups} />
- <VStack spacing={0} className="h-full">
- <Outlet />
- </VStack>
- </div>
- </CollapsibleSidebarProvider>
+ <VStack spacing={0} className="h-full">
+ <Outlet />
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/settings+/_layout.tsx b/apps/erp/app/routes/x+/settings+/_layout.tsx
index bb4c1356f9..77c74359b4 100644
--- a/apps/erp/app/routes/x+/settings+/_layout.tsx
+++ b/apps/erp/app/routes/x+/settings+/_layout.tsx
@@ -7,7 +7,6 @@ import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
import { Outlet } from "react-router";
import { GroupedContentSidebar } from "~/components/Layout";
-import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
import { useSettingsSubmodules } from "~/modules/settings";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -16,26 +15,25 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | Settings" }];
};
+function SettingsSidebar() {
+ const { groups } = useSettingsSubmodules();
+ return <GroupedContentSidebar groups={groups} />;
+}
+
export const handle: Handle = {
breadcrumb: msg`Settings`,
to: path.to.company,
- module: "settings"
+ module: "settings",
+ sidebar: SettingsSidebar
};
export default function SettingsRoute() {
- const { groups } = useSettingsSubmodules();
-
return (
- <CollapsibleSidebarProvider>
- <div className="grid grid-cols-[auto_minmax(0,1fr)] w-full h-full bg-card">
- <GroupedContentSidebar groups={groups} />
- <VStack
- spacing={0}
- className="overflow-y-auto scrollbar-hide h-[calc(100dvh-var(--topbar-height)-var(--content-inset))]"
- >
- <Outlet />
- </VStack>
- </div>
- </CollapsibleSidebarProvider>
+ <VStack
+ spacing={0}
+ className="overflow-y-auto scrollbar-hide h-[calc(100dvh-var(--topbar-height)-var(--content-inset))]"
+ >
+ <Outlet />
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/users+/_layout.tsx b/apps/erp/app/routes/x+/users+/_layout.tsx
index 1e41f23a8c..7e58482c01 100644
--- a/apps/erp/app/routes/x+/users+/_layout.tsx
+++ b/apps/erp/app/routes/x+/users+/_layout.tsx
@@ -7,7 +7,6 @@ import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
import { Outlet } from "react-router";
import { GroupedContentSidebar } from "~/components/Layout";
-import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
import { useUsersSubmodules } from "~/modules/users";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -16,23 +15,22 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | Users" }];
};
+function UsersSidebar() {
+ const { groups } = useUsersSubmodules();
+ return <GroupedContentSidebar groups={groups} />;
+}
+
export const handle: Handle = {
breadcrumb: msg`Users`,
to: path.to.employeeAccounts,
- module: "users"
+ module: "users",
+ sidebar: UsersSidebar
};
export default function UsersRoute() {
- const { groups } = useUsersSubmodules();
-
return (
- <CollapsibleSidebarProvider>
- <div className="grid grid-cols-[auto_minmax(0,1fr)] w-full h-full">
- <GroupedContentSidebar groups={groups} />
- <VStack spacing={0} className="h-full">
- <Outlet />
- </VStack>
- </div>
- </CollapsibleSidebarProvider>
+ <VStack spacing={0} className="h-full">
+ <Outlet />
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/workflows+/_layout.tsx b/apps/erp/app/routes/x+/workflows+/_layout.tsx
index 96ff4c85f0..7a5c071d26 100644
--- a/apps/erp/app/routes/x+/workflows+/_layout.tsx
+++ b/apps/erp/app/routes/x+/workflows+/_layout.tsx
@@ -7,7 +7,6 @@ import { msg } from "@lingui/core/macro";
import type { MetaFunction } from "react-router";
import { Outlet } from "react-router";
import { GroupedContentSidebar } from "~/components/Layout";
-import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";
import useWorkflowsSubmodules from "~/modules/workflows/ui/useWorkflowsSubmodules";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -16,23 +15,22 @@ export const meta: MetaFunction = () => {
return [{ title: "Carbon | Workflows" }];
};
+function WorkflowsSidebar() {
+ const { groups } = useWorkflowsSubmodules();
+ return <GroupedContentSidebar groups={groups} />;
+}
+
export const handle: Handle = {
breadcrumb: msg`Workflows`,
to: path.to.workflows,
- module: "workflows"
+ module: "workflows",
+ sidebar: WorkflowsSidebar
};
export default function WorkflowsRoute() {
- const { groups } = useWorkflowsSubmodules();
-
return (
- <CollapsibleSidebarProvider>
- <div className="grid grid-cols-[auto_minmax(0,1fr)] w-full h-full">
- <GroupedContentSidebar groups={groups} />
- <VStack spacing={0} className="h-full">
- <Outlet />
- </VStack>
- </div>
- </CollapsibleSidebarProvider>
+ <VStack spacing={0} className="h-full">
+ <Outlet />
+ </VStack>
);
}
diff --git a/apps/erp/app/utils/handle.ts b/apps/erp/app/utils/handle.ts
index c1a98d80ec..e13f44e88e 100644
--- a/apps/erp/app/utils/handle.ts
+++ b/apps/erp/app/utils/handle.ts
@@ -3,14 +3,17 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import type { MessageDescriptor } from "@lingui/core";
-import type { ReactNode } from "react";
+import type { ComponentType, ReactNode } from "react";
export type Handle = {
breadcrumb?: any;
to?: string;
module?: string;
- // When true, a module _layout hides its GroupedContentSidebar for this route —
- // used by full-screen detail views that provide their own left panel (e.g. the
+ // A module layout's sub-navigation. The shell renders it in the one module
+ // sidebar (`ModuleSidebarLayout`), so it stays in place across modules.
+ sidebar?: ComponentType;
+ // When true, the module sidebar is hidden for this route — used by
+ // full-screen detail views that provide their own left panel (e.g. the
// change-order workspace) so the app doesn't stack two left sidebars.
hideModuleSidebar?: boolean;
};