import { useState } from "react"; import { useQueryClient } from "@tanstack/react-query"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; import { SchemaTree } from "@/components/schema/SchemaTree"; import { HistoryPanel } from "@/components/history/HistoryPanel"; import { SavedQueriesPanel } from "@/components/saved-queries/SavedQueriesPanel"; import { AdminPanel } from "@/components/management/AdminPanel"; import { Search, RefreshCw, Layers, Clock, Bookmark, Shield } from "lucide-react"; type SidebarView = "schema" | "history" | "saved" | "admin"; const SCHEMA_QUERY_KEYS = [ "databases", "schemas", "tables", "views", "functions", "sequences", "completionSchema", "column-details", ]; const SIDEBAR_TABS: { id: SidebarView; label: string; icon: React.ReactNode }[] = [ { id: "schema", label: "Schema", icon: }, { id: "history", label: "History", icon: }, { id: "saved", label: "Saved", icon: }, { id: "admin", label: "Admin", icon: }, ]; export function Sidebar() { const [view, setView] = useState("schema"); const [search, setSearch] = useState(""); const queryClient = useQueryClient(); const handleRefreshSchema = () => { for (const key of SCHEMA_QUERY_KEYS) { queryClient.invalidateQueries({ queryKey: [key] }); } }; return ( {/* Sidebar navigation tabs */} {SIDEBAR_TABS.map((tab) => ( setView(tab.id)} > {tab.icon} {tab.label} ))} {view === "schema" ? ( <> setSearch(e.target.value)} /> Refresh schema > ) : view === "history" ? ( ) : view === "saved" ? ( ) : ( )} ); }