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

158 lines
5.0 KiB
TypeScript

import { useParams } from 'common'
import { Issues } from 'icons'
import { ExternalLinkIcon } from 'lucide-react'
import type { ComponentProps, ReactNode } from 'react'
import { Admonition } from 'ui-patterns/Admonition'
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
import { asGraphqlExposureLint, GraphqlExposureCallout } from '../Linter/GraphqlExposureLintCTA'
import { Markdown } from '../Markdown'
import { IssueAffectedResources } from './IssueAffectedResources'
import { IssueDetailToolbar } from './IssueDetailToolbar'
import { CATEGORY_ICONS, CATEGORY_LABELS, SEVERITY_LABELS } from './Issues.constants'
import { SeverityIndicator } from './SeverityIndicator'
import {
ExplorerToolbar,
ExplorerToolbarIcon,
} from '@/components/interfaces/Explorer/ExplorerToolbar'
import { AlertError } from '@/components/ui/AlertError'
import type { Issue } from '@/data/issues/issue.types'
import { useProjectIssues } from '@/data/issues/useProjectIssues'
const IssueDetailLayout = ({
toolbar,
header,
children,
...props
}: {
toolbar: ReactNode
header: ReactNode
children: ReactNode
} & Omit<ComponentProps<'div'>, 'className'>) => (
<div className="flex h-full flex-col bg-card" {...props}>
{toolbar}
<div className="min-h-0 flex-1 overflow-y-auto">
<article className="mx-auto flex w-full max-w-3xl flex-col gap-6 px-6 pb-16 pt-12">
<header className="flex flex-col gap-2">{header}</header>
<div className="flex min-w-0 flex-col gap-8">{children}</div>
</article>
</div>
</div>
)
const IssueMeta = ({ issue }: { issue: Issue }) => {
const CategoryIcon = CATEGORY_ICONS[issue.category]
return (
<p className="flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-foreground-light">
<span className="flex items-center gap-1.5">
<SeverityIndicator severity={issue.severity} aria-hidden />
{SEVERITY_LABELS[issue.severity]}
</span>
<span aria-hidden className="text-foreground-muted">
·
</span>
<span className="flex items-center gap-1.5">
<CategoryIcon size={14} aria-hidden className="text-foreground-lighter" />
{CATEGORY_LABELS[issue.category]}
</span>
<span aria-hidden className="text-foreground-muted">
·
</span>
<a
href={issue.docsUrl}
target="_blank"
rel="noreferrer noopener"
className="flex items-center gap-1.5 hover:text-foreground"
>
View docs
<ExternalLinkIcon size={14} aria-hidden />
</a>
</p>
)
}
const DESCRIPTION_LINE_WIDTHS = ['w-full', 'w-11/12', 'w-4/5', 'w-2/3']
const IssueDetailSkeleton = () => (
<IssueDetailLayout
role="status"
aria-label="Loading issue"
toolbar={
<ExplorerToolbar aria-hidden className="md:h-(--header-height)">
<ExplorerToolbarIcon>
<Issues size={16} strokeWidth={2} />
</ExplorerToolbarIcon>
<ShimmeringLoader className="h-3 w-48 py-0" />
</ExplorerToolbar>
}
header={
<>
<div className="flex h-8 items-center">
<ShimmeringLoader className="h-6 w-2/3 py-0" />
</div>
<div className="flex h-5 items-center">
<ShimmeringLoader className="h-3 w-64 py-0" delayIndex={1} />
</div>
</>
}
>
<div className="flex flex-col gap-1">
{DESCRIPTION_LINE_WIDTHS.map((width, index) => (
<div key={width} className="flex h-5 items-center">
<ShimmeringLoader className={`h-3 py-0 ${width}`} delayIndex={index} />
</div>
))}
</div>
</IssueDetailLayout>
)
export const IssueDetail = () => {
const { ref, id } = useParams()
const { issues, error, isLoading, isError, isHealthLoading } = useProjectIssues({
projectRef: ref,
})
const issue = issues.find((item) => item.id === id)
if (!issue && (isLoading || isHealthLoading)) return <IssueDetailSkeleton />
if (isError) {
return (
<div className="h-full bg-card px-6 py-10">
<div className="mx-auto max-w-3xl">
<AlertError error={error} subject="Failed to retrieve issue" />
</div>
</div>
)
}
if (!issue) {
return (
<div className="flex h-full items-center justify-center bg-card p-6">
<Admonition
type="default"
className="max-w-md"
title="Issue not found"
description="The check may have stopped failing, or the link points to another project."
/>
</div>
)
}
return (
<IssueDetailLayout
toolbar={<IssueDetailToolbar issue={issue} />}
header={
<>
<h1 className="text-2xl text-foreground">{issue.title}</h1>
<IssueMeta issue={issue} />
</>
}
>
<section aria-label="Issue description" className="min-w-0">
<Markdown className="text-base text-foreground-light">{issue.description}</Markdown>
</section>
{ref && asGraphqlExposureLint(issue.id) && <GraphqlExposureCallout projectRef={ref} />}
<IssueAffectedResources key={issue.id} issue={issue} />
</IssueDetailLayout>
)
}