import React from "react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, } from "@/components/ui"; import { Button } from "@/components/ui"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui"; import { Alert, AlertDescription } from "@/components/ui"; import { FileText, Loader2 } from "lucide-react"; import { getPodLogsCmd } from "@/lib/tauriCommands"; interface LogsModalProps { open: boolean; onOpenChange: (open: boolean) => void; clusterId: string; namespace: string; podName: string; containers: string[]; } export function LogsModal({ open, onOpenChange, clusterId, namespace, podName, containers, }: LogsModalProps) { const [selectedContainer, setSelectedContainer] = React.useState(""); const [logs, setLogs] = React.useState(""); const [isLoading, setIsLoading] = React.useState(false); const [error, setError] = React.useState(null); React.useEffect(() => { if (open) { setSelectedContainer(containers[0] ?? ""); setLogs(""); setError(null); } }, [open, containers]); const fetchLogs = async () => { if (!selectedContainer) return; setIsLoading(true); setError(null); try { const response = await getPodLogsCmd(clusterId, namespace, podName, selectedContainer); setLogs(response.logs); } catch (err) { setError(err instanceof Error ? err.message : String(err)); } finally { setIsLoading(false); } }; return ( Logs — {podName}
{error && ( {error} )}
            {logs || "No logs. Select a container and click Fetch Logs."}
          
); }