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 = { 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 ( {meta.label} {description} ) } /** * Info button opening a legend that explains every possible slot status. */ export const SlotStatusLegend = () => { return (

Slot statuses

How safely your database is keeping the changes the pipeline still needs.

    {WAL_STATUS_LEGEND.map((meta) => (
  • {meta.label}
    {meta.description}
  • ))}
Learn more about monitoring replication
) } /** * 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 ( {isActive ? 'Connected' : 'Not connected'} {isActive ? text.active : text.inactive} ) }