mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
Part 4 of a 6-PR stack migrating all `next/link` imports in `apps/studio` onto TanStack Router's `Link` (or plain `<a>` for known external URLs) and removing `compat/next/link.tsx`. | Part | PR | Scope | | --- | --- | --- | | 1 | #54304 | `data/prefetchers/PrefetchableLink.tsx` and `components/ui/**` | | 2 | #54305 | `components/layouts/**` and top-level shell components | | 3 | #54306 | Database, TableGridEditor, Storage, SQLEditor, BranchManagement, Branching, Functions, Realtime | | **4** | **#54307 ← this PR** | **Integrations, Settings, Observability, LogDrains, Issues, Linter, Reports, QueryPerformance, QuerySources, ConfigDrift, DiskManagement, Compute** | | 5 | #54308 | Remaining `components/interfaces/**` (Org, Billing, Auth, Support, Home, SignIn, ConnectSheet, etc.) | | 6 | #54309 | Remove `compat/next/link.tsx` shim, Vite alias, and update basePath tests/docs | Migrates `components/interfaces/{Integrations,Settings,Observability,LogDrains,Issues,Linter,Reports,QueryPerformance,QuerySources,ConfigDrift,DiskManagement,Compute}/` off `next/link`. **Changed:** - Replaced `next/link` across all 72 files in Integrations, Settings, Observability, LogDrains, Issues, Linter, Reports, QueryPerformance, QuerySources, ConfigDrift, DiskManagement, and Compute interfaces - Updated legacy permanent-redirect hrefs (`/settings/database` → `/database/settings`, `/settings/vault/secrets` → `/integrations/vault/secrets`, `/reports/database#database-size-report` → `/observability/database#database-size-report`) to canonical routes - Flattened legacy nested `<Link><a>...</a></Link>` markup in `DatabaseReadOnlyAlert.tsx` and dropped `passHref` in `Integrations/Queues/QueueTab.tsx` - Standardized external `target="_blank"` anchors with `rel="noreferrer noopener"`, switched `ObservabilityOverviewFooter.tsx` to `InlineLink` + `DOCS_URL`, and applied `InlineLinkClassName` to the typed billing links in `DatabaseReadOnlyAlert.tsx` per review feedback - Removed `vi.mock('next/link', ...)` from `Settings/General/Project.test.tsx` and `MobileIssuesNavigation.platform.test.tsx` Addresses [FE-5108](https://linear.app/supabase/issue/FE-5108/replace-the-nextlink-shim-with-tanstack-link) ## To test - [ ] Navigate across Integrations (marketplace, cron, queues, wrappers, Vercel/GitHub), Settings (database, infrastructure, read replicas, logs), Observability, Issues, and Compute pages - [ ] Verify Logs Preview → Logs Explorer links preserve multi-line SQL queries in search params - [ ] Verify billing and database-size links preserve query parameters and hash fragments --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
156 lines
5.2 KiB
TypeScript
156 lines
5.2 KiB
TypeScript
import { Link } from '@tanstack/react-router'
|
|
import { useParams } from 'common'
|
|
import { Database as DatabaseIcon } from 'icons'
|
|
import { Loader2Icon, MinusIcon, MoreVerticalIcon, RotateCcwIcon, TrashIcon } from 'lucide-react'
|
|
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/ShimmeringLoader'
|
|
|
|
import { DropReplicaConfirmationModal } from './DropReplicaConfirmationModal'
|
|
import { REPLICA_STATUS } from './ReadReplicas.constants'
|
|
import { getIsInTransition, getStatusLabel } from './ReadReplicas.utils'
|
|
import { RestartReplicaConfirmationModal } from './RestartReplicaConfirmationModal'
|
|
import { getReadReplicaPath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'
|
|
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 && <Loader2Icon className="animate-spin w-3 h-3" />}
|
|
</div>
|
|
</TableCell>
|
|
|
|
<TableCell>
|
|
{isErrorLag || status !== REPLICA_STATUS.ACTIVE_HEALTHY ? (
|
|
<MinusIcon size={18} className="text-foreground-lighter" />
|
|
) : isLoadingLag ? (
|
|
<ShimmeringLoader />
|
|
) : (
|
|
<p>{lagDuration}s</p>
|
|
)}
|
|
</TableCell>
|
|
|
|
<TableCell>
|
|
<div className="flex items-center justify-end gap-x-2">
|
|
<Button asChild className="relative" disabled={status === 'GOING_DOWN'}>
|
|
<Link to={getReadReplicaPath(ref, replica.identifier)}>View replica</Link>
|
|
</Button>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button icon={<MoreVerticalIcon />} className="w-7" />
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-52">
|
|
<DropdownMenuItem
|
|
className="gap-x-2"
|
|
disabled={status !== 'ACTIVE_HEALTHY'}
|
|
onClick={() => setShowConfirmRestart(true)}
|
|
>
|
|
<RotateCcwIcon size={14} />
|
|
<span>Restart replica</span>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem
|
|
className="gap-x-2"
|
|
disabled={status === 'GOING_DOWN'}
|
|
onClick={() => setShowConfirmDrop(true)}
|
|
>
|
|
<TrashIcon 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)}
|
|
/>
|
|
</>
|
|
)
|
|
}
|