Testing functionality of the workspace storing and receiving

This commit is contained in:
2026-02-27 21:37:42 +01:00
parent 1a51dc8467
commit 3c17c73390
6 changed files with 86 additions and 26 deletions
+10 -3
View File
@@ -16,14 +16,16 @@ import {
DropdownMenuTrigger,
} from "../ui/dropdown-menu";
import { ChevronDown } from "lucide-react";
import { Workspace } from "@/hooks/workspace";
import { EntityId, SetState, Workspace } from "@/lib/types";
export default function AppSidebar({
children,
workspace,
setRoute,
}: Readonly<{
children: React.ReactNode;
workspace: Workspace;
setRoute: SetState<EntityId | undefined>;
}>) {
return (
<SidebarProvider>
@@ -51,8 +53,13 @@ export default function AppSidebar({
</SidebarHeader>
<SidebarContent>
<SidebarMenu>
{workspace.entityLayout.map((entity, i) => (
<EntitySwitch entity={entity} workspace={workspace} key={i} />
{workspace.layout.map((entity, i) => (
<EntitySwitch
entity={entity}
workspace={workspace}
key={i}
setRoute={setRoute}
/>
))}
</SidebarMenu>
</SidebarContent>
+10 -3
View File
@@ -9,7 +9,7 @@ import {
} from "../ui/sidebar";
import { Collapsible, CollapsibleContent } from "../ui/collapsible";
import { ChevronDown } from "lucide-react";
import { Workspace } from "@/hooks/workspace";
import { EntityId, SetState, Workspace } from "@/lib/types";
export type SidebarEntity =
| {
@@ -25,9 +25,11 @@ export type SidebarEntity =
export default function EntitySwitch({
entity,
workspace,
setRoute,
}: {
entity: SidebarEntity;
workspace: Workspace;
setRoute: SetState<EntityId | undefined>;
}) {
if (entity.kind === "group") {
return (
@@ -45,7 +47,12 @@ export default function EntitySwitch({
<SidebarGroupContent>
<SidebarMenu>
{entity.children?.map((entity, i) => (
<EntitySwitch entity={entity} workspace={workspace} key={i} />
<EntitySwitch
entity={entity}
workspace={workspace}
key={i}
setRoute={setRoute}
/>
))}
</SidebarMenu>
</SidebarGroupContent>
@@ -58,7 +65,7 @@ export default function EntitySwitch({
<SidebarMenuItem>
<SidebarMenuButton
onClick={() => {
workspace.setRoute(entity.id);
setRoute(entity.id);
}}
>
{workspace.entities[entity.id].name}