diff --git a/app/console/deployments/page.tsx b/app/console/deployments/page.tsx index 47cd111..1fc360a 100644 --- a/app/console/deployments/page.tsx +++ b/app/console/deployments/page.tsx @@ -3,7 +3,7 @@ import { useEffect, useState } from "react"; import { useRouter } from "next/navigation"; import Link from "next/link"; -import { Rocket, ExternalLink, Trash2, RefreshCw, Server, ScrollText, RotateCcw, AlertTriangle } from "lucide-react"; +import { Rocket, ExternalLink, Trash2, RefreshCw, Server, ScrollText, RotateCcw, AlertTriangle, Copy, Check } from "lucide-react"; interface DeploymentSummary { sandboxId: string; @@ -33,6 +33,33 @@ const STATUS_DOT: Record = { failed: "bg-red-500", }; +// Isolated Copy Component to maintain separate success timer states inside lists (Fixes #49) +function CopyButton({ text }: { text: string }) { + const [copied, setCopied] = useState(false); + + const handleCopy = async (e: React.MouseEvent) => { + e.stopPropagation(); // Prevent row click events + try { + await navigator.clipboard.writeText(text); + setCopied(true); + setTimeout(() => setCopied(false), 2000); + } catch { + // Fallback if system permission is denied + } + }; + + return ( + + ); +} + export default function Page() { const router = useRouter(); const [deployments, setDeployments] = useState([]); @@ -91,7 +118,6 @@ export default function Page() { const res = await fetch(`/api/deploy/${sandboxId}`, { method: "POST" }); const data = await res.json(); if (data.ok && data.deployment?.sandboxId) { - // Navigate to the new deployment's log page router.push(`/console/deployments/${data.deployment.sandboxId}`); } else { alert(data.error ?? "Redeploy failed"); @@ -185,17 +211,20 @@ export default function Page() { {new Date(d.startedAt).toLocaleString()} {d.logCount} log lines - {d.publicUrl && d.status !== "live" && ( -
- Preview URL: + + {/* Public Preview Block with Copy to Clipboard Integration */} + {d.publicUrl && ( +
+ Preview URL: {d.publicUrl} +
)}
@@ -246,4 +275,4 @@ export default function Page() { )} ); -} +} \ No newline at end of file