Files
Alaister YoungandAlaister Young df798783e1 [FE-5108] (part 4) refactor(studio): migrate integrations, settings & observability off next/link (#54307)
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>
2026-12-01 17:02:11 +08:00

95 lines
3.9 KiB
TypeScript

import { Link } from '@tanstack/react-router'
import { useParams } from 'common'
import { AlertTriangleIcon, ExternalLinkIcon } from 'lucide-react'
import { useState } from 'react'
import { Alert, AlertDescription, AlertTitle, Button } from 'ui'
import ConfirmDisableReadOnlyModeModal from './DatabaseSettings/ConfirmDisableReadOnlyModal'
import { InlineLinkClassName } from '@/components/ui/InlineLink'
import { useResourceWarningsQuery } from '@/data/usage/resource-warnings-query'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
import { DOCS_URL } from '@/lib/constants'
export const DatabaseReadOnlyAlert = () => {
const { ref: projectRef } = useParams()
const { data: organization } = useSelectedOrganizationQuery()
const [showConfirmationModal, setShowConfirmationModal] = useState(false)
const { data: resourceWarnings } = useResourceWarningsQuery({ ref: projectRef })
// [Joshen Cleanup] JFYI this can be cleaned up once BE changes are live which will only return the warnings based on the provided ref
// No longer need to filter by ref on the client side
const isReadOnlyMode =
(resourceWarnings ?? [])?.find((warning) => warning.project === projectRef)
?.is_readonly_mode_enabled ?? false
return (
<>
{isReadOnlyMode && (
<Alert variant="destructive">
<AlertTriangleIcon />
<AlertTitle>
Project is in read-only mode and database is no longer accepting write requests
</AlertTitle>
<AlertDescription>
You have reached 95% of your project's disk space, and read-only mode has been enabled
to preserve your database's stability and prevent your project from exceeding its
current billing plan. To resolve this, you may:
<ul className="list-disc pl-6 mt-1">
<li>
Temporarily disable read-only mode to free up space and reduce your database size
</li>
{organization?.plan.id === 'free' ? (
<li>
<Link
to="/org/$slug/billing"
params={{ slug: organization?.slug ?? '_' }}
search={{
panel: 'subscriptionPlan',
source: 'databaseReadOnlyAlertUpgradePlan',
}}
className={InlineLinkClassName}
>
Upgrade to the Pro Plan
</Link>{' '}
to increase your database size limit to 8GB.
</li>
) : organization?.plan.id === 'pro' && organization?.usage_billing_enabled ? (
<li>
<Link
to="/org/$slug/billing"
params={{ slug: organization?.slug ?? '_' }}
search={{
panel: 'subscriptionPlan',
source: 'databaseReadOnlyAlertSpendCap',
}}
className={InlineLinkClassName}
>
Disable your Spend Cap
</Link>{' '}
to allow your project to auto-scale and expand beyond the 8GB database size limit
</li>
) : null}
</ul>
</AlertDescription>
<div className="mt-4 flex items-center space-x-2">
<Button onClick={() => setShowConfirmationModal(true)}>Disable read-only mode</Button>
<Button asChild icon={<ExternalLinkIcon />}>
<a
href={`${DOCS_URL}/guides/platform/database-size#disabling-read-only-mode`}
target="_blank"
rel="noreferrer"
>
Learn more
</a>
</Button>
</div>
</Alert>
)}
<ConfirmDisableReadOnlyModeModal
visible={showConfirmationModal}
onClose={() => setShowConfirmationModal(false)}
/>
</>
)
}