mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
Part 5 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 | Integrations, Settings, Observability, LogDrains, Issues, Linter, Reports, QueryPerformance, QuerySources, ConfigDrift, DiskManagement, Compute | | **5** | **#54308 ← this PR** | **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 the remaining `components/interfaces/**` directories off `next/link`, leaving zero `next/link` component imports in `apps/studio`. **Changed:** - Replaced `next/link` across all 73 remaining interface files (`Organization`, `OrganizationInvite`, `Billing`, `Auth`, `Support`, `ProjectHome`, `Home`, `Project`, `ProjectCreation`, `ProjectAPIDocs`, `ApiAuthorization`, `App`, `ConnectSheet`, `SignIn`, `APIKeys`, `Account`, `CliLogin`, `Docs`, `JwtSecrets`, `Platform`) - Converted the sole remaining `UrlObject` link (`<Link href={{ pathname: '/sign-in-sso', query }}>`) in `SignInSSOForm.tsx` to `<Link to="/sign-in-sso" search={query}>` - Migrated `SupportLink.tsx` onto `DynamicLink` (`createSupportFormUrl(...)`) - Standardized external `target="_blank"` anchors with `rel="noreferrer noopener"`, switched `OverviewMetrics.tsx` observability link to typed `<Link to="/project/$ref/observability/auth">`, and adopted `InlineLink` / `InlineLinkClassName` on inline paragraph links per review feedback Addresses [FE-5108](https://linear.app/supabase/issue/FE-5108/replace-the-nextlink-shim-with-tanstack-link) ## To test - [ ] Check Organization (billing, usage, team, documents, AWS Marketplace), Auth (providers, templates, rate limits, users, OAuth apps), Support form/links, Project Home, Connect sheet, and Sign-In/SSO links - [ ] Verify `SignInWithSSOButton` preserves query params when navigating to `/sign-in-sso` - [ ] Verify `SupportLink` pre-populates support form query parameters cleanly --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
96 lines
3.4 KiB
TypeScript
96 lines
3.4 KiB
TypeScript
import { Link } from '@tanstack/react-router'
|
|
import { DownloadIcon } from 'lucide-react'
|
|
import { toast } from 'sonner'
|
|
import { Button } from 'ui'
|
|
import {
|
|
PageSection,
|
|
PageSectionContent,
|
|
PageSectionDescription,
|
|
PageSectionMeta,
|
|
PageSectionSummary,
|
|
PageSectionTitle,
|
|
} from 'ui-patterns/PageSection'
|
|
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
import { NoPermission } from '@/components/ui/NoPermission'
|
|
import { getDocument } from '@/data/documents/document-query'
|
|
import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
|
|
import { FGA_PERMISSIONS, useAsyncCheckPermissionsV2 } from '@/hooks/misc/useCheckPermissionsV2'
|
|
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
|
|
import { useTrack } from '@/lib/telemetry/track'
|
|
|
|
export const SecurityQuestionnaire = () => {
|
|
const { data: organization } = useSelectedOrganizationQuery()
|
|
const slug = organization?.slug
|
|
|
|
const track = useTrack()
|
|
const { can: canReadSubscriptions, isLoading: isLoadingPermissions } = useAsyncCheckPermissionsV2(
|
|
FGA_PERMISSIONS.ORGANIZATION.BILLING_READ
|
|
)
|
|
const { hasAccess: hasAccessToQuestionnaire, isLoading: isLoadingEntitlement } =
|
|
useCheckEntitlements('security.questionnaire')
|
|
|
|
const fetchQuestionnaire = async (orgSlug: string) => {
|
|
try {
|
|
const questionnaireLink = await getDocument({
|
|
orgSlug,
|
|
docType: 'standard-security-questionnaire',
|
|
})
|
|
if (questionnaireLink?.fileUrl) window.open(questionnaireLink.fileUrl, '_blank')
|
|
} catch (error: unknown) {
|
|
const message = error instanceof Error ? error.message : 'Unknown error occurred'
|
|
toast.error(`Failed to download Security Questionnaire: ${message}`)
|
|
}
|
|
}
|
|
|
|
const handleDownloadClick = () => {
|
|
if (!slug) return
|
|
|
|
track('document_view_button_clicked', { documentName: 'Standard Security Questionnaire' })
|
|
fetchQuestionnaire(slug)
|
|
}
|
|
|
|
return (
|
|
<PageSection orientation="horizontal">
|
|
<PageSectionMeta>
|
|
<PageSectionSummary>
|
|
<PageSectionTitle>Standard Security Questionnaire</PageSectionTitle>
|
|
<PageSectionDescription className="space-y-2">
|
|
<p>
|
|
Organizations on Team Plan or above have access to our standard security
|
|
questionnaire.
|
|
</p>
|
|
</PageSectionDescription>
|
|
</PageSectionSummary>
|
|
</PageSectionMeta>
|
|
<PageSectionContent>
|
|
{isLoadingPermissions || isLoadingEntitlement ? (
|
|
<div className="@lg:flex items-center justify-center h-full">
|
|
<ShimmeringLoader className="w-24" />
|
|
</div>
|
|
) : !canReadSubscriptions ? (
|
|
<NoPermission resourceText="access our security questionnaire" />
|
|
) : !hasAccessToQuestionnaire ? (
|
|
<div className="@lg:flex items-center justify-center h-full">
|
|
<Button asChild>
|
|
<Link
|
|
to="/org/$slug/billing"
|
|
params={{ slug: slug ?? '_' }}
|
|
search={{ panel: 'subscriptionPlan', source: 'securityQuestionnaire' }}
|
|
>
|
|
Upgrade to Team
|
|
</Link>
|
|
</Button>
|
|
</div>
|
|
) : (
|
|
<div className="@lg:flex items-center justify-center h-full">
|
|
<Button icon={<DownloadIcon />} onClick={handleDownloadClick} disabled={!slug}>
|
|
Download Questionnaire
|
|
</Button>
|
|
</div>
|
|
)}
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
)
|
|
}
|