import type { Torrent, TorrentAction } from './shared'; import { ChevronsDown, ChevronsUp, CircleCheckBig, FolderInput, Pause, Play, Plus, RefreshCw, Search, Settings2, Rabbit, Tag, Trash2, Turtle, X, } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'; // Actions above the list. Everything acts on the current selection except Add and the turtle toggle; with // nothing selected the selection-scoped buttons are disabled rather than silently acting on all torrents, // which is the single most destructive mistake a torrent client UI can make. type TorrentToolbarProps = { selected: Torrent[]; search: string; onSearch: (value: string) => void; onAct: (action: TorrentAction) => void; onAdd: () => void; onRemove: () => void; onMove: () => void; onLabels: () => void; onOptions: () => void; /** Session alt-speed ("turtle mode"), which is global rather than per-torrent. */ altSpeed: boolean; onToggleAltSpeed: () => void; total: number; shown: number; }; export const TorrentToolbar = ({ selected, search, onSearch, onAct, onAdd, onRemove, onMove, onLabels, onOptions, altSpeed, onToggleAltSpeed, total, shown, }: TorrentToolbarProps) => { const none = selected.length === 0; // "Start" and "Pause" are offered by what the selection can actually do, so a paused selection doesn't // show a live Pause button that would be a no-op. const anyStopped = selected.some((t) => t.status === 0); const anyRunning = selected.some((t) => t.status !== 0); return (