diff --git a/src/api/client.ts b/src/api/client.ts index 01fc954..2123666 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -217,6 +217,8 @@ export interface DashboardVPSRoute { vpsInstanceId?: string; assignmentCount: number; peakAssignmentCount: number; + provisionReason?: string; + deprecationReason?: string; trackName: string; protocolName: string; locationName?: string; diff --git a/src/components/VPSOverview.tsx b/src/components/VPSOverview.tsx index 180e8dc..2df4ba6 100644 --- a/src/components/VPSOverview.tsx +++ b/src/components/VPSOverview.tsx @@ -34,6 +34,24 @@ function formatUptime(createdISO: string): string { return `${minutes}m`; } +// Short human-friendly labels for the reason codes the API stamps on +// vps_routes.provision_reason / deprecation_reason. Unknown codes fall +// through with underscores replaced by spaces so they still read cleanly +// on screen (e.g. a future reason code ships before the UI is updated). +const REASON_LABELS: Record = { + pool_deficit: "pool deficit", + capacity_scale_up: "capacity scale-up", + admin_create: "admin create", + blocked_grace: "blocked (grace)", + manual: "manual", + track_deleted: "track deleted", + force_release: "force released", +}; + +function formatReason(code: string): string { + return REASON_LABELS[code] || code.replace(/_/g, " "); +} + interface RegionGroup { regionName: string; city?: string; @@ -415,16 +433,36 @@ function VPSOverview({ routes, summary, isLoading, error }: VPSOverviewProps) { / {route.peakAssignmentCount} - {/* Status / Deprecated badge */} - + {/* Status / Deprecated badge + reason chip */} + {isDeprecated ? ( - - deprecated - + <> + + deprecated + + {route.deprecationReason && ( + + {formatReason(route.deprecationReason)} + + )} + ) : ( - - {route.status} - + <> + + {route.status} + + {route.provisionReason && route.status !== "running" && ( + + {formatReason(route.provisionReason)} + + )} + )}