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.

feat: separate views in inventory by type

Brad Barbind1216e1cf287
diff --git a/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsx b/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsx
index 5d2e42eb0e..0a19f66a37 100644
--- a/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsx
+++ b/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsx
@@ -1,4 +1,11 @@
-import { Button, cn, VStack } from "@carbon/react";
+import {
+ Button,
+ cn,
+ SidebarMenuSub,
+ SidebarMenuSubButton,
+ SidebarMenuSubItem,
+ VStack,
+} from "@carbon/react";
import { Link } from "@remix-run/react";
import { useOptimisticLocation } from "~/hooks";
import type { RouteGroup } from "~/types";
@@ -30,26 +37,48 @@ const GroupedContentSidebar = ({
{group.routes.map((route) => {
const isActive = exactMatch
? location.pathname === route.to
- : location.pathname.includes(route.to);
+ : location.pathname.includes(route.to) &&
+ !route.groups?.some((subRoute) =>
+ `${location.pathname}${location.search}`.includes(
+ subRoute.to
+ )
+ );
return (
- <Button
- key={route.name}
- asChild
- leftIcon={route.icon}
- variant={isActive ? "active" : "ghost"}
- className={cn(
- "w-full justify-start truncate",
- !isActive &&
- "hover:bg-active hover:text-active-foreground"
- )}
- >
- <Link
- to={route.to + (route.q ? `?q=${route.q}` : "")}
- prefetch="intent"
+ <div className="w-full flex flex-col" key={route.name}>
+ <Button
+ asChild
+ leftIcon={route.icon}
+ variant={isActive ? "active" : "ghost"}
+ className={cn(
+ "w-full justify-start truncate",
+ !isActive &&
+ "hover:bg-active hover:text-active-foreground"
+ )}
>
- {route.name}
- </Link>
- </Button>
+ <Link
+ to={route.to + (route.q ? `?q=${route.q}` : "")}
+ prefetch="intent"
+ >
+ {route.name}
+ </Link>
+ </Button>
+ {route.groups && (
+ <SidebarMenuSub>
+ {route.groups.map((subRoute) => (
+ <SidebarMenuSubItem key={subRoute.name}>
+ <SidebarMenuSubButton
+ asChild
+ isActive={`${location.pathname}${location.search}`.includes(
+ subRoute.to
+ )}
+ >
+ <Link to={subRoute.to}>{subRoute.name}</Link>
+ </SidebarMenuSubButton>
+ </SidebarMenuSubItem>
+ ))}
+ </SidebarMenuSub>
+ )}
+ </div>
);
})}
</VStack>
diff --git a/apps/carbon/app/modules/inventory/ui/useInventorySubmodules.tsx b/apps/carbon/app/modules/inventory/ui/useInventorySubmodules.tsx
index ce6533869f..2e285eb41b 100644
--- a/apps/carbon/app/modules/inventory/ui/useInventorySubmodules.tsx
+++ b/apps/carbon/app/modules/inventory/ui/useInventorySubmodules.tsx
@@ -12,6 +12,38 @@ const inventoryRoutes: AuthenticatedRouteGroup[] = [
to: path.to.inventory,
role: "employee",
icon: <LuBox />,
+ groups: [
+ {
+ name: "Parts",
+ to: `${path.to.inventory}?filter=${encodeURIComponent(
+ "type:eq:Part"
+ )}`,
+ },
+ {
+ name: "Materials",
+ to: `${path.to.inventory}?filter=${encodeURIComponent(
+ "type:eq:Material"
+ )}`,
+ },
+ {
+ name: "Tools",
+ to: `${path.to.inventory}?filter=${encodeURIComponent(
+ "type:eq:Tool"
+ )}`,
+ },
+ {
+ name: "Fixtures",
+ to: `${path.to.inventory}?filter=${encodeURIComponent(
+ "type:eq:Fixture"
+ )}`,
+ },
+ {
+ name: "Consumables",
+ to: `${path.to.inventory}?filter=${encodeURIComponent(
+ "type:eq:Consumable"
+ )}`,
+ },
+ ],
},
// {
// name: "Receipts",
diff --git a/apps/carbon/app/types/index.ts b/apps/carbon/app/types/index.ts
index 6c658ecaba..1b3416eea8 100644
--- a/apps/carbon/app/types/index.ts
+++ b/apps/carbon/app/types/index.ts
@@ -56,6 +56,7 @@ export type Route = {
to: string;
icon?: any;
q?: string; // TODO: this is dumb
+ groups?: Omit<Route, "groups">[];
};
export type RouteGroup = {
diff --git a/packages/react/src/Sidebar.tsx b/packages/react/src/Sidebar.tsx
index dbab0d2d16..9bae374397 100644
--- a/packages/react/src/Sidebar.tsx
+++ b/packages/react/src/Sidebar.tsx
@@ -691,7 +691,7 @@ const SidebarMenuSub = React.forwardRef<
ref={ref}
data-sidebar="menu-sub"
className={cn(
- "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5",
+ "text-sm mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5",
"group-data-[collapsible=icon]:hidden",
className
)}
@@ -728,6 +728,7 @@ const SidebarMenuSubButton = React.forwardRef<
size === "sm" && "text-xs",
size === "md" && "text-sm",
"group-data-[collapsible=icon]:hidden",
+ isActive && "bg-active text-active-foreground",
className
)}
{...props}