'use client'; import { ProcessInfo } from '@/lib/supervisor/types'; import { useStartProcess, useStopProcess, useRestartProcess } from '@/lib/hooks/useSupervisor'; import { Button } from '@/components/ui/button'; import { Card } from '@/components/ui/card'; import { Play, Square, RotateCw, X } from 'lucide-react'; import { cn } from '@/lib/utils/cn'; interface BatchActionsProps { selectedProcesses: Set; processes: ProcessInfo[]; onClearSelection: () => void; } export function BatchActions({ selectedProcesses, processes, onClearSelection }: BatchActionsProps) { const startMutation = useStartProcess(); const stopMutation = useStopProcess(); const restartMutation = useRestartProcess(); const isLoading = startMutation.isPending || stopMutation.isPending || restartMutation.isPending; const selectedCount = selectedProcesses.size; if (selectedCount === 0) return null; const handleStartSelected = async () => { for (const processId of selectedProcesses) { startMutation.mutate({ name: processId }); } onClearSelection(); }; const handleStopSelected = async () => { for (const processId of selectedProcesses) { stopMutation.mutate({ name: processId }); } onClearSelection(); }; const handleRestartSelected = async () => { for (const processId of selectedProcesses) { restartMutation.mutate(processId); } onClearSelection(); }; return (
{selectedCount}
{selectedCount} {selectedCount === 1 ? 'process' : 'processes'} selected
); }