// // SPDX-FileCopyrightText: Copyright (c) 1993-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // "use client" import { Download, Maximize, Minimize, CuboidIcon, LayoutGrid, Database, Search as SearchIcon, Settings, Zap, HelpCircle } from "lucide-react" import { Button } from "@/components/ui/button" import { Switch } from "@/components/ui/switch" import { Label } from "@/components/ui/label" import { Input } from "@/components/ui/input" import { Separator } from "@/components/ui/separator" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, DropdownMenuSeparator, } from "@/components/ui/dropdown-menu" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip" interface GraphToolbarProps { // View controls use3D: boolean onToggle3D: () => void isFullscreen: boolean onToggleFullscreen: () => void // Layout controls layoutType: "force" | "hierarchical" | "radial" onLayoutChange: (layout: "force" | "hierarchical" | "radial") => void // Data controls includeStoredTriples: boolean onToggleStoredTriples: (enabled: boolean) => void storedTriplesCount: number loadingStoredTriples: boolean // Export onExport: (format: "json" | "csv" | "png") => void // Search searchTerm: string onSearchChange: (term: string) => void onSearch: () => void searchInputRef?: React.RefObject // Stats nodeCount: number edgeCount: number } export function GraphToolbar({ use3D, onToggle3D, isFullscreen, onToggleFullscreen, layoutType, onLayoutChange, includeStoredTriples, onToggleStoredTriples, storedTriplesCount, loadingStoredTriples, onExport, searchTerm, onSearchChange, onSearch, searchInputRef, nodeCount, edgeCount }: GraphToolbarProps) { return (
{/* Primary Actions Group */}
Switch to {use3D ? '2D' : '3D'} view {isFullscreen ? "Exit fullscreen" : "Enter fullscreen"}
{/* Layout Controls Group */}
Layout:
{[ { key: "force", label: "Force", icon: null }, { key: "hierarchical", label: "Tree", icon: null }, { key: "radial", label: "Radial", icon: null } ].map((layout) => ( {layout.label} layout ))}
{/* Data Source Controls */}
Include stored triples from database ({storedTriplesCount} available)
{/* Stats (on larger screens) */}
{nodeCount} nodes {edgeCount} edges
{/* Search */}
onSearchChange(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') { e.preventDefault() onSearch() } }} className="pl-10 h-8 text-sm" />
{/* Secondary Actions - Right Side */}
{/* Export Dropdown */} Export graph data onExport("json")}> Export as JSON onExport("csv")}> Export as CSV onExport("png")}> Export as PNG {/* Help/Shortcuts */}
Keyboard Shortcuts:
FFullscreen
3Toggle 3D
Ctrl+KSearch
1Force layout
2Tree layout
Shift+3Radial layout
) }