ubiquitous-invention/apps/web/components/sidebar/workspace-switcher.tsx
Randall Stillwell a508ece6e7 feat: Full project management application scaffold
Complete architecture for a ClickUp/Notion/Miro-class project management app:

- Turborepo monorepo with Next.js 15, TypeScript, PostgreSQL (Drizzle ORM)
- Object-centered database schema (everything is an Object: tasks, projects, docs, whiteboards)
- NextAuth v5 authentication with credentials + OAuth providers
- tRPC v11 API layer with full CRUD for objects, properties, relations, templates, search
- Three-panel UI: collapsible sidebar, center content area, push-in right panel
- Purple/teal theme with light/dark mode via Shadcn/ui + Tailwind CSS
- Multiple views: List, Kanban board (dnd-kit), Table (spreadsheet), Embedded iframe
- TipTap rich text editor with slash commands, custom blocks (callout, toggle, mention, embed, divider), AI block
- Real-time collaboration via Yjs + Hocuspocus with presence/cursors
- tldraw whiteboard with custom shape cards (task, document, project)
- MCP server exposing all app data/tools for AI agents
- AI chat panel, editor AI slash commands, Cmd+K command palette
- Template system with built-in templates (Bug Report, Meeting Notes, Sprint)
- Full-text search with result highlighting
- Docker Compose for full-stack deployment (web + collab + postgres + redis)

Made-with: Cursor
2026-03-26 22:39:16 -05:00

124 lines
3.5 KiB
TypeScript

"use client";
import { Building2, Check, Plus } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip";
import {
useWorkspaceStore,
type WorkspaceInfo,
} from "@/lib/stores/workspace-store";
import { cn } from "@/lib/utils";
const MOCK_WORKSPACES: WorkspaceInfo[] = [
{
id: "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",
slug: "personal",
name: "Personal",
},
{
id: "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb",
slug: "team-alpha",
name: "Team Alpha",
},
{
id: "cccccccc-cccc-4ccc-8ccc-cccccccccccc",
slug: "acme",
name: "Acme Corp",
},
];
export function WorkspaceSwitcher({
collapsed,
className,
}: {
collapsed?: boolean;
className?: string;
}) {
const current = useWorkspaceStore((s) => s.currentWorkspace);
const setWorkspace = useWorkspaceStore((s) => s.setWorkspace);
const display =
current ??
MOCK_WORKSPACES[0] ??
({ id: "", slug: "", name: "Workspace" } satisfies WorkspaceInfo);
const trigger = (
<Button
type="button"
variant="ghost"
className={cn(
"h-auto min-h-9 w-full justify-start gap-2 rounded-md px-2 py-1.5 text-left font-semibold text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
collapsed && "justify-center px-0",
className,
)}
>
<Building2 className="size-4 shrink-0 text-primary" />
{!collapsed ? (
<span className="min-w-0 flex-1 truncate text-sm">{display.name}</span>
) : null}
</Button>
);
return (
<div className={cn("min-w-0", collapsed && "flex justify-center")}>
<DropdownMenu>
{collapsed ? (
<Tooltip delayDuration={0}>
<TooltipTrigger asChild>
<DropdownMenuTrigger asChild>{trigger}</DropdownMenuTrigger>
</TooltipTrigger>
<TooltipContent side="right">{display.name}</TooltipContent>
</Tooltip>
) : (
<DropdownMenuTrigger asChild className="min-w-0 flex-1">
{trigger}
</DropdownMenuTrigger>
)}
<DropdownMenuContent className="w-56" align="start" side="bottom">
<DropdownMenuLabel className="text-xs font-normal text-muted-foreground">
Workspaces
</DropdownMenuLabel>
{MOCK_WORKSPACES.map((ws) => {
const selected = display.id === ws.id;
return (
<DropdownMenuItem
key={ws.id}
className="gap-2"
onClick={() => setWorkspace(ws)}
>
<Building2 className="size-4 shrink-0 opacity-70" />
<span className="flex-1 truncate">{ws.name}</span>
{selected ? (
<Check className="size-4 shrink-0 text-primary" />
) : null}
</DropdownMenuItem>
);
})}
<DropdownMenuSeparator />
<DropdownMenuItem
className="gap-2 text-muted-foreground focus:text-foreground"
onClick={() => {
// Conductor: wire create workspace flow
}}
>
<Plus className="size-4" />
Create Workspace
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
);
}