mirror of
https://github.com/supabase/supabase.git
synced 2026-05-09 10:19:50 -04:00
45f96a197f
## Context Replaces the provider name with the region code in the infrastructure settings overview node diagram - The latter is more important, and we don't really specify the cloud provider anywhere in the dashboard <img width="315" height="137" alt="Screenshot 2026-02-05 at 18 43 11" src="https://github.com/user-attachments/assets/bc6f4dab-e9be-4663-ae1e-50e76b517c86" /> Also made the same changes in the upcoming database replication page too in the form of tooltips And swapped the title + description to be more consistent (Top: type of data, bottom: description), same for the table below Before: <img width="737" height="335" alt="image" src="https://github.com/user-attachments/assets/6674564b-e871-4cd9-83a3-e0bfde7a9f83" /> <img width="287" height="354" alt="image" src="https://github.com/user-attachments/assets/f234de68-107b-470d-804a-bd3b1d9ae9dc" /> After: <img width="637" height="350" alt="image" src="https://github.com/user-attachments/assets/03e08d55-43a1-4a16-8be1-11dd7d14fef3" /> <img width="364" height="357" alt="image" src="https://github.com/user-attachments/assets/0e49df5b-68e5-4652-8dca-4d44ebb8c3ab" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added region metadata with interactive tooltips across replication and database views. * Actions that modify replicas now refresh the list automatically. * Replication diagram layout updated with increased node spacing and a wider zoom-out range. * **Style** * Destination and replica name/ID display reorganized for clearer, two-line presentation. * BigQuery icon now inherits color from CSS for better visual consistency. * Provider/region labels refined for clearer wording. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Alaister Young <a@alaisteryoung.com>
161 lines
5.4 KiB
TypeScript
161 lines
5.4 KiB
TypeScript
import { useParams } from 'common'
|
|
import { Database as DatabaseIcon } from 'icons'
|
|
import { Loader2, Minus, MoreVertical, RotateCcw, Trash } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { useMemo, useState } from 'react'
|
|
import { AWS_REGIONS } from 'shared-data'
|
|
import {
|
|
Badge,
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
TableCell,
|
|
TableRow,
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipTrigger,
|
|
} from 'ui'
|
|
import { ShimmeringLoader } from 'ui-patterns'
|
|
|
|
import { getIsInTransition, getStatusLabel } from './ReadReplicas.utils'
|
|
import { DropReplicaConfirmationModal } from '@/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DropReplicaConfirmationModal'
|
|
import { REPLICA_STATUS } from '@/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.constants'
|
|
import { RestartReplicaConfirmationModal } from '@/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/RestartReplicaConfirmationModal'
|
|
import { useReplicationLagQuery } from '@/data/read-replicas/replica-lag-query'
|
|
import { type Database } from '@/data/read-replicas/replicas-query'
|
|
import { formatDatabaseID } from '@/data/read-replicas/replicas.utils'
|
|
|
|
interface ReadReplicaRow {
|
|
replica: Database
|
|
onUpdateReplica: () => void
|
|
}
|
|
|
|
export const ReadReplicaRow = ({ replica, onUpdateReplica }: ReadReplicaRow) => {
|
|
const { ref } = useParams()
|
|
const { identifier, region, status } = replica
|
|
const formattedId = formatDatabaseID(identifier ?? '')
|
|
|
|
const {
|
|
data: lagDuration,
|
|
isPending: isLoadingLag,
|
|
isError: isErrorLag,
|
|
} = useReplicationLagQuery(
|
|
{
|
|
id: identifier,
|
|
projectRef: ref,
|
|
connectionString: replica.connectionString,
|
|
},
|
|
{ enabled: status === REPLICA_STATUS.ACTIVE_HEALTHY }
|
|
)
|
|
|
|
const [showConfirmRestart, setShowConfirmRestart] = useState(false)
|
|
const [showConfirmDrop, setShowConfirmDrop] = useState(false)
|
|
|
|
const regionMeta = Object.values(AWS_REGIONS).find((x) => x.code === region)
|
|
|
|
const isInTransition = useMemo(() => getIsInTransition({ status }), [status])
|
|
const statusLabel = useMemo(() => getStatusLabel({ status }), [status])
|
|
|
|
return (
|
|
<>
|
|
<TableRow>
|
|
<TableCell>
|
|
<DatabaseIcon size={18} className="text-foreground-light" />
|
|
</TableCell>
|
|
|
|
<TableCell>
|
|
<div>
|
|
<p>Read Replica (ID: {formattedId})</p>
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<p className="text-foreground-lighter w-fit">{regionMeta?.displayName}</p>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="right">{regionMeta?.code}</TooltipContent>
|
|
</Tooltip>
|
|
</div>
|
|
</TableCell>
|
|
|
|
<TableCell>
|
|
<div className="flex items-center gap-x-2">
|
|
<Badge
|
|
variant={
|
|
statusLabel === 'Healthy'
|
|
? 'success'
|
|
: statusLabel === 'Failed'
|
|
? 'destructive'
|
|
: 'default'
|
|
}
|
|
>
|
|
{statusLabel}
|
|
</Badge>
|
|
{isInTransition && <Loader2 className="animate-spin w-3 h-3" />}
|
|
</div>
|
|
</TableCell>
|
|
|
|
<TableCell>
|
|
{isErrorLag || status !== REPLICA_STATUS.ACTIVE_HEALTHY ? (
|
|
<Minus size={18} className="text-foreground-lighter" />
|
|
) : isLoadingLag ? (
|
|
<ShimmeringLoader />
|
|
) : (
|
|
<p>{lagDuration}s</p>
|
|
)}
|
|
</TableCell>
|
|
|
|
<TableCell>
|
|
<Minus size={18} className="text-foreground-lighter" />
|
|
</TableCell>
|
|
|
|
<TableCell>
|
|
<div className="flex items-center justify-end gap-x-2">
|
|
<Button asChild type="default" className="relative" disabled={status === 'GOING_DOWN'}>
|
|
<Link href={`/project/${ref}/database/replication/replica/${replica.identifier}`}>
|
|
View replication
|
|
</Link>
|
|
</Button>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger>
|
|
<Button type="default" icon={<MoreVertical />} className="w-7" />
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-52">
|
|
<DropdownMenuItem
|
|
className="gap-x-2"
|
|
disabled={status !== 'ACTIVE_HEALTHY'}
|
|
onClick={() => setShowConfirmRestart(true)}
|
|
>
|
|
<RotateCcw size={14} />
|
|
<span>Restart replica</span>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem
|
|
className="gap-x-2"
|
|
disabled={status === 'GOING_DOWN'}
|
|
onClick={() => setShowConfirmDrop(true)}
|
|
>
|
|
<Trash size={14} />
|
|
<span>Drop replica</span>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</div>
|
|
</TableCell>
|
|
</TableRow>
|
|
|
|
<DropReplicaConfirmationModal
|
|
selectedReplica={showConfirmDrop ? replica : undefined}
|
|
onSuccess={() => onUpdateReplica()}
|
|
onCancel={() => setShowConfirmDrop(false)}
|
|
/>
|
|
|
|
<RestartReplicaConfirmationModal
|
|
selectedReplica={showConfirmRestart ? replica : undefined}
|
|
onSuccess={() => onUpdateReplica()}
|
|
onCancel={() => setShowConfirmRestart(false)}
|
|
/>
|
|
</>
|
|
)
|
|
}
|