Files
supabase/apps/studio/components/interfaces/Database/Replication/EnableReplicationCallout.tsx
T
Riccardo Busetti 324c724117 ref(replication): Improve replication copy and UI (#46793)
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 -->
2026-06-11 10:58:36 +00:00

114 lines
3.7 KiB
TypeScript

import { useParams } from 'common'
import { useState } from 'react'
import { toast } from 'sonner'
import {
Button,
cn,
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogSection,
DialogSectionSeparator,
DialogTitle,
DialogTrigger,
} from 'ui'
import { Admonition } from 'ui-patterns'
import { DestinationType } from './DestinationPanel/DestinationPanel.types'
import { DocsButton } from '@/components/ui/DocsButton'
import { UpgradePlanButton } from '@/components/ui/UpgradePlanButton'
import { useCreateTenantSourceMutation } from '@/data/replication/create-tenant-source-mutation'
import { DOCS_URL } from '@/lib/constants'
const EnableReplicationModal = () => {
const { ref: projectRef } = useParams()
const [open, setOpen] = useState(false)
const { mutate: createTenantSource, isPending: creatingTenantSource } =
useCreateTenantSourceMutation({
onSuccess: () => {
toast.success('External replication has been successfully enabled!')
setOpen(false)
},
onError: (error) => {
toast.error(`Failed to enable external replication: ${error.message}`)
},
})
const onEnableReplication = async () => {
if (!projectRef) return console.error('Project ref is required')
createTenantSource({ projectRef })
}
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<Button type="primary" className="w-min">
Enable external replication
</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Enable external replication</DialogTitle>
</DialogHeader>
<DialogSectionSeparator />
<DialogSection className="flex flex-col gap-y-2 p-0!">
<Admonition
type="warning"
className="rounded-none border-0"
title="Replication is currently in alpha"
>
<p className="text-sm leading-normal!">
External replication streams database changes to destinations outside your Supabase
project. The feature is in active development and may change as we gather feedback.
</p>
<p className="text-sm leading-normal!">
Pricing is not finalized. You can enable external replication now; we'll announce
pricing later and notify you before any charges apply.
</p>
</Admonition>
</DialogSection>
<DialogFooter>
<Button type="default" disabled={creatingTenantSource} onClick={() => setOpen(false)}>
Cancel
</Button>
<Button type="primary" loading={creatingTenantSource} onClick={onEnableReplication}>
Enable external replication
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}
export const EnableReplicationCallout = ({
type,
className,
hasAccess,
}: {
type?: DestinationType | null
className?: string
hasAccess: boolean
}) => {
return (
<div className={cn('border rounded-md p-4 md:p-12 flex flex-col gap-y-4', className)}>
<div className="flex flex-col gap-y-1">
<h4>Replicate data to external destinations in real time</h4>
<p className="text-sm text-foreground-light">
{hasAccess ? 'Enable external replication' : 'Upgrade to the Pro plan'} to start
replicating your database changes to {type ?? 'data warehouses and analytics platforms'}.
</p>
</div>
<div className="flex gap-x-2">
{hasAccess ? (
<EnableReplicationModal />
) : (
<UpgradePlanButton source="replication" featureProposition="use replication" />
)}
<DocsButton href={`${DOCS_URL}/guides/database/replication#replication`} />
</div>
</div>
)
}