All checks were successful
Build and Push Docker Image to Gitea / build-and-push (push) Successful in 59s
Features added:
- Multi-select functionality for processes with checkboxes
- Floating BatchActions toolbar appears when processes are selected
- Batch operations: Start Selected, Stop Selected, Restart Selected
- Select All / Deselect All button in processes page
- Visual feedback with ring indicator on selected cards
- Click card to toggle selection, buttons prevent card selection
Implementation details:
- Created batch API routes: /api/supervisor/processes/{start-all,stop-all,restart-all}
- Added React Query hooks: useStartAllProcesses, useStopAllProcesses, useRestartAllProcesses
- Created BatchActions component with floating toolbar
- Enhanced ProcessCard with optional selection mode (isSelected, onSelectionChange props)
- Updated processes page with selection state management
- Checkbox prevents event bubbling to avoid conflicts with action buttons
UX improvements:
- Selected cards show primary ring with offset
- BatchActions toolbar slides up from bottom
- Selection count displayed in toolbar
- Clear selection with X button or after batch action completes
Phase 3 complete (4-6 hours estimated)
111 lines
3.3 KiB
TypeScript
111 lines
3.3 KiB
TypeScript
'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<string>;
|
|
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 (
|
|
<div className="fixed bottom-6 left-1/2 -translate-x-1/2 z-50 animate-slide-up">
|
|
<Card className="shadow-2xl border-2">
|
|
<div className="flex items-center gap-4 px-6 py-4">
|
|
<div className="flex items-center gap-2">
|
|
<div className="h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center">
|
|
<span className="text-sm font-bold text-primary">{selectedCount}</span>
|
|
</div>
|
|
<span className="text-sm font-medium">
|
|
{selectedCount} {selectedCount === 1 ? 'process' : 'processes'} selected
|
|
</span>
|
|
</div>
|
|
|
|
<div className="h-6 w-px bg-border" />
|
|
|
|
<div className="flex gap-2">
|
|
<Button
|
|
variant="success"
|
|
size="sm"
|
|
onClick={handleStartSelected}
|
|
disabled={isLoading}
|
|
className="gap-2"
|
|
>
|
|
<Play className="h-4 w-4" />
|
|
Start Selected
|
|
</Button>
|
|
<Button
|
|
variant="destructive"
|
|
size="sm"
|
|
onClick={handleStopSelected}
|
|
disabled={isLoading}
|
|
className="gap-2"
|
|
>
|
|
<Square className="h-4 w-4" />
|
|
Stop Selected
|
|
</Button>
|
|
<Button
|
|
variant="outline"
|
|
size="sm"
|
|
onClick={handleRestartSelected}
|
|
disabled={isLoading}
|
|
className="gap-2"
|
|
>
|
|
<RotateCw className={cn('h-4 w-4', isLoading && 'animate-spin')} />
|
|
Restart Selected
|
|
</Button>
|
|
</div>
|
|
|
|
<div className="h-6 w-px bg-border" />
|
|
|
|
<Button
|
|
variant="ghost"
|
|
size="icon"
|
|
onClick={onClearSelection}
|
|
className="h-8 w-8"
|
|
>
|
|
<X className="h-4 w-4" />
|
|
</Button>
|
|
</div>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|