From 1931f9208b16c221b0ff5abf1500c01b244df445 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sat, 28 Feb 2026 13:55:30 +0100 Subject: [PATCH] Workspace editing --- src/components/sidebar/AppSidebar.tsx | 81 +++++++++++++++++++++++---- 1 file changed, 70 insertions(+), 11 deletions(-) diff --git a/src/components/sidebar/AppSidebar.tsx b/src/components/sidebar/AppSidebar.tsx index aecb03a..2caa1b1 100644 --- a/src/components/sidebar/AppSidebar.tsx +++ b/src/components/sidebar/AppSidebar.tsx @@ -34,7 +34,11 @@ import { import { ChevronDown } from "lucide-react"; import { Route, SetState, Workspace } from "@/lib/types"; -import { listWorkspaces, saveWorkspaceToLocalStorage } from "@/lib/workspace"; +import { + listWorkspaces, + saveWorkspaceToLocalStorage, + createDefaultWorkspace, +} from "@/lib/workspace"; import { openFileDialog } from "@/lib/import"; // Simple ID generator @@ -79,6 +83,9 @@ export default function AppSidebar({ const [isRenameOpen, setIsRenameOpen] = React.useState(false); const [proposedName, setProposedName] = React.useState(workspace.name); + const [isWorkspaceCreateOpen, setIsWorkspaceCreateOpen] = + React.useState(false); + const [newWorkspaceName, setNewWorkspaceName] = React.useState(""); const [isCreateOpen, setIsCreateOpen] = React.useState(false); const [createMode, setCreateMode] = React.useState<"list" | "doc" | "group">( "list", @@ -168,16 +175,19 @@ export default function AppSidebar({ className="w-[--radix-popper-anchor-width]" > {/* list all known workspaces */} - {availableWorkspaces.map((w) => ( + {[ + availableWorkspaces.find((w) => w.id === workspace.id), + ...availableWorkspaces.filter((w) => w.id !== workspace.id), + ].map((w) => ( switchWorkspace(w.id)} + onSelect={() => w && switchWorkspace(w?.id)} > - {w.name} - {w.id === workspace.id ? " (current)" : ""} + {w?.name} + {w?.id === workspace.id ? " (current)" : ""} ))} @@ -209,16 +219,23 @@ export default function AppSidebar({ New group (root) - - Import Workspace - - setIsRenameOpen(true)}> Rename Workspace + + Import Workspace + Export Workspace + { + setNewWorkspaceName("New workspace"); + setIsWorkspaceCreateOpen(true); + }} + > + Create workspace + @@ -279,6 +296,48 @@ export default function AppSidebar({ + {/* create workspace dialog */} + + + + Create workspace + + Provide a name for the workspace. + + + setNewWorkspaceName(e.target.value)} + className="w-full" + /> + + + + + + {/* create dialog */}