Files
supabase/apps/studio/components/interfaces/Issues/IssueAffectedResources.tsx
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

88 lines
2.9 KiB
TypeScript

import { useParams } from 'common'
import { useState } from 'react'
import { Button, Card, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from 'ui'
import { LintCTA } from '../Linter/Linter.utils'
import { Markdown } from '../Markdown'
import { formatIssueResource, sortAffected } from './Issues.utils'
import { DynamicLink } from '@/components/ui/DynamicLink'
import type { Issue, IssueAffectedResource } from '@/data/issues/issue.types'
const COLLAPSED_ROW_COUNT = 5
const AffectedResourceFix = ({ affected }: { affected: IssueAffectedResource }) => {
const { ref } = useParams()
if (ref && affected.lint) {
return <LintCTA title={affected.lint.name} projectRef={ref} metadata={affected.lint.metadata} />
}
if (affected.action) {
return (
<Button asChild variant="default">
<DynamicLink href={affected.action.href}>{affected.action.label}</DynamicLink>
</Button>
)
}
return null
}
const AffectedResourceRow = ({ affected }: { affected: IssueAffectedResource }) => (
<TableRow>
<TableCell className="whitespace-nowrap align-top text-foreground">
{formatIssueResource(affected.resource)}
</TableCell>
<TableCell className="min-w-64 align-top">
{affected.detail && <Markdown className="text-foreground-light">{affected.detail}</Markdown>}
</TableCell>
<TableCell className="text-right align-top">
<AffectedResourceFix affected={affected} />
</TableCell>
</TableRow>
)
const AffectedResourceTable = ({ issue }: { issue: Issue }) => {
const [isExpanded, setIsExpanded] = useState(false)
const affected = sortAffected(issue.affected)
const visible = isExpanded ? affected : affected.slice(0, COLLAPSED_ROW_COUNT)
const hiddenCount = affected.length - visible.length
return (
<section aria-labelledby="issue-affected-heading" className="flex flex-col gap-3">
<h2 id="issue-affected-heading" className="text-sm text-foreground">
Affected resources
</h2>
<Card>
<Table>
<TableHeader>
<TableRow>
<TableHead>Resource</TableHead>
<TableHead>Detail</TableHead>
<TableHead className="text-right">
<span className="sr-only">Fix</span>
</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{visible.map((item) => (
<AffectedResourceRow key={item.id} affected={item} />
))}
</TableBody>
</Table>
</Card>
{hiddenCount > 0 && (
<div>
<Button variant="default" size="tiny" onClick={() => setIsExpanded(true)}>
Show {hiddenCount.toLocaleString()} more
</Button>
</div>
)}
</section>
)
}
export const IssueAffectedResources = ({ issue }: { issue: Issue }) => {
if (issue.affected.length === 0) return null
return <AffectedResourceTable issue={issue} />
}