Files
Danny White 7ab3f32625 feat(studio): rebuild the pipeline overview (#49630)
## What kind of change does this PR introduce?

Studio UI improvement.

## What is the current behavior?

The pipeline Overview uses bespoke loading, metrics, table-state and
empty-state layouts that shift while data resolves and repeat status
information from the detail header.

## What is the new behavior?

Rebuilds the Overview around stable **Pipeline health** and **Replicated
tables** sections. It adds layout-matched loading geometry, prioritised
pipeline notices, initial-sync progress, clearer empty states, and
accessible loading announcements. Complete pipeline configuration
remains deferred to #49631.

| Before | After |
| --- | --- |
| <img width="1024" height="759" alt="54861"
src="https://github.com/user-attachments/assets/56e5cc5a-5d49-44c8-94d7-e1f1e0c827d5"
/> | <img width="1024" height="759" alt="Replication Database Agua
Basket Supabase"
src="https://github.com/user-attachments/assets/43b6d0f6-6fd5-47f9-b3e5-788a33511304"
/> |

This is the final independent slice in the review series: #50443,
#50444, #50445, #50446, then this PR. Each PR targets `master` and can
merge on its own. Rebase this PR as earlier slices merge.

## To test

1. Open `/project/<ref>/database/replication` and select a pipeline.
2. Throttle the initial requests and confirm **Pipeline health** and
**Replicated tables** keep their final geometry while loading.
3. Check running, initial-sync, stopped, failed, disconnected and
unavailable states.
4. Confirm the Overview contains Pipeline health and Replicated tables
only, without a Configuration section.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Reorganized replication pipeline status into Pipeline health and
Replicated tables sections.
  - Added loading skeletons with accessible status announcements.
- Added clearer notices for pipeline health, failed or disconnected
pipelines, paused updates, lag, and synchronization progress.
- Improved empty states when table data is unavailable or the pipeline
is inactive.
  - Added options to view logs and reset failed tables.

- **Tests**
- Added coverage for loading behavior, pipeline notices, table counts,
synchronization progress, and empty states.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-17 16:31:04 +10:00

150 lines
5.3 KiB
TypeScript

import { useParams } from 'common'
import { TableEditor } from 'icons'
import { MoreVertical, RotateCcw } from 'lucide-react'
import Link from 'next/link'
import {
Button,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
TableCell,
TableRow,
} from 'ui'
import { ErroredTableDetails } from '../ErroredTableDetails'
import { StateDot } from '../StateDot'
import { SlotLagMetrics as SlotLagMetricsType, TableState } from './ReplicationPipelineStatus.types'
import { getStatusConfig, getTableSyncLagLabel } from './ReplicationPipelineStatus.utils'
import { DropdownMenuItemTooltip } from '@/components/ui/DropdownMenuItemTooltip'
import { ReplicationPipelineTableStatus } from '@/data/replication/pipeline-replication-status-query'
interface TableReplicationRowProps {
table: ReplicationPipelineTableStatus
isRestarting: boolean
showDisabledState: boolean
disabledStateMessage: string
isAnyRestartInProgress: boolean
isPipelineStopped: boolean
onSelectRestart: () => void
onSelectShowError: () => void
}
export const TableReplicationRow = ({
table,
isRestarting,
showDisabledState,
disabledStateMessage,
isAnyRestartInProgress,
isPipelineStopped,
onSelectRestart,
onSelectShowError,
}: TableReplicationRowProps) => {
const { ref } = useParams()
const statusConfig = getStatusConfig(table.state as TableState['state'])
const tableName = `${table.schema}.${table.name}`
const canRestart = !showDisabledState && !isRestarting && !isAnyRestartInProgress
const pipelineAction = isPipelineStopped ? 'start' : 'restart'
const isErrorState = table.state.name === 'error'
const canShowError =
isErrorState && 'reason' in table.state && !showDisabledState && !isRestarting
// A table copying during the initial sync reports its own slot metrics. Shown as one line rather
// than a grid, so the detail survives without a table cell turning into a dashboard.
const syncLag = table.table_sync_lag as SlotLagMetricsType | null | undefined
const syncLagParts = syncLag == null ? undefined : getTableSyncLagLabel(syncLag)
const syncLagLabel =
syncLagParts !== undefined && syncLagParts.length > 0 ? syncLagParts.join(' · ') : undefined
// Status column already names the state (Copying, Queued, …). Prefer the sync line when we have
// one; keep the description only when it adds something the status label doesn't say.
const detailsLine =
syncLagLabel !== undefined ? syncLagLabel : isErrorState ? undefined : statusConfig.description
return (
<TableRow>
<TableCell>{tableName}</TableCell>
<TableCell>
{isRestarting ? (
<StateDot variant="warning" isPulsing>
Resetting
</StateDot>
) : showDisabledState ? (
<StateDot variant="default">Not available</StateDot>
) : (
<StateDot
variant={statusConfig.variant}
isPulsing={statusConfig.isPulsing}
pulseDelayMs={statusConfig.isPulsing ? (table.id % 8) * 55 : undefined}
>
{statusConfig.label}
</StateDot>
)}
</TableCell>
<TableCell>
{isRestarting ? (
<p className="text-sm text-foreground-lighter">
Resetting. The pipeline will {pipelineAction} automatically…
</p>
) : showDisabledState ? (
<p className="text-sm text-foreground-lighter">{disabledStateMessage}</p>
) : isErrorState ? (
<div className="flex flex-col gap-y-3 text-sm text-foreground-lighter">
<p>{statusConfig.description}.</p>
<ErroredTableDetails table={table} />
</div>
) : (
<p className="text-sm text-foreground-lighter">{detailsLine}</p>
)}
</TableCell>
<TableCell>
<div className="flex items-center justify-end gap-x-2">
{canShowError && (
<Button variant="default" onClick={onSelectShowError}>
View error
</Button>
)}
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="default"
className="px-1.25 hit-area-2"
aria-label={`Options for ${tableName}`}
icon={<MoreVertical />}
/>
</DropdownMenuTrigger>
<DropdownMenuContent side="bottom" align="end" className="w-44">
<DropdownMenuItemTooltip
className="gap-x-2"
disabled={!canRestart}
onClick={onSelectRestart}
tooltip={{
content: {
side: 'left',
text: canRestart ? undefined : disabledStateMessage,
},
}}
>
<RotateCcw size={14} />
<span>Reset table</span>
</DropdownMenuItemTooltip>
<DropdownMenuItem className="gap-x-2" asChild>
<Link
target="_blank"
rel="noopener noreferrer"
href={`/project/${ref}/editor/${table.id}`}
>
<TableEditor size={14} />
<span>View in Table Editor</span>
</Link>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</TableCell>
</TableRow>
)
}