// ui/src/components/InstanceCard.tsx import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import type { Instance } from "@/types/instance"; import { Edit, FileText, Play, Square, Trash2, MoreHorizontal } from "lucide-react"; import LogsDialog from "@/components/LogDialog"; import HealthBadge from "@/components/HealthBadge"; import BackendBadge from "@/components/BackendBadge"; import { useState } from "react"; import { useInstanceHealth } from "@/hooks/useInstanceHealth"; interface InstanceCardProps { instance: Instance; startInstance: (name: string) => void; stopInstance: (name: string) => void; deleteInstance: (name: string) => void; editInstance: (instance: Instance) => void; } function InstanceCard({ instance, startInstance, stopInstance, deleteInstance, editInstance, }: InstanceCardProps) { const [isLogsOpen, setIsLogsOpen] = useState(false); const [showAllActions, setShowAllActions] = useState(false); const health = useInstanceHealth(instance.name, instance.status); const handleStart = () => { startInstance(instance.name); }; const handleStop = () => { stopInstance(instance.name); }; const handleDelete = () => { if ( confirm(`Are you sure you want to delete instance "${instance.name}"?`) ) { deleteInstance(instance.name); } }; const handleEdit = () => { editInstance(instance); }; const handleLogs = () => { setIsLogsOpen(true); }; const running = instance.status === "running"; return ( <> {/* Header with instance name and status badges */}
{instance.name} {/* Badges row */}
{running && }
{/* Primary actions - always visible */}
{/* Secondary actions - collapsible */} {showAllActions && (
)}
); } export default InstanceCard;