From e71b481dbb7b0a1fd79fa294a5ac73449bb1966d Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sat, 28 Feb 2026 14:06:00 +0100 Subject: [PATCH] Context menu sidebar --- src/components/sidebar/AppSidebar.tsx | 12 +++- src/components/sidebar/Entity.tsx | 99 ++++++++++++++------------- 2 files changed, 60 insertions(+), 51 deletions(-) diff --git a/src/components/sidebar/AppSidebar.tsx b/src/components/sidebar/AppSidebar.tsx index 2caa1b1..0b77f91 100644 --- a/src/components/sidebar/AppSidebar.tsx +++ b/src/components/sidebar/AppSidebar.tsx @@ -164,10 +164,10 @@ export default function AppSidebar({ - + Create workspace + { + localStorage.removeItem(workspace.id); + }} + variant="destructive" + > + Delete workspace + diff --git a/src/components/sidebar/Entity.tsx b/src/components/sidebar/Entity.tsx index cfc1993..0cc5ba5 100644 --- a/src/components/sidebar/Entity.tsx +++ b/src/components/sidebar/Entity.tsx @@ -30,6 +30,13 @@ import { import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { useState } from "react"; +import { + ContextMenu, + ContextMenuContent, + ContextMenuItem, + ContextMenuSeparator, + ContextMenuTrigger, +} from "../ui/context-menu"; type Props = { node: LayoutNode; @@ -58,7 +65,6 @@ export default function EntitySwitch({ removeNode, renameGroup, }: Props) { - const [menuOpen, setMenuOpen] = useState(false); const [dialogOpen, setDialogOpen] = useState(false); const [dialogValue, setDialogValue] = useState(""); const [dialogMode, setDialogMode] = useState< @@ -74,7 +80,6 @@ export default function EntitySwitch({ setDialogValue(initial); } setDialogOpen(true); - setMenuOpen(false); }; const handleDialogSubmit = () => { @@ -100,32 +105,30 @@ export default function EntitySwitch({
- - - {node.name} - - - - - - - - - openDialog("add-item")}> + + + + + {node.name} + + + + + + openDialog("add-item")}> Add list - - openDialog("add-group")}> + + openDialog("add-group")}> Add group - - - + + openDialog("rename-group", node.name)} > Rename - - + { if ( window.confirm("Delete this group and its children?") @@ -135,9 +138,9 @@ export default function EntitySwitch({ }} > Delete - - - + + +
@@ -209,29 +212,27 @@ export default function EntitySwitch({ return (
- - setRoute({ - workspace: workspace.id, - entity: node.entityId, - }) - } - > - {workspaceEntity.name} - - - - - - - + + + setRoute({ + workspace: workspace.id, + entity: node.entityId, + }) + } + > + {workspaceEntity.name} + + + + openDialog("rename-item", workspaceEntity.name)} > Rename - - + { if (window.confirm("Delete this list?")) { deleteEntity(node.entityId); @@ -239,9 +240,9 @@ export default function EntitySwitch({ }} > Delete - - - + + +
);