Localize the admin all-applications page.

Move the final dashboard page (admin all-apps) onto a
dashboard.adminApps dictionary: status-count cards, search, table/cards,
lifecycle & migration statuses, plan/expiry, and the migrate modal —
completing full fa-IR/en-US coverage across the entire app.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
keyhan
2026-06-12 01:06:33 +03:30
parent e43274e9a2
commit d31d93f6b8
4 changed files with 170 additions and 110 deletions
@@ -2,7 +2,9 @@
import { useState } from 'react';
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import Link from 'next/link';
import { Link } from '@/i18n/Link';
import { useT, useLocale } from '@/i18n/I18nProvider';
import type { Dictionary } from '@/i18n/dictionaries/fa';
import api from '@/lib/api';
import { toast } from 'react-toastify';
import type { Application, AppLifecycleStatus, ApplicationMigrationEvent, ApplicationMigrationJob, BillingCycle, Cluster } from '@/types';
@@ -36,36 +38,25 @@ const lifecycleColors: Record<string, string> = {
deleted: 'text-gray-500 bg-gray-100',
};
const lifecycleLabels: Record<string, string> = {
active: 'Active',
suspended: 'Suspended — Unpaid',
pending_deletion: 'Pending Deletion',
deleted: 'Deleted',
};
type AdminAppsDict = Dictionary['dashboard']['adminApps'];
const cycleLabels: Record<string, string> = {
hourly: 'Hourly',
monthly: 'Monthly',
yearly: 'Yearly',
};
function formatExpiry(expiresAt?: string): { text: string; urgent: boolean } {
function formatExpiry(expiresAt: string | undefined, aa: AdminAppsDict): { text: string; urgent: boolean } {
if (!expiresAt) return { text: '—', urgent: false };
const now = new Date();
const exp = new Date(expiresAt);
const diff = exp.getTime() - now.getTime();
if (diff <= 0) return { text: 'Expired', urgent: true };
if (diff <= 0) return { text: aa.expired, urgent: true };
const hours = Math.floor(diff / 3600000);
const days = Math.floor(hours / 24);
if (days > 0) return { text: `${days}d ${hours % 24}h`, urgent: days < 3 };
if (hours > 0) return { text: `${hours}h`, urgent: hours < 6 };
if (days > 0) return { text: `${days}${aa.dayShort} ${hours % 24}${aa.hourShort}`, urgent: days < 3 };
if (hours > 0) return { text: `${hours}${aa.hourShort}`, urgent: hours < 6 };
const mins = Math.floor(diff / 60000);
return { text: `${mins}m`, urgent: true };
return { text: `${mins}${aa.minShort}`, urgent: true };
}
function formatDeletionDate(date?: string): string {
function formatDeletionDate(date: string | undefined, locale: string): string {
if (!date) return '';
return new Date(date).toLocaleDateString('en-US', { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' });
return new Date(date).toLocaleDateString(locale, { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' });
}
function migrationStatusBadgeClass(status: ApplicationMigrationJob['status']): string {
@@ -83,11 +74,14 @@ function migrationStatusBadgeClass(status: ApplicationMigrationJob['status']): s
}
}
function formatMigrationStatus(status: ApplicationMigrationJob['status']): string {
return status.replace(/_/g, ' ');
}
export default function AdminAppsPage() {
const t = useT();
const aa = t.dashboard.adminApps;
const locale = useLocale();
const statusLabel = (s: string) => (t.components.deployStatus as Record<string, string>)[s] ?? s;
const lifecycleLabel = (s: string) => (aa.lifecycle as Record<string, string>)[s] ?? s;
const cycleLabel = (s: string) => (aa.cycles as Record<string, string>)[s] ?? s;
const migrationStatusLabel = (s: string) => (aa.migrationStatus as Record<string, string>)[s] ?? s.replace(/_/g, ' ');
const queryClient = useQueryClient();
const confirm = useConfirm();
const [search, setSearch] = useState('');
@@ -105,7 +99,7 @@ export default function AdminAppsPage() {
const { deleteApplication, isDeleting, isAnyDeleting } = useApplicationDelete({
invalidateKeys: [['admin-applications']],
successMessage: 'Application deleted',
successMessage: aa.appDeleted,
});
const { data: clusters = [] } = useQuery<Cluster[]>({
@@ -143,18 +137,18 @@ export default function AdminAppsPage() {
}),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['application-migrations'] });
toast.success('Migration job queued');
toast.success(aa.migrationQueued);
},
onError: (err: any) => toast.error(err?.response?.data?.message || 'Failed to queue migration'),
onError: (err: any) => toast.error(err?.response?.data?.message || aa.migrationQueueFailed),
});
const retryMigration = useMutation({
mutationFn: (id: string) => api.post(`/application-migrations/${id}/retry`),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['application-migrations'] });
toast.success('Migration retry queued');
toast.success(aa.migrationRetryQueued);
},
onError: (err: any) => toast.error(err?.response?.data?.message || 'Failed to retry migration'),
onError: (err: any) => toast.error(err?.response?.data?.message || aa.migrationRetryFailed),
});
// Compute status counts from apps
@@ -210,10 +204,10 @@ export default function AdminAppsPage() {
<div className="space-y-6">
<div className="page-header">
<div>
<h1 className="page-title">All Applications</h1>
<h1 className="page-title">{aa.title}</h1>
<p className="page-subtitle">
{apps.length} application{apps.length !== 1 ? 's' : ''}
{debouncedSearch && ` matching "${debouncedSearch}"`}
{aa.count.replace('{n}', String(apps.length))}
{debouncedSearch && aa.matching.replace('{q}', debouncedSearch)}
</p>
</div>
</div>
@@ -222,48 +216,48 @@ export default function AdminAppsPage() {
<div className="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-3">
<div className="card py-4 text-center border-l-4 border-l-green-500">
<p className="text-2xl font-bold text-green-600">{statusCounts.running}</p>
<p className="text-xs text-gray-500 font-medium mt-1">Running</p>
<p className="text-xs text-gray-500 font-medium mt-1">{aa.countRunning}</p>
</div>
<div className="card py-4 text-center border-l-4 border-l-blue-500">
<p className="text-2xl font-bold text-blue-600">{statusCounts.deploying}</p>
<p className="text-xs text-gray-500 font-medium mt-1">Deploying</p>
<p className="text-xs text-gray-500 font-medium mt-1">{aa.countDeploying}</p>
</div>
<div className="card py-4 text-center border-l-4 border-l-yellow-500">
<p className="text-2xl font-bold text-yellow-600">{statusCounts.pending}</p>
<p className="text-xs text-gray-500 font-medium mt-1">Pending</p>
<p className="text-xs text-gray-500 font-medium mt-1">{aa.countPending}</p>
</div>
<div className="card py-4 text-center border-l-4 border-l-gray-400">
<p className="text-2xl font-bold text-gray-500">{statusCounts.stopped}</p>
<p className="text-xs text-gray-500 font-medium mt-1">Stopped</p>
<p className="text-xs text-gray-500 font-medium mt-1">{aa.countStopped}</p>
</div>
<div className="card py-4 text-center border-l-4 border-l-red-500">
<p className="text-2xl font-bold text-red-600">{statusCounts.failed}</p>
<p className="text-xs text-gray-500 font-medium mt-1">Failed</p>
<p className="text-xs text-gray-500 font-medium mt-1">{aa.countFailed}</p>
</div>
<div className="card py-4 text-center border-l-4 border-l-amber-500">
<p className="text-2xl font-bold text-amber-600">{statusCounts.suspended}</p>
<p className="text-xs text-gray-500 font-medium mt-1">Suspended</p>
<p className="text-xs text-gray-500 font-medium mt-1">{aa.countSuspended}</p>
</div>
<div className="card py-4 text-center border-l-4 border-l-red-700">
<p className="text-2xl font-bold text-red-700">{statusCounts.pendingDeletion}</p>
<p className="text-xs text-gray-500 font-medium mt-1">Pending Del.</p>
<p className="text-xs text-gray-500 font-medium mt-1">{aa.countPendingDel}</p>
</div>
</div>
{/* Search */}
<div className="relative">
<Search className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 w-4 h-4" />
<Search className="absolute left-3 rtl:left-auto rtl:right-3 top-1/2 -translate-y-1/2 text-gray-400 w-4 h-4" />
<input
type="text"
placeholder="Search by app name, user name, email, or user ID…"
placeholder={aa.searchPlaceholder}
value={search}
onChange={(e) => setSearch(e.target.value)}
className="input pl-10 w-full"
className="input pl-10 rtl:pl-3 rtl:pr-10 w-full"
/>
{search && (
<button
onClick={() => setSearch('')}
className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600"
className="absolute right-3 rtl:right-auto rtl:left-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600"
>
<X className="w-4 h-4" />
</button>
@@ -275,15 +269,15 @@ export default function AdminAppsPage() {
<Package className="w-12 h-12 mx-auto mb-4 text-gray-300" />
{debouncedSearch ? (
<>
<p className="text-gray-600 text-lg font-medium">No applications found</p>
<p className="text-gray-600 text-lg font-medium">{aa.noAppsFound}</p>
<p className="text-gray-400 mt-1 text-sm">
No results for &quot;{debouncedSearch}&quot;. Try a different search.
{aa.noResultsFor.replace('{q}', debouncedSearch)}
</p>
</>
) : (
<>
<p className="text-gray-600 text-lg font-medium">No applications yet</p>
<p className="text-gray-400 mt-1 text-sm">No applications have been created by any user.</p>
<p className="text-gray-600 text-lg font-medium">{aa.noAppsYet}</p>
<p className="text-gray-400 mt-1 text-sm">{aa.noAppsByUser}</p>
</>
)}
</div>
@@ -294,21 +288,21 @@ export default function AdminAppsPage() {
<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 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 min-w-[200px]">Actions</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]">{aa.colApplication}</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">{aa.colOwner}</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">{aa.colStatus}</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">{aa.colService}</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">{aa.colCluster}</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">{aa.colMigration}</th>
<th className="px-6 py-3.5 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">{aa.colPlanExpiry}</th>
<th className="px-6 py-3.5 text-right text-xs font-semibold text-gray-500 uppercase tracking-wider min-w-[200px]">{aa.colActions}</th>
</tr>
</thead>
<tbody className="divide-y divide-gray-100">
{apps.map((app) => {
const latestStatus = app.deployments?.[0]?.status || 'pending';
const lifecycle = app.lifecycleStatus || 'active';
const expiry = formatExpiry(app.planExpiresAt);
const expiry = formatExpiry(app.planExpiresAt, aa);
const latestMigration = migrations.find((migration) => migration.applicationId === app.id);
const assignedCluster = app.clusterId ? clusterById.get(app.clusterId) : undefined;
const rowDeleting = isDeleting(app.id);
@@ -344,21 +338,21 @@ export default function AdminAppsPage() {
)}
</td>
<td className={`px-6 py-4 max-w-[120px] text-sm text-gray-600 capitalize ${rowDeleting ? deletingRowContentClass : ''}`}>
<span className={`badge max-w-full truncate ${statusColors[latestStatus] || 'badge-gray'}`} title={latestStatus}>
{latestStatus}
<span className={`badge max-w-full truncate ${statusColors[latestStatus] || 'badge-gray'}`} title={statusLabel(latestStatus)}>
{statusLabel(latestStatus)}
</span>
</td>
<td className={`px-6 py-4 max-w-[180px] ${rowDeleting ? deletingRowContentClass : ''}`}>
<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}
title={lifecycleLabel(lifecycle)}
>
{lifecycle === 'suspended' && <AlertTriangle className="w-3 h-3 shrink-0" />}
<span className="truncate">{lifecycleLabels[lifecycle] || lifecycle}</span>
<span className="truncate">{lifecycleLabel(lifecycle)}</span>
</span>
{lifecycle === 'pending_deletion' && app.scheduledDeletionAt && (
<TruncatedText className="text-xs text-red-500 mt-1">
{`Delete: ${formatDeletionDate(app.scheduledDeletionAt)}`}
{aa.deletePrefix.replace('{date}', formatDeletionDate(app.scheduledDeletionAt, locale))}
</TruncatedText>
)}
</td>
@@ -367,25 +361,25 @@ export default function AdminAppsPage() {
<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'}`}
{`${assignedCluster.region || aa.na} · ${assignedCluster.status}/${assignedCluster.healthStatus || aa.unknown}`}
</TruncatedText>
</div>
) : app.clusterId ? (
<div className="min-w-0">
<TruncatedText className="text-sm font-medium text-gray-700">Unknown cluster</TruncatedText>
<TruncatedText className="text-sm font-medium text-gray-700">{aa.unknownCluster}</TruncatedText>
<TruncatedText className="text-xs text-gray-400 font-mono">{app.clusterId}</TruncatedText>
</div>
) : (
<TruncatedText className="text-xs text-gray-400">Not assigned</TruncatedText>
<TruncatedText className="text-xs text-gray-400">{aa.notAssigned}</TruncatedText>
)}
</td>
<td className={`px-6 py-4 max-w-[140px] ${rowDeleting ? deletingRowContentClass : ''}`}>
{latestMigration ? (
<span
className={`badge text-xs capitalize max-w-full truncate ${migrationStatusBadgeClass(latestMigration.status)}`}
title={formatMigrationStatus(latestMigration.status)}
title={migrationStatusLabel(latestMigration.status)}
>
{formatMigrationStatus(latestMigration.status)}
{migrationStatusLabel(latestMigration.status)}
</span>
) : (
<span className="text-xs text-gray-400"></span>
@@ -395,9 +389,9 @@ export default function AdminAppsPage() {
{app.billingCycle && (
<span
className="badge badge-purple text-xs max-w-full truncate"
title={cycleLabels[app.billingCycle] || app.billingCycle}
title={cycleLabel(app.billingCycle)}
>
{cycleLabels[app.billingCycle] || app.billingCycle}
{cycleLabel(app.billingCycle)}
</span>
)}
{app.planExpiresAt ? (
@@ -405,13 +399,13 @@ export default function AdminAppsPage() {
{expiry.text}
</TruncatedText>
) : (
<TruncatedText className="text-xs text-gray-400">No plan</TruncatedText>
<TruncatedText className="text-xs text-gray-400">{aa.noPlan}</TruncatedText>
)}
</td>
<td className={`px-6 py-4 text-right ${rowDeleting ? deletingRowContentClass : ''}`}>
<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
{aa.view}
</Link>
<button
type="button"
@@ -421,15 +415,15 @@ export default function AdminAppsPage() {
}}
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}
title={!app.clusterId ? aa.notAssignedTooltip : undefined}
>
<ArrowRightLeft className="w-3 h-3" /> Migrate
<ArrowRightLeft className="w-3 h-3" /> {aa.migrate}
</button>
<button
type="button"
disabled={isAnyDeleting}
onClick={async () => {
const ok = await confirm({ title: 'Delete Application', message: `Are you sure you want to delete "${app.name}"?`, confirmText: 'Delete', variant: 'danger' });
const ok = await confirm({ title: aa.deleteAppTitle, message: aa.deleteAppConfirm.replace('{name}', app.name), confirmText: t.common.delete, variant: 'danger' });
if (ok) deleteApplication(app.id);
}}
className="text-xs px-3 py-1.5 rounded-lg text-red-600 hover:bg-red-50 transition-colors font-medium disabled:opacity-50 disabled:pointer-events-none"
@@ -457,7 +451,7 @@ export default function AdminAppsPage() {
{apps.map((app) => {
const latestStatus = app.deployments?.[0]?.status || 'pending';
const lifecycle = app.lifecycleStatus || 'active';
const expiry = formatExpiry(app.planExpiresAt);
const expiry = formatExpiry(app.planExpiresAt, aa);
const latestMigration = migrations.find((migration) => migration.applicationId === app.id);
const assignedCluster = app.clusterId ? clusterById.get(app.clusterId) : undefined;
const cardDeleting = isDeleting(app.id);
@@ -481,7 +475,7 @@ export default function AdminAppsPage() {
</div>
</Link>
<span className={`badge shrink-0 ${statusColors[latestStatus] || 'badge-gray'}`}>
{latestStatus}
{statusLabel(latestStatus)}
</span>
</div>
@@ -498,51 +492,51 @@ export default function AdminAppsPage() {
<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}
{lifecycleLabel(lifecycle)}
</span>
{app.billingCycle && (
<span className="badge badge-purple">{cycleLabels[app.billingCycle] || app.billingCycle}</span>
<span className="badge badge-purple">{cycleLabel(app.billingCycle)}</span>
)}
{latestMigration && (
<span className={`badge capitalize ${migrationStatusBadgeClass(latestMigration.status)}`}>
{formatMigrationStatus(latestMigration.status)}
{migrationStatusLabel(latestMigration.status)}
</span>
)}
</div>
{lifecycle === 'pending_deletion' && app.scheduledDeletionAt && (
<p className="text-xs text-red-600">Delete: {formatDeletionDate(app.scheduledDeletionAt)}</p>
<p className="text-xs text-red-600">{aa.deletePrefix.replace('{date}', formatDeletionDate(app.scheduledDeletionAt, locale))}</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>
<span className="text-gray-400 block">{aa.cluster}</span>
<TruncatedText className="font-medium text-gray-800">
{assignedCluster?.name || (app.clusterId ? 'Unknown' : 'Not assigned')}
{assignedCluster?.name || (app.clusterId ? aa.unknown : aa.notAssigned)}
</TruncatedText>
{assignedCluster && (
<TruncatedText className="text-gray-400 mt-0.5">
{`${assignedCluster.region || 'N/A'} · ${assignedCluster.status}`}
{`${assignedCluster.region || aa.na} · ${assignedCluster.status}`}
</TruncatedText>
)}
</div>
<div>
<span className="text-gray-400 block">Plan</span>
<span className="text-gray-400 block">{aa.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>
<span className="text-gray-400">{aa.noPlan}</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>
<span className="flex items-center gap-1"><Box className="w-3 h-3" /> {aa.replicas.replace('{n}', String(app.replicas))}</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
{aa.view}
</Link>
<button
type="button"
@@ -552,18 +546,18 @@ export default function AdminAppsPage() {
}}
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}
title={!app.clusterId ? aa.notAssignedTooltip : undefined}
>
<ArrowRightLeft className="w-3 h-3" /> Migrate
<ArrowRightLeft className="w-3 h-3" /> {aa.migrate}
</button>
<button
type="button"
disabled={isAnyDeleting}
onClick={async () => {
const ok = await confirm({
title: 'Delete Application',
message: `Are you sure you want to delete "${app.name}"?`,
confirmText: 'Delete',
title: aa.deleteAppTitle,
message: aa.deleteAppConfirm.replace('{name}', app.name),
confirmText: t.common.delete,
variant: 'danger',
});
if (ok) deleteApplication(app.id);
@@ -587,10 +581,10 @@ export default function AdminAppsPage() {
<div className="flex items-start justify-between gap-3">
<div>
<h2 className="text-lg font-semibold text-gray-900 flex items-center gap-2">
<ArrowRightLeft className="w-5 h-5" /> Migrate Application
<ArrowRightLeft className="w-5 h-5" /> {aa.migrateApplication}
</h2>
<p className="text-sm text-gray-500 mt-1">
Move <span className="font-medium">{migrateApp.name}</span> to a healthy target cluster with logs, retry, and rollback.
{aa.moveTo.split('{name}').flatMap((part, i) => i === 0 ? [part] : [<span key={i} className="font-medium">{migrateApp.name}</span>, part])}
</p>
</div>
<button onClick={() => setMigrateApp(null)} className="p-1 text-gray-400 hover:text-gray-600">
@@ -599,15 +593,15 @@ export default function AdminAppsPage() {
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Target Cluster</label>
<label className="block text-sm font-medium text-gray-700 mb-1">{aa.targetCluster}</label>
<div className="mb-3 rounded-xl bg-gray-50 border border-gray-100 p-3">
<p className="text-xs font-medium text-gray-500">Current cluster</p>
<p className="text-xs font-medium text-gray-500">{aa.currentCluster}</p>
<p className="text-sm font-semibold text-gray-900 mt-1">
{currentCluster?.name || (migrateApp.clusterId ? `Unknown cluster (${migrateApp.clusterId.slice(0, 8)})` : 'Not assigned')}
{currentCluster?.name || (migrateApp.clusterId ? aa.unknownClusterShort.replace('{id}', migrateApp.clusterId.slice(0, 8)) : aa.notAssigned)}
</p>
{currentCluster && (
<p className="text-xs text-gray-500 mt-0.5">
{currentCluster.region || 'N/A'} · {currentCluster.status}/{currentCluster.healthStatus || 'unknown'}
{currentCluster.region || aa.na} · {currentCluster.status}/{currentCluster.healthStatus || aa.unknown}
</p>
)}
</div>
@@ -616,7 +610,7 @@ export default function AdminAppsPage() {
value={targetClusterId}
onChange={(e) => setTargetClusterId(e.target.value)}
>
<option value="">Select healthy cluster</option>
<option value="">{aa.selectHealthyCluster}</option>
{targetClusters
.map((cluster) => (
<option
@@ -624,16 +618,16 @@ export default function AdminAppsPage() {
value={cluster.id}
disabled={cluster.status !== 'active' || cluster.healthStatus !== 'healthy'}
>
{cluster.name} · {cluster.region || 'N/A'} · {cluster.status}/{cluster.healthStatus || 'unknown'}
{cluster.name} · {cluster.region || aa.na} · {cluster.status}/{cluster.healthStatus || aa.unknown}
</option>
))}
</select>
<p className="text-xs text-gray-400 mt-1">
The current cluster is excluded. Migration is blocked for unhealthy, inactive, or maintenance clusters.
{aa.currentExcludedNote}
</p>
{targetClusters.length === 0 && (
<p className="text-xs text-amber-600 mt-2">
No other cluster is available as a migration target.
{aa.noOtherCluster}
</p>
)}
</div>
@@ -642,9 +636,9 @@ export default function AdminAppsPage() {
<div className="rounded-xl border border-gray-200 p-4 space-y-3">
<div className="flex items-center justify-between">
<div>
<p className="text-sm font-semibold text-gray-800">Latest migration</p>
<p className="text-sm font-semibold text-gray-800">{aa.latestMigration}</p>
<p className="text-xs text-gray-500">
{selectedMigration.currentStep || 'queued'} · attempts {selectedMigration.attempts}/{selectedMigration.maxAttempts}
{selectedMigration.currentStep || aa.queued} · {aa.attempts} {selectedMigration.attempts}/{selectedMigration.maxAttempts}
</p>
</div>
<span className={`badge ${
@@ -654,7 +648,7 @@ export default function AdminAppsPage() {
? 'badge-red'
: 'badge-blue'
}`}>
{selectedMigration.status}
{migrationStatusLabel(selectedMigration.status)}
</span>
</div>
{selectedMigration.errorMessage && (
@@ -662,10 +656,10 @@ export default function AdminAppsPage() {
)}
<div className="max-h-40 overflow-auto rounded-lg bg-gray-50 p-3 space-y-2">
{selectedMigrationEvents.length === 0 ? (
<p className="text-xs text-gray-400">No events yet.</p>
<p className="text-xs text-gray-400">{aa.noEvents}</p>
) : selectedMigrationEvents.map((event) => (
<div key={event.id} className="text-xs">
<span className="font-mono text-gray-400">{new Date(event.createdAt).toLocaleTimeString()}</span>
<span className="font-mono text-gray-400">{new Date(event.createdAt).toLocaleTimeString(locale)}</span>
<span className={`ml-2 font-medium ${
event.level === 'error' ? 'text-red-600' : event.level === 'warn' ? 'text-amber-600' : 'text-gray-700'
}`}>
@@ -683,7 +677,7 @@ export default function AdminAppsPage() {
className="btn-secondary text-sm inline-flex items-center gap-1"
>
<RefreshCw className={`w-4 h-4 ${retryMigration.isPending ? 'animate-spin' : ''}`} />
Retry migration
{aa.retryMigration}
</button>
)}
</div>
@@ -691,14 +685,14 @@ export default function AdminAppsPage() {
<div className="flex justify-end gap-2">
<button onClick={() => setMigrateApp(null)} className="btn-secondary">
Cancel
{t.common.cancel}
</button>
<button
onClick={() => migrateMutation.mutate({ appId: migrateApp.id, clusterId: targetClusterId })}
disabled={!targetClusterId || migrateMutation.isPending}
className="btn-primary disabled:opacity-50"
>
{migrateMutation.isPending ? 'Queueing...' : 'Start Migration'}
{migrateMutation.isPending ? aa.queueing : aa.startMigration}
</button>
</div>
</div>
+33
View File
@@ -1017,6 +1017,39 @@ const en: Dictionary = {
insufficientRenew: 'Insufficient wallet balance. Top up your wallet or pay via invoice.',
cycles: { hourly: 'Hourly', monthly: 'Monthly', yearly: 'Yearly' },
},
adminApps: {
title: 'All Applications',
count: '{n} application(s)',
matching: ' matching "{q}"',
lifecycle: { active: 'Active', suspended: 'Suspended — Unpaid', pending_deletion: 'Pending Deletion', deleted: 'Deleted' },
cycles: { hourly: 'Hourly', monthly: 'Monthly', yearly: 'Yearly' },
expired: 'Expired', dayShort: 'd', hourShort: 'h', minShort: 'm',
countRunning: 'Running', countDeploying: 'Deploying', countPending: 'Pending',
countStopped: 'Stopped', countFailed: 'Failed', countSuspended: 'Suspended', countPendingDel: 'Pending Del.',
searchPlaceholder: 'Search by app name, user name, email, or user ID…',
noAppsFound: 'No applications found', noResultsFor: 'No results for "{q}". Try a different search.',
noAppsYet: 'No applications yet', noAppsByUser: 'No applications have been created by any user.',
colApplication: 'Application', colOwner: 'Owner', colStatus: 'Status', colService: 'Service', colCluster: 'Cluster',
colMigration: 'Migration', colPlanExpiry: 'Plan / Expiry', colActions: 'Actions',
unknownCluster: 'Unknown cluster', notAssigned: 'Not assigned', noPlan: 'No plan', deletePrefix: 'Delete: {date}',
cluster: 'Cluster', plan: 'Plan', unknown: 'Unknown', na: 'N/A',
view: 'View', migrate: 'Migrate', notAssignedTooltip: 'Application is not assigned to a cluster',
deleteAppTitle: 'Delete Application', deleteAppConfirm: 'Are you sure you want to delete "{name}"?',
replicas: '{n} replica(s)',
migrateApplication: 'Migrate Application',
moveTo: 'Move {name} to a healthy target cluster with logs, retry, and rollback.',
targetCluster: 'Target Cluster', currentCluster: 'Current cluster',
unknownClusterShort: 'Unknown cluster ({id})',
selectHealthyCluster: 'Select healthy cluster',
currentExcludedNote: 'The current cluster is excluded. Migration is blocked for unhealthy, inactive, or maintenance clusters.',
noOtherCluster: 'No other cluster is available as a migration target.',
latestMigration: 'Latest migration', queued: 'queued', attempts: 'attempts',
noEvents: 'No events yet.', retryMigration: 'Retry migration',
startMigration: 'Start Migration', queueing: 'Queueing...',
appDeleted: 'Application deleted', migrationQueued: 'Migration job queued', migrationQueueFailed: 'Failed to queue migration',
migrationRetryQueued: 'Migration retry queued', migrationRetryFailed: 'Failed to retry migration',
migrationStatus: { completed: 'completed', failed: 'failed', rolled_back: 'rolled back', running: 'running', rolling_back: 'rolling back', queued: 'queued' },
},
appDetail: {
productTypeApp: 'Application',
cycles: { hourly: 'Hourly', monthly: 'Monthly', yearly: 'Yearly' },
+33
View File
@@ -1016,6 +1016,39 @@ const fa = {
insufficientRenew: 'موجودی کیف‌پول کافی نیست. کیف‌پول را شارژ کن یا از طریق فاکتور پرداخت کن.',
cycles: { hourly: 'ساعتی', monthly: 'ماهانه', yearly: 'سالانه' },
},
adminApps: {
title: 'همهٔ اپلیکیشن‌ها',
count: '{n} اپلیکیشن',
matching: ' مطابق با «{q}»',
lifecycle: { active: 'فعال', suspended: 'معلق — پرداخت‌نشده', pending_deletion: 'در انتظار حذف', deleted: 'حذف‌شده' },
cycles: { hourly: 'ساعتی', monthly: 'ماهانه', yearly: 'سالانه' },
expired: 'منقضی‌شده', dayShort: 'روز', hourShort: 'ساعت', minShort: 'دقیقه',
countRunning: 'در حال اجرا', countDeploying: 'در حال انتشار', countPending: 'در انتظار',
countStopped: 'متوقف', countFailed: 'ناموفق', countSuspended: 'معلق', countPendingDel: 'در انتظار حذف',
searchPlaceholder: 'جستجو بر اساس نام اپ، نام کاربر، ایمیل یا شناسهٔ کاربر…',
noAppsFound: 'اپلیکیشنی پیدا نشد', noResultsFor: 'نتیجه‌ای برای «{q}» نیست. جستجوی دیگری امتحان کن.',
noAppsYet: 'هنوز اپلیکیشنی نیست', noAppsByUser: 'هیچ کاربری اپلیکیشنی نساخته است.',
colApplication: 'اپلیکیشن', colOwner: 'مالک', colStatus: 'وضعیت', colService: 'سرویس', colCluster: 'کلاستر',
colMigration: 'مهاجرت', colPlanExpiry: 'پلن / انقضا', colActions: 'عملیات',
unknownCluster: 'کلاستر نامشخص', notAssigned: 'تخصیص نیافته', noPlan: 'بدون پلن', deletePrefix: 'حذف: {date}',
cluster: 'کلاستر', plan: 'پلن', unknown: 'نامشخص', na: 'نامشخص',
view: 'مشاهده', migrate: 'مهاجرت', notAssignedTooltip: 'اپلیکیشن به کلاستری تخصیص نیافته است',
deleteAppTitle: 'حذف اپلیکیشن', deleteAppConfirm: 'مطمئنی می‌خواهی «{name}» را حذف کنی؟',
replicas: '{n} رپلیکا',
migrateApplication: 'مهاجرت اپلیکیشن',
moveTo: 'انتقال {name} به یک کلاستر مقصدِ سالم با لاگ، تلاش مجدد و بازگردانی.',
targetCluster: 'کلاستر مقصد', currentCluster: 'کلاستر فعلی',
unknownClusterShort: 'کلاستر نامشخص ({id})',
selectHealthyCluster: 'یک کلاستر سالم انتخاب کن',
currentExcludedNote: 'کلاستر فعلی حذف شده است. مهاجرت برای کلاسترهای ناسالم، غیرفعال یا در حال تعمیر مسدود است.',
noOtherCluster: 'هیچ کلاستر دیگری به‌عنوان مقصد مهاجرت در دسترس نیست.',
latestMigration: 'آخرین مهاجرت', queued: 'در صف', attempts: 'تلاش‌ها',
noEvents: 'هنوز رویدادی نیست.', retryMigration: 'تلاش مجدد مهاجرت',
startMigration: 'شروع مهاجرت', queueing: 'در حال صف‌بندی…',
appDeleted: 'اپلیکیشن حذف شد', migrationQueued: 'وظیفهٔ مهاجرت در صف قرار گرفت', migrationQueueFailed: 'صف‌بندی مهاجرت ناموفق بود',
migrationRetryQueued: 'تلاش مجدد مهاجرت در صف قرار گرفت', migrationRetryFailed: 'تلاش مجدد مهاجرت ناموفق بود',
migrationStatus: { completed: 'کامل', failed: 'ناموفق', rolled_back: 'بازگردانده‌شده', running: 'در حال اجرا', rolling_back: 'در حال بازگردانی', queued: 'در صف' },
},
appDetail: {
productTypeApp: 'اپلیکیشن',
cycles: { hourly: 'ساعتی', monthly: 'ماهانه', yearly: 'سالانه' },
File diff suppressed because one or more lines are too long