'use client'; import { useState } from 'react'; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { ExternalLink, Copy, Check, Terminal } from 'lucide-react'; import { ProblemSolution } from '@/lib/docker-problems'; import { useToast } from '@/hooks/use-toast'; import { invoke } from '@tauri-apps/api/core'; import { cn } from '@/lib/utils'; interface DockerCommandsModalProps { open: boolean; onOpenChange: (open: boolean) => void; problem: ProblemSolution | null; } export function DockerCommandsModal({ open, onOpenChange, problem }: DockerCommandsModalProps) { const { toast } = useToast(); const [copiedIndex, setCopiedIndex] = useState(null); if (!problem) return null; const handleCopyCommand = async (command: string, index: number) => { try { await navigator.clipboard.writeText(command); setCopiedIndex(index); toast({ title: 'Comando copiado', description: 'Comando copiado para a área de transferência', }); setTimeout(() => setCopiedIndex(null), 2000); } catch (error) { toast({ title: 'Erro ao copiar', description: 'Não foi possível copiar o comando', variant: 'destructive', }); } }; const handleOpenLink = async (url: string) => { try { await invoke('open_url', { url }); } catch (error) { console.error('Error opening URL:', error); // Fallback para window.open se Tauri falhar window.open(url, '_blank', 'noopener,noreferrer'); } }; return ( {problem.problem} {problem.description && ( {problem.description} )}
{/* Links de Documentação */} {problem.links.length > 0 && ( Documentação Oficial Links para documentação oficial sobre este problema {problem.links.map((link, idx) => ( ))} )} {/* Comandos */} {problem.commands && problem.commands.length > 0 && ( Comandos Execute estes comandos no terminal para resolver o problema {problem.commands.map((command, idx) => (

{command.title}

{command.description && (

{command.description}

)}
                        {command.code}
                      
))}
)} {/* Mensagem quando não há comandos nem links */} {problem.links.length === 0 && (!problem.commands || problem.commands.length === 0) && (

Nenhuma solução disponível para este problema.

Consulte a documentação oficial do Docker para mais informações.

)}
); }