mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +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>
131 lines
4.9 KiB
TypeScript
131 lines
4.9 KiB
TypeScript
import { useFlag, useParams } from 'common'
|
|
import { ChevronRightIcon } from 'lucide-react'
|
|
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
import {
|
|
CATEGORY_ICONS,
|
|
CATEGORY_LABELS,
|
|
ISSUE_CATEGORIES,
|
|
ISSUE_SEVERITIES,
|
|
SEVERITY_LABELS,
|
|
} from './Issues.constants'
|
|
import { IssuesLegacyRedirect } from './IssuesLegacyRedirect'
|
|
import { SeverityIndicator } from './SeverityIndicator'
|
|
import { AlertError } from '@/components/ui/AlertError'
|
|
import { DocsButton } from '@/components/ui/DocsButton'
|
|
import { DynamicLink } from '@/components/ui/DynamicLink'
|
|
import type { IssueSeverity } from '@/data/issues/issue.types'
|
|
import { useProjectIssues } from '@/data/issues/useProjectIssues'
|
|
import { DOCS_URL } from '@/lib/constants'
|
|
|
|
const countBy = <T extends string>(values: T[]) =>
|
|
values.reduce<Record<string, number>>((counts, value) => {
|
|
counts[value] = (counts[value] ?? 0) + 1
|
|
return counts
|
|
}, {})
|
|
|
|
export const IssuesOverview = () => {
|
|
const { ref } = useParams()
|
|
const isHealthAdvisorEnabled = useFlag('healthAdvisor')
|
|
const { issues, error, isLoading, isError, isSuccess } = useProjectIssues({ projectRef: ref })
|
|
|
|
const severityCounts = countBy(issues.map((issue) => issue.severity))
|
|
const categoryCounts = countBy(issues.map((issue) => issue.category))
|
|
const categories = ISSUE_CATEGORIES.filter(
|
|
(category) => category !== 'health' || isHealthAdvisorEnabled
|
|
)
|
|
|
|
return (
|
|
<div className="h-full overflow-y-auto bg-card">
|
|
<IssuesLegacyRedirect />
|
|
<div className="mx-auto flex w-full max-w-3xl flex-col gap-10 px-6 pb-16 pt-10">
|
|
<header className="flex items-start justify-between gap-4">
|
|
<div className="flex flex-col gap-1">
|
|
<h1 className="text-2xl text-foreground">Issues</h1>
|
|
<p className="text-sm text-foreground-light">
|
|
Problems found in this project by Supabase checks
|
|
</p>
|
|
</div>
|
|
<DocsButton href={`${DOCS_URL}/guides/observability/advisors`} />
|
|
</header>
|
|
|
|
{isLoading && <GenericSkeletonLoader />}
|
|
{isError && <AlertError error={error} subject="Failed to retrieve issues" />}
|
|
{isSuccess && (
|
|
<>
|
|
<section
|
|
aria-label="Open issues by severity"
|
|
className="grid grid-cols-2 gap-3 sm:grid-cols-4"
|
|
>
|
|
<StatCard label="Open" value={issues.length} href={`/project/${ref}/issues`} />
|
|
{ISSUE_SEVERITIES.map((severity) => (
|
|
<StatCard
|
|
key={severity}
|
|
label={SEVERITY_LABELS[severity]}
|
|
value={severityCounts[severity] ?? 0}
|
|
severity={severity}
|
|
href={`/project/${ref}/issues?severity=${severity}`}
|
|
/>
|
|
))}
|
|
</section>
|
|
|
|
<section aria-labelledby="issues-by-category" className="flex flex-col gap-3">
|
|
<h2 id="issues-by-category" className="text-sm text-foreground">
|
|
Open by category
|
|
</h2>
|
|
<ul className="flex flex-col divide-y rounded-md border">
|
|
{categories.map((category) => {
|
|
const Icon = CATEGORY_ICONS[category]
|
|
|
|
const firstIssue = issues.find((issue) => issue.category === category)
|
|
const href = firstIssue
|
|
? `/project/${ref}/issues/${firstIssue.id}?category=${category}`
|
|
: `/project/${ref}/issues?category=${category}`
|
|
return (
|
|
<li key={category}>
|
|
<DynamicLink
|
|
href={href}
|
|
className="flex items-center gap-3 px-4 py-2.5 text-sm text-foreground-light hover:bg-muted hover:text-foreground"
|
|
>
|
|
<Icon size={14} className="shrink-0 text-foreground-lighter" />
|
|
<span className="flex-1">{CATEGORY_LABELS[category]}</span>
|
|
<span className="tabular-nums text-foreground-lighter">
|
|
{categoryCounts[category] ?? 0}
|
|
</span>
|
|
<ChevronRightIcon size={14} className="shrink-0 text-foreground-muted" />
|
|
</DynamicLink>
|
|
</li>
|
|
)
|
|
})}
|
|
</ul>
|
|
</section>
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const StatCard = ({
|
|
label,
|
|
value,
|
|
href,
|
|
severity,
|
|
}: {
|
|
label: string
|
|
value: number
|
|
href: string
|
|
severity?: IssueSeverity
|
|
}) => (
|
|
<DynamicLink
|
|
href={href}
|
|
className="flex flex-col gap-1 rounded-md border bg-card px-4 py-3 hover:border-strong"
|
|
>
|
|
<span className="flex items-center gap-1.5 text-xs text-foreground-lighter">
|
|
{severity && <SeverityIndicator severity={severity} aria-hidden />}
|
|
{label}
|
|
</span>
|
|
<span className="text-2xl tabular-nums text-foreground">{value}</span>
|
|
</DynamicLink>
|
|
)
|