import { Check, Circle, Loader2 } from 'lucide-react' import { Card, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, cn } from 'ui' import { BACKUP_STEP, DATABASE_UPGRADE_STEPS } from './UpgradingState.constants' type UpgradeStepsTableProps = | { /** * Pre-upgrade view: all steps shown as pending */ variant: 'pending' } | { /** * Active upgrade view: shows current progress through steps */ variant: 'upgrading' progress: string | undefined } | { /** * Backing up view: all upgrade steps completed, backup step in progress */ variant: 'backingUp' } | { /** * Completed view: all steps including backup shown as completed */ variant: 'completed' } | { /** * Failed view: all steps shown as completed (project is back online) */ variant: 'failed' } export const UpgradeStepsTable = (props: UpgradeStepsTableProps) => { const { variant } = props const progress = variant === 'upgrading' ? props.progress : undefined const progressStage = Number((progress || '').split('_')[0]) const isTerminalState = variant === 'completed' || variant === 'failed' const showProgress = variant === 'upgrading' || variant === 'backingUp' || isTerminalState const allUpgradeStepsCompleted = variant === 'backingUp' || isTerminalState // Only append backup step when actively backing up const steps = variant === 'backingUp' ? [...DATABASE_UPGRADE_STEPS, BACKUP_STEP] : DATABASE_UPGRADE_STEPS return ( Step Description Status {steps.map((step, idx) => { const isBackupStep = step.key === BACKUP_STEP.key const isFirstStep = idx === 0 // Show the first step as current immediately when upgrade starts (progress is undefined) // This is to give visual feedback that something is happening const isCurrentStep = isTerminalState ? false // No step is "current" in terminal states : isBackupStep ? variant === 'backingUp' : showProgress && !allUpgradeStepsCompleted && (step.key === progress || (progress === undefined && isFirstStep)) const isCompletedStep = isTerminalState ? true // All steps are completed in terminal states : !isBackupStep && showProgress && (allUpgradeStepsCompleted || progressStage > idx) const statusText = 'offline' in step && step.offline ? 'Project offline' : null return (

{/* Manual strike-through to ensure proper centering */} {isCurrentStep ? step.activeTitle : step.staticTitle}

{statusText && (

{statusText}

)}
) })}
) } interface StepIndicatorProps { isCurrentStep: boolean isCompletedStep: boolean } const StepIndicator = ({ isCurrentStep, isCompletedStep }: StepIndicatorProps) => { if (isCurrentStep) { return (
) } if (isCompletedStep) { return (
) } return (
) }