Add persistent deployment progress bar with minimize support.

Deployments can continue in the background via a dashboard progress bar; tables use truncation and admin migration status for cleaner layout.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
keyhan
2026-05-19 22:41:31 +03:30
parent 18c6abd0e8
commit 736509708b
11 changed files with 563 additions and 157 deletions
+192 -82
View File
@@ -8,6 +8,7 @@ import { toast } from 'react-toastify';
import type { Application, AppLifecycleStatus, ApplicationMigrationEvent, ApplicationMigrationJob, BillingCycle, Cluster } from '@/types';
import { Search, X, Package, Hexagon, User, Database, Box, AlertTriangle, Clock, ArrowRightLeft, RefreshCw } from 'lucide-react';
import { useConfirm } from '@/components/confirm-modal';
import { TruncatedText } from '@/components/truncated-text';
import { useDebounce } from '@/hooks/useDebounce';
const statusColors: Record<string, string> = {
@@ -60,6 +61,25 @@ function formatDeletionDate(date?: string): string {
return new Date(date).toLocaleDateString('en-US', { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' });
}
function migrationStatusBadgeClass(status: ApplicationMigrationJob['status']): string {
switch (status) {
case 'completed':
return 'badge-green';
case 'failed':
case 'rolled_back':
return 'badge-red';
case 'running':
case 'rolling_back':
return 'badge-blue';
default:
return 'badge-gray';
}
}
function formatMigrationStatus(status: ApplicationMigrationJob['status']): string {
return status.replace(/_/g, ' ');
}
export default function AdminAppsPage() {
const queryClient = useQueryClient();
const confirm = useConfirm();
@@ -267,17 +287,18 @@ export default function AdminAppsPage() {
) : (
<>
{/* Desktop Table */}
<div className="hidden md:block table-wrapper">
<table className="min-w-full divide-y divide-gray-200">
<div className="hidden lg:block table-wrapper overflow-x-auto">
<table className="min-w-[1180px] w-full table-fixed divide-y divide-gray-200">
<thead className="bg-gray-50/80">
<tr>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Application</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider w-[300px] min-w-[300px]">Application</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Owner</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Status</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Service</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Cluster</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Migration</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Plan / Expiry</th>
<th className="px-6 py-3.5 text-right text-xs font-semibold text-gray-500 uppercase tracking-wider">Actions</th>
<th className="px-6 py-3.5 text-right text-xs font-semibold text-gray-500 uppercase tracking-wider min-w-[200px]">Actions</th>
</tr>
</thead>
<tbody className="divide-y divide-gray-100">
@@ -289,106 +310,121 @@ export default function AdminAppsPage() {
const assignedCluster = app.clusterId ? clusterById.get(app.clusterId) : undefined;
return (
<tr key={app.id} className={`hover:bg-gray-50/50 transition-colors ${lifecycle === 'suspended' ? 'bg-amber-50/30' : lifecycle === 'pending_deletion' ? 'bg-red-50/30' : ''}`}>
<td className="px-6 py-4">
<Link href={`/dashboard/apps/${app.id}`} className="flex items-center gap-3 group">
<td className="px-6 py-4 min-w-[300px]">
<Link href={`/dashboard/apps/${app.id}`} className="flex items-center gap-3 min-w-[300px] group">
<div className="w-9 h-9 rounded-lg bg-primary-50 flex items-center justify-center shrink-0">
<Hexagon className={`w-5 h-5 ${app.runtime === 'nodejs' ? 'text-green-600' : app.runtime === 'wordpress' ? 'text-blue-600' : 'text-orange-500'}`} />
</div>
<div>
<span className="font-semibold text-gray-900 group-hover:text-primary-600 transition-colors block">
<div className="min-w-0 flex-1">
<TruncatedText className="font-semibold text-gray-900 group-hover:text-primary-600 transition-colors">
{app.name}
</span>
<span className="text-xs text-gray-400 capitalize">{app.runtime}</span>
</TruncatedText>
<TruncatedText className="text-xs text-gray-400 capitalize">{app.runtime}</TruncatedText>
</div>
</Link>
</td>
<td className="px-6 py-4">
<td className="px-6 py-4 max-w-[200px]">
{app.user ? (
<div>
<p className="text-sm font-medium text-gray-900">
{app.user.firstName} {app.user.lastName}
</p>
<p className="text-xs text-gray-400">{app.user.email}</p>
<p className="text-xs text-gray-300 font-mono">{app.userId.slice(0, 8)}</p>
<div className="min-w-0">
<TruncatedText className="text-sm font-medium text-gray-900">
{`${app.user.firstName} ${app.user.lastName}`}
</TruncatedText>
<TruncatedText className="text-xs text-gray-400">{app.user.email}</TruncatedText>
<TruncatedText className="text-xs text-gray-300 font-mono">{app.userId}</TruncatedText>
</div>
) : (
<span className="text-xs text-gray-400 font-mono">{app.userId.slice(0, 8)}</span>
<TruncatedText className="text-xs text-gray-400 font-mono">{app.userId}</TruncatedText>
)}
</td>
<td className="px-6 py-4 text-sm text-gray-600 capitalize">
<span className={`badge ${statusColors[latestStatus] || 'badge-gray'}`}>{latestStatus}</span>
<td className="px-6 py-4 max-w-[120px] text-sm text-gray-600 capitalize">
<span className={`badge max-w-full truncate ${statusColors[latestStatus] || 'badge-gray'}`} title={latestStatus}>
{latestStatus}
</span>
</td>
<td className="px-6 py-4">
<span className={`inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-semibold ${lifecycleColors[lifecycle] || 'text-gray-500 bg-gray-100'}`}>
{lifecycle === 'suspended' && <AlertTriangle className="w-3 h-3" />}
{lifecycleLabels[lifecycle] || lifecycle}
<td className="px-6 py-4 max-w-[180px]">
<span
className={`inline-flex max-w-full items-center gap-1 truncate px-2 py-1 rounded-full text-xs font-semibold ${lifecycleColors[lifecycle] || 'text-gray-500 bg-gray-100'}`}
title={lifecycleLabels[lifecycle] || lifecycle}
>
{lifecycle === 'suspended' && <AlertTriangle className="w-3 h-3 shrink-0" />}
<span className="truncate">{lifecycleLabels[lifecycle] || lifecycle}</span>
</span>
{lifecycle === 'pending_deletion' && app.scheduledDeletionAt && (
<p className="text-xs text-red-500 mt-1">Delete: {formatDeletionDate(app.scheduledDeletionAt)}</p>
<TruncatedText className="text-xs text-red-500 mt-1">
{`Delete: ${formatDeletionDate(app.scheduledDeletionAt)}`}
</TruncatedText>
)}
</td>
<td className="px-6 py-4">
<td className="px-6 py-4 max-w-[200px]">
{assignedCluster ? (
<div>
<p className="text-sm font-medium text-gray-900">{assignedCluster.name}</p>
<p className="text-xs text-gray-400">
{assignedCluster.region || 'N/A'} · {assignedCluster.status}/{assignedCluster.healthStatus || 'unknown'}
</p>
<div className="min-w-0">
<TruncatedText className="text-sm font-medium text-gray-900">{assignedCluster.name}</TruncatedText>
<TruncatedText className="text-xs text-gray-400">
{`${assignedCluster.region || 'N/A'} · ${assignedCluster.status}/${assignedCluster.healthStatus || 'unknown'}`}
</TruncatedText>
</div>
) : app.clusterId ? (
<div>
<p className="text-sm font-medium text-gray-700">Unknown cluster</p>
<p className="text-xs text-gray-400 font-mono">{app.clusterId.slice(0, 8)}</p>
<div className="min-w-0">
<TruncatedText className="text-sm font-medium text-gray-700">Unknown cluster</TruncatedText>
<TruncatedText className="text-xs text-gray-400 font-mono">{app.clusterId}</TruncatedText>
</div>
) : (
<span className="text-xs text-gray-400">Not assigned</span>
<TruncatedText className="text-xs text-gray-400">Not assigned</TruncatedText>
)}
</td>
<td className="px-6 py-4">
{app.billingCycle && (
<span className="badge badge-purple text-xs">{cycleLabels[app.billingCycle] || app.billingCycle}</span>
)}
{app.planExpiresAt ? (
<span className={`block text-xs mt-1 ${expiry.urgent ? 'text-red-600 font-semibold' : 'text-gray-500'}`}>
{expiry.text}
<td className="px-6 py-4 max-w-[140px]">
{latestMigration ? (
<span
className={`badge text-xs capitalize max-w-full truncate ${migrationStatusBadgeClass(latestMigration.status)}`}
title={formatMigrationStatus(latestMigration.status)}
>
{formatMigrationStatus(latestMigration.status)}
</span>
) : (
<span className="text-xs text-gray-400">No plan</span>
<span className="text-xs text-gray-400"></span>
)}
</td>
<td className="px-6 py-4 max-w-[140px]">
{app.billingCycle && (
<span
className="badge badge-purple text-xs max-w-full truncate"
title={cycleLabels[app.billingCycle] || app.billingCycle}
>
{cycleLabels[app.billingCycle] || app.billingCycle}
</span>
)}
{app.planExpiresAt ? (
<TruncatedText className={`text-xs mt-1 ${expiry.urgent ? 'text-red-600 font-semibold' : 'text-gray-500'}`}>
{expiry.text}
</TruncatedText>
) : (
<TruncatedText className="text-xs text-gray-400">No plan</TruncatedText>
)}
</td>
<td className="px-6 py-4 text-right">
<div className="flex items-center justify-end gap-2">
<div className="flex flex-wrap items-center justify-end gap-1.5">
<Link href={`/dashboard/apps/${app.id}`} className="btn-ghost text-xs px-3 py-1.5">
View
</Link>
<button
type="button"
onClick={() => {
setMigrateApp(app);
setTargetClusterId('');
}}
disabled={!app.clusterId}
className="btn-ghost text-xs px-3 py-1.5 inline-flex items-center gap-1"
className="btn-secondary text-xs px-3 py-1.5 inline-flex items-center gap-1 disabled:opacity-50"
title={!app.clusterId ? 'Application is not assigned to a cluster' : undefined}
>
<ArrowRightLeft className="w-3 h-3" /> Migrate
</button>
{latestMigration && (
<span className={`text-xs px-2 py-1 rounded-full ${
latestMigration.status === 'completed'
? 'bg-green-50 text-green-700'
: latestMigration.status === 'failed' || latestMigration.status === 'rolled_back'
? 'bg-red-50 text-red-700'
: 'bg-blue-50 text-blue-700'
}`}>
{latestMigration.status}
</span>
)}
<button
type="button"
onClick={async () => {
const ok = await confirm({ title: 'Delete Application', message: `Are you sure you want to delete "${app.name}"?`, confirmText: 'Delete', variant: 'danger' });
if (ok) deleteMutation.mutate(app.id);
}}
className="text-xs px-3 py-1.5 rounded-lg text-red-600 hover:bg-red-50 transition-colors"
className="text-xs px-3 py-1.5 rounded-lg text-red-600 hover:bg-red-50 transition-colors font-medium"
>
Delete
</button>
@@ -401,48 +437,122 @@ export default function AdminAppsPage() {
</table>
</div>
{/* Mobile Cards */}
<div className="md:hidden grid gap-3">
{/* Mobile / tablet cards */}
<div className="lg:hidden grid gap-3">
{apps.map((app) => {
const latestStatus = app.deployments?.[0]?.status || 'pending';
const lifecycle = app.lifecycleStatus || 'active';
const expiry = formatExpiry(app.planExpiresAt);
const latestMigration = migrations.find((migration) => migration.applicationId === app.id);
const assignedCluster = app.clusterId ? clusterById.get(app.clusterId) : undefined;
return (
<Link
<div
key={app.id}
href={`/dashboard/apps/${app.id}`}
className="card-hover"
className={`card space-y-3 ${lifecycle === 'suspended' ? 'border-amber-200/80' : lifecycle === 'pending_deletion' ? 'border-red-200/80' : ''}`}
>
<div className="flex items-center justify-between mb-3">
<div className="flex items-center gap-3">
<div className="w-10 h-10 rounded-xl bg-primary-50 flex items-center justify-center">
<div className="flex items-start justify-between gap-3">
<Link href={`/dashboard/apps/${app.id}`} className="flex items-center gap-3 min-w-0 flex-1">
<div className="w-10 h-10 rounded-xl bg-primary-50 flex items-center justify-center shrink-0">
<Hexagon className={`w-5 h-5 ${app.runtime === 'nodejs' ? 'text-green-600' : app.runtime === 'wordpress' ? 'text-blue-600' : 'text-orange-500'}`} />
</div>
<div>
<h3 className="font-semibold text-gray-900">{app.name}</h3>
<div className="min-w-0">
<TruncatedText className="font-semibold text-gray-900">{app.name}</TruncatedText>
<p className="text-xs text-gray-500 capitalize">{app.runtime}</p>
</div>
</div>
<span className={`badge ${statusColors[latestStatus] || 'badge-gray'}`}>
</Link>
<span className={`badge shrink-0 ${statusColors[latestStatus] || 'badge-gray'}`}>
{latestStatus}
</span>
</div>
{app.user && (
<div className="flex items-center gap-2 mb-2 text-xs text-gray-500">
<span className="flex items-center gap-1"><User className="w-3 h-3" /> {app.user.firstName} {app.user.lastName}</span>
<span className="text-gray-300"></span>
<span>{app.user.email}</span>
<div className="text-xs text-gray-500 space-y-0.5">
<p className="flex items-center gap-1 font-medium text-gray-700">
<User className="w-3 h-3 shrink-0" />
{app.user.firstName} {app.user.lastName}
</p>
<TruncatedText>{app.user.email}</TruncatedText>
</div>
)}
<div className="flex items-center gap-4 text-xs text-gray-500">
<span className="flex items-center gap-1"><Database className="w-3 h-3" /> {app.databaseType}</span>
<span className="flex items-center gap-1"><Box className="w-3 h-3" /> {app.replicas} replica{app.replicas > 1 ? 's' : ''}</span>
</div>
<div className="mt-2 text-xs text-gray-500">
Cluster:{' '}
<span className="font-medium text-gray-700">
{app.clusterId ? (clusterById.get(app.clusterId)?.name || app.clusterId.slice(0, 8)) : 'Not assigned'}
<div className="flex flex-wrap items-center gap-2 text-xs">
<span className={`inline-flex items-center gap-1 px-2 py-1 rounded-full font-semibold ${lifecycleColors[lifecycle] || 'text-gray-500 bg-gray-100'}`}>
{lifecycle === 'suspended' && <AlertTriangle className="w-3 h-3" />}
{lifecycleLabels[lifecycle] || lifecycle}
</span>
{app.billingCycle && (
<span className="badge badge-purple">{cycleLabels[app.billingCycle] || app.billingCycle}</span>
)}
{latestMigration && (
<span className={`badge capitalize ${migrationStatusBadgeClass(latestMigration.status)}`}>
{formatMigrationStatus(latestMigration.status)}
</span>
)}
</div>
</Link>
{lifecycle === 'pending_deletion' && app.scheduledDeletionAt && (
<p className="text-xs text-red-600">Delete: {formatDeletionDate(app.scheduledDeletionAt)}</p>
)}
<div className="grid grid-cols-1 sm:grid-cols-2 gap-2 text-xs text-gray-500">
<div>
<span className="text-gray-400 block">Cluster</span>
<TruncatedText className="font-medium text-gray-800">
{assignedCluster?.name || (app.clusterId ? 'Unknown' : 'Not assigned')}
</TruncatedText>
{assignedCluster && (
<TruncatedText className="text-gray-400 mt-0.5">
{`${assignedCluster.region || 'N/A'} · ${assignedCluster.status}`}
</TruncatedText>
)}
</div>
<div>
<span className="text-gray-400 block">Plan</span>
{app.planExpiresAt ? (
<span className={expiry.urgent ? 'text-red-600 font-semibold' : 'text-gray-700'}>{expiry.text}</span>
) : (
<span className="text-gray-400">No plan</span>
)}
</div>
<div className="flex items-center gap-3 sm:col-span-2">
<span className="flex items-center gap-1"><Database className="w-3 h-3" /> {app.databaseType}</span>
<span className="flex items-center gap-1"><Box className="w-3 h-3" /> {app.replicas} replica{app.replicas > 1 ? 's' : ''}</span>
</div>
</div>
<div className="flex flex-wrap items-center gap-2 pt-3 border-t border-gray-100">
<Link href={`/dashboard/apps/${app.id}`} className="btn-ghost text-xs px-3 py-1.5">
View
</Link>
<button
type="button"
onClick={() => {
setMigrateApp(app);
setTargetClusterId('');
}}
disabled={!app.clusterId}
className="btn-secondary text-xs px-3 py-1.5 inline-flex items-center gap-1 disabled:opacity-50"
title={!app.clusterId ? 'Application is not assigned to a cluster' : undefined}
>
<ArrowRightLeft className="w-3 h-3" /> Migrate
</button>
<button
type="button"
onClick={async () => {
const ok = await confirm({
title: 'Delete Application',
message: `Are you sure you want to delete "${app.name}"?`,
confirmText: 'Delete',
variant: 'danger',
});
if (ok) deleteMutation.mutate(app.id);
}}
className="text-xs px-3 py-1.5 rounded-lg text-red-600 hover:bg-red-50 font-medium"
>
Delete
</button>
</div>
</div>
);
})}
</div>
@@ -9,7 +9,6 @@ import { useState, useRef, useCallback, useEffect } from 'react';
import NextLink from 'next/link';
import { Hexagon, Rocket, Play, Square, RotateCw, Globe, Package, Server, Scale, CheckCircle, Clock, XCircle, AlertCircle, Link, GitBranch, KeyRound, FolderUp, BarChart3, ChevronDown, FileText, Monitor, Hammer, Settings, RefreshCw, Upload, Circle, Pin, Database, Eye, EyeOff, Copy, Check, History, Download, RotateCcw, Camera, Trash2, Archive, Zap, Wallet, CreditCard, AlertTriangle, ShieldAlert, ExternalLink, ScrollText } from 'lucide-react';
import { useConfirm } from '@/components/confirm-modal';
import { BuildProgressModal } from '@/components/build-progress-modal';
import { useAuthStore } from '@/lib/store';
/** Matches backend multipart limit for POST /applications/:id/upload */
@@ -547,6 +546,7 @@ export default function AppDetailPage() {
const invalidateAll = () => {
queryClient.invalidateQueries({ queryKey: ['deployments', appId] });
queryClient.invalidateQueries({ queryKey: ['application', appId] });
queryClient.invalidateQueries({ queryKey: ['applications'] });
};
const deployMutation = useMutation({
@@ -2951,7 +2951,6 @@ export default function AppDetailPage() {
</div>
)}
</div>
<BuildProgressModal appId={appId} enabled={isInProgress} />
</div>
);
}
+3 -3
View File
@@ -120,7 +120,7 @@ export default function AppsPage() {
<table className="min-w-full divide-y divide-gray-200">
<thead className="bg-gray-50/80">
<tr>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Application</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider min-w-[300px]">Application</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Runtime</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Status</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">Service Status</th>
@@ -138,8 +138,8 @@ export default function AppsPage() {
key={app.id}
className={`hover:bg-gray-50/50 transition-colors ${lifecycle === 'suspended' ? 'bg-amber-50/30' : lifecycle === 'pending_deletion' ? 'bg-red-50/30' : ''}`}
>
<td className="px-6 py-4">
<Link href={`/dashboard/apps/${app.id}`} className="flex items-center gap-3 group">
<td className="px-6 py-4 min-w-[300px]">
<Link href={`/dashboard/apps/${app.id}`} className="flex items-center gap-3 group min-w-[300px]">
<div className="w-9 h-9 rounded-lg bg-primary-50 flex items-center justify-center shrink-0">
<Hexagon className={`w-5 h-5 ${app.runtime === 'nodejs' ? 'text-green-600' : app.runtime === 'wordpress' ? 'text-blue-600' : 'text-orange-500'}`} />
</div>
+9 -1
View File
@@ -6,6 +6,8 @@ import Link from 'next/link';
import { useQuery } from '@tanstack/react-query';
import { useAuthStore } from '@/lib/store';
import api from '@/lib/api';
import { DeploymentProgressManager } from '@/components/deployment-progress-manager';
import { useDeployProgressStore } from '@/lib/deploy-progress-store';
import {
LayoutDashboard,
Package,
@@ -66,6 +68,7 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
const router = useRouter();
const pathname = usePathname();
const [sidebarOpen, setSidebarOpen] = useState(false);
const deployBarMinimized = useDeployProgressStore((s) => s.minimized);
useEffect(() => {
if (!isLoading && !isAuthenticated) {
@@ -205,6 +208,7 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
return (
<div className="min-h-screen bg-gray-50">
<DeploymentProgressManager />
{/* Mobile overlay */}
{sidebarOpen && (
<div
@@ -231,7 +235,11 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
</aside>
{/* Header */}
<header className="bg-white/80 backdrop-blur-lg border-b border-gray-200/80 sticky top-0 z-30">
<header
className={`bg-white/80 backdrop-blur-lg border-b border-gray-200/80 sticky z-30 ${
deployBarMinimized ? 'top-11' : 'top-0'
}`}
>
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div className="flex justify-between items-center h-16">
<div className="flex items-center gap-3">
+2 -2
View File
@@ -327,7 +327,7 @@ function LogsPageContent() {
<tr>
<th className="px-3 py-2 text-left text-xs font-medium text-gray-500">Time</th>
<th className="px-3 py-2 text-left text-xs font-medium text-gray-500">Level</th>
<th className="px-3 py-2 text-left text-xs font-medium text-gray-500">App</th>
<th className="px-3 py-2 text-left text-xs font-medium text-gray-500 min-w-[300px]">App</th>
<th className="px-3 py-2 text-left text-xs font-medium text-gray-500">Source</th>
<th className="px-3 py-2 text-left text-xs font-medium text-gray-500">Message</th>
</tr>
@@ -343,7 +343,7 @@ function LogsPageContent() {
{entry.level?.toUpperCase()}
</span>
</td>
<td className="px-3 py-2 text-gray-800">{entry.applicationName || '—'}</td>
<td className="px-3 py-2 text-gray-800 min-w-[300px]">{entry.applicationName || '—'}</td>
<td className="px-3 py-2 text-gray-600 capitalize">{entry.workload || 'app'}</td>
<td className="px-3 py-2 font-mono text-xs text-gray-800 break-all max-w-xl">
{entry.message}