"use client"; import { useEffect, useMemo, useState } from "react"; import { DashboardLayout } from "@/components/dashboard/DashboardLayout"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Rocket, RotateCcw, Eye, MoreVertical, Plus, Play, Pause, Trash, } from "lucide-react"; import { Application, Deployment } from "@/lib/types"; import { getDeployments } from "@/lib/dockship/deploy"; import { getApps } from "@/lib/dockship/application"; import { cn } from "@/lib/utils"; import DeployAppDialog from "@/components/dialogs/DeployApp"; import { useAsync, useAsyncInterval } from "@/hooks/use-async"; import RemoveDialog from "@/components/dialogs/Remove"; const statusDot = { running: "bg-chart-2", pending: "bg-chart-1", stopped: "bg-slate-400 dark:bg-slate-600", } as const; export default function DeploymentsPage() { const { value: apps } = useAsyncInterval([], getApps, 5000); const { value: deployments, loading } = useAsync([], getDeployments, [apps]); const appNameByContainer = useMemo(() => { const map = new Map(); for (const app of apps) { for (const container of app.deployments) { map.set(container, app.name); } } return map; }, [apps]); return ( {/* Header */}
{loading ? "Loading…" : `${deployments.length} deployment${deployments.length > 0 && "s"}`}
{deployments.map((dep) => { const appName = appNameByContainer.get(dep.container) ?? "Unknown app"; return (
{appName} {dep.ports.map(([to, from]) => ( {from} → {to} ))}

{dep.image}

{}} />
); })}
); }