mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 12:25:05 +03:00
This PR improves the replication UI in the following ways: - Adds a new selecion picker for destinations which is split by the destination location and it's clearer and can scale more when we add more destinations. - Adds a much improved section on lag, highlighting new metrics that could help debug issues more easily. - Improves the copy across the whole code. - Fixes the 2d topological view of replication with better status handling. ### Screenshots <img width="1270" height="777" alt="image" src="https://github.com/user-attachments/assets/0ffc890e-2f80-47e5-bdb1-75071adda024" /> <img width="1665" height="656" alt="image" src="https://github.com/user-attachments/assets/23a27a02-acb2-4891-af95-5bc1d6ec7bfe" /> <img width="1454" height="247" alt="image" src="https://github.com/user-attachments/assets/c8799983-aa63-42b2-9370-ae4e009c1573" /> <img width="1120" height="340" alt="image" src="https://github.com/user-attachments/assets/20a18ad6-e5a9-40ec-80d4-42d6f783d868" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Live slot health indicators, legend, and connection badges. * Grouped destination type dropdown with alpha badges. * **Improvements** * Clearer UI copy for external destinations, alpha disclaimers, and onboarding flows. * Consolidated "n/a" handling for lag displays and richer metric tooltips. * Simplified replication diagram visuals and clearer table/row status/lag presentation. * Replication status responses now include expanded slot health and lag metrics. * **Tests** * New test suites covering destination selection and destination row states. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
136 lines
4.5 KiB
TypeScript
136 lines
4.5 KiB
TypeScript
import { Info } from 'lucide-react'
|
|
import {
|
|
Badge,
|
|
cn,
|
|
Popover,
|
|
PopoverContent,
|
|
PopoverTrigger,
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipTrigger,
|
|
} from 'ui'
|
|
|
|
import { SlotWalStatus } from './ReplicationPipelineStatus.types'
|
|
import { getWalStatusMeta, WAL_STATUS_LEGEND } from './ReplicationPipelineStatus.utils'
|
|
import { InlineLink } from '@/components/ui/InlineLink'
|
|
import { DOCS_URL } from '@/lib/constants'
|
|
|
|
export type SlotStatusContext = 'pipeline' | 'table'
|
|
|
|
const CONNECTION_TEXT: Record<SlotStatusContext, { active: string; inactive: string }> = {
|
|
pipeline: {
|
|
active: "This pipeline's replication slot is active and being used right now.",
|
|
inactive: "This pipeline's replication slot is not active right now.",
|
|
},
|
|
table: {
|
|
active: "This table's replication slot is active and being used right now.",
|
|
inactive: "This table's replication slot is not active right now.",
|
|
},
|
|
}
|
|
|
|
/**
|
|
* Colored badge for a slot's WAL status, with the plain-language meaning on hover.
|
|
* Pass `context="table"` in the per-table inline view to show table-specific descriptions.
|
|
*/
|
|
export const SlotStatusBadge = ({
|
|
status,
|
|
context = 'pipeline',
|
|
}: {
|
|
status?: SlotWalStatus
|
|
context?: SlotStatusContext
|
|
}) => {
|
|
const meta = getWalStatusMeta(status)
|
|
const description = context === 'table' ? meta.tableDescription : meta.description
|
|
return (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Badge variant={meta.variant} className="cursor-default">
|
|
{meta.label}
|
|
</Badge>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="bottom" className="max-w-[260px]">
|
|
{description}
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Info button opening a legend that explains every possible slot status.
|
|
*/
|
|
export const SlotStatusLegend = () => {
|
|
return (
|
|
<Popover>
|
|
<PopoverTrigger asChild>
|
|
<button
|
|
type="button"
|
|
aria-label="What do the slot statuses mean?"
|
|
className="inline-flex h-4 w-4 items-center justify-center rounded-full bg-surface-200 text-foreground-lighter transition-colors hover:bg-surface-300 hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-foreground-lighter"
|
|
>
|
|
<Info size={12} />
|
|
</button>
|
|
</PopoverTrigger>
|
|
<PopoverContent side="bottom" align="center" className="w-[26rem] p-0">
|
|
<div className="px-4 py-3 border-b border-overlay">
|
|
<p className="text-sm text-foreground">Slot statuses</p>
|
|
<p className="text-xs text-foreground-light">
|
|
How safely your database is keeping the changes the pipeline still needs.
|
|
</p>
|
|
</div>
|
|
<ul className="flex flex-col divide-y divide-overlay">
|
|
{WAL_STATUS_LEGEND.map((meta) => (
|
|
<li key={meta.label} className="flex items-start gap-x-3 px-4 py-2.5">
|
|
<div className="flex h-5 w-28 shrink-0 items-center">
|
|
<Badge variant={meta.variant}>{meta.label}</Badge>
|
|
</div>
|
|
<span className="flex-1 text-xs leading-5 text-foreground-light">
|
|
{meta.description}
|
|
</span>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
<div className="border-t border-overlay px-4 py-2.5">
|
|
<InlineLink
|
|
href={`${DOCS_URL}/guides/database/replication/external-replication-monitoring`}
|
|
className="text-xs text-foreground-light"
|
|
>
|
|
Learn more about monitoring replication
|
|
</InlineLink>
|
|
</div>
|
|
</PopoverContent>
|
|
</Popover>
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Small dot + label indicating whether the slot has a live replication connection.
|
|
* Pass `context="table"` in the per-table inline view to show table-specific descriptions.
|
|
*/
|
|
export const SlotConnectionIndicator = ({
|
|
isActive,
|
|
context = 'pipeline',
|
|
}: {
|
|
isActive?: boolean
|
|
context?: SlotStatusContext
|
|
}) => {
|
|
const text = CONNECTION_TEXT[context]
|
|
return (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<span className="flex items-center gap-x-1.5 text-xs text-foreground-light cursor-default">
|
|
<span
|
|
className={cn(
|
|
'h-1.5 w-1.5 rounded-full shrink-0',
|
|
isActive ? 'bg-brand' : 'bg-foreground-muted'
|
|
)}
|
|
/>
|
|
{isActive ? 'Connected' : 'Not connected'}
|
|
</span>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="bottom" className="max-w-[260px]">
|
|
{isActive ? text.active : text.inactive}
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
)
|
|
}
|