import { Badge, StatusDot, MonoText } from '@cameleer/design-system'; import type { Deployment, AppVersion } from '../../../../api/queries/admin/apps'; import { timeAgo } from '../../../../utils/format-utils'; import styles from '../AppDeploymentPage.module.css'; const STATUS_COLORS = { RUNNING: 'success', STARTING: 'warning', FAILED: 'error', STOPPED: 'auto', DEGRADED: 'warning', STOPPING: 'auto', } as const; const DEPLOY_STATUS_DOT = { RUNNING: 'live', STARTING: 'running', DEGRADED: 'stale', STOPPING: 'stale', STOPPED: 'dead', FAILED: 'error', } as const; interface Props { deployment: Deployment; version: AppVersion | null; externalUrl: string; } export function StatusCard({ deployment, version, externalUrl }: Props) { const running = deployment.replicaStates?.filter((r) => r.status === 'RUNNING').length ?? 0; const total = deployment.replicaStates?.length ?? 0; return (
{version && }
{version && <>JAR{version.jarFilename}} {version && <>Checksum{version.jarChecksum.substring(0, 12)}} Replicas{running}/{total} Strategy{deployment.deploymentStrategy ?? '—'} URL {deployment.status === 'RUNNING' ? {externalUrl} : {externalUrl}} Deployed{deployment.deployedAt ? timeAgo(deployment.deployedAt) : '—'}
{deployment.status === 'FAILED' && deployment.errorMessage && (
Failure reason {deployment.errorMessage}
)}
); }