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>
166 lines
5.6 KiB
TypeScript
166 lines
5.6 KiB
TypeScript
import * as Sentry from '@sentry/react'
|
|
import { useFlag } from 'common'
|
|
import { Loader2Icon } from 'lucide-react'
|
|
import { useCallback, useReducer } from 'react'
|
|
import { toast } from 'sonner'
|
|
import { Button, cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
|
|
|
|
import { IncidentAdmonition } from './IncidentAdmonition'
|
|
import { Success } from './Success'
|
|
import type { ExtendedSupportCategories } from './Support.constants'
|
|
import { SupportAssistantSuccessCard } from './SupportAssistantSuccessCard'
|
|
import { createInitialSupportFormState, supportFormReducer } from './SupportForm.state'
|
|
import { NO_PROJECT_MARKER, type SupportFormUrlKeys } from './SupportForm.utils'
|
|
import { SupportFormV3 } from './SupportFormV3'
|
|
import { DEFAULT_STATUS_PAGE_URL, getSupportStatusLabel } from './SupportStatus.utils'
|
|
import { useSupportForm } from './useSupportForm'
|
|
import { useSupportStatus } from './useSupportStatus'
|
|
import { useStateTransition } from '@/hooks/misc/useStateTransition'
|
|
import { useTrack } from '@/lib/telemetry/track'
|
|
|
|
function useSupportFormTelemetry() {
|
|
const track = useTrack()
|
|
|
|
return useCallback(
|
|
({
|
|
projectRef,
|
|
orgSlug,
|
|
category,
|
|
}: {
|
|
projectRef: string | undefined
|
|
orgSlug: string | undefined
|
|
category: ExtendedSupportCategories
|
|
}) =>
|
|
track(
|
|
'support_ticket_submitted',
|
|
{ ticketCategory: category },
|
|
{ project: projectRef, organization: orgSlug }
|
|
),
|
|
[track]
|
|
)
|
|
}
|
|
|
|
interface SupportFormProps {
|
|
initialParams?: Partial<SupportFormUrlKeys>
|
|
}
|
|
|
|
export function SupportForm({ initialParams }: SupportFormProps) {
|
|
const [state, dispatch] = useReducer(supportFormReducer, undefined, createInitialSupportFormState)
|
|
const { form, initialError, projectRef } = useSupportForm(dispatch, initialParams)
|
|
const showSupportAssistantFollowUp = useFlag('supportAssistantFollowUp') === true
|
|
|
|
const supportStatus = useSupportStatus()
|
|
const admonition = supportStatus.status === 'success' ? supportStatus.admonition : null
|
|
const statusPageUrl =
|
|
supportStatus.status === 'success' ? supportStatus.pageUrl : DEFAULT_STATUS_PAGE_URL
|
|
|
|
const sendTelemetry = useSupportFormTelemetry()
|
|
useStateTransition(state, 'submitting', 'success', (_, curr) => {
|
|
toast.success('Support request sent. Thank you!')
|
|
sendTelemetry({
|
|
projectRef: curr.sentProjectRef,
|
|
orgSlug: curr.sentOrgSlug,
|
|
category: curr.sentCategory,
|
|
})
|
|
})
|
|
|
|
useStateTransition(state, 'submitting', 'error', (_, curr) => {
|
|
toast.error(`Failed to submit support ticket: ${curr.message}`)
|
|
if (curr.code !== 429) {
|
|
Sentry.captureMessage(`Failed to submit Support Form: ${curr.message}`)
|
|
}
|
|
dispatch({ type: 'RETURN_TO_EDITING' })
|
|
})
|
|
|
|
const successState = state.type === 'success' ? state : null
|
|
const showAssistantSuccessCard =
|
|
showSupportAssistantFollowUp &&
|
|
successState !== null &&
|
|
successState.submittedRequest.projectRef !== undefined &&
|
|
successState.submittedRequest.projectRef !== NO_PROJECT_MARKER
|
|
|
|
return (
|
|
<div className="relative h-full overflow-y-auto overflow-x-hidden">
|
|
<IncidentAdmonition
|
|
isActive={admonition !== null}
|
|
title={admonition?.title ?? ''}
|
|
description={admonition?.description ?? ''}
|
|
statusPageUrl={statusPageUrl}
|
|
className="rounded-none border-x-0 shadow-none"
|
|
/>
|
|
<div className="min-h-full px-5 pt-5">
|
|
<div className="flex flex-col gap-y-8">
|
|
{successState ? (
|
|
<div className="flex flex-col gap-y-8 pt-2">
|
|
<Success
|
|
selectedProject={
|
|
successState.sentProjectRef === undefined
|
|
? (projectRef ?? undefined)
|
|
: successState.sentProjectRef
|
|
}
|
|
sentCategory={successState.sentCategory}
|
|
showFinishAction={false}
|
|
/>
|
|
{showAssistantSuccessCard && (
|
|
<SupportAssistantSuccessCard request={successState.submittedRequest} />
|
|
)}
|
|
</div>
|
|
) : (
|
|
<SupportFormV3
|
|
form={form}
|
|
initialError={initialError}
|
|
state={state}
|
|
dispatch={dispatch}
|
|
selectedProjectRef={projectRef}
|
|
/>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export function SupportFormStatusButton() {
|
|
const supportStatus = useSupportStatus()
|
|
const isLoading = supportStatus.status === 'pending'
|
|
const isIncident = supportStatus.status === 'success' && supportStatus.hasActiveIncidents
|
|
const statusLabel = getSupportStatusLabel(supportStatus)
|
|
const statusPageUrl =
|
|
supportStatus.status === 'success' ? supportStatus.pageUrl : DEFAULT_STATUS_PAGE_URL
|
|
|
|
return (
|
|
<>
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button
|
|
asChild
|
|
size="tiny"
|
|
icon={
|
|
isLoading ? (
|
|
<Loader2Icon className="animate-spin" />
|
|
) : (
|
|
<div
|
|
className={cn(
|
|
'h-2 w-2 rounded-full',
|
|
isIncident ? 'bg-warning' : 'bg-brand-default'
|
|
)}
|
|
/>
|
|
)
|
|
}
|
|
>
|
|
<a href={statusPageUrl} target="_blank" rel="noreferrer noopener">
|
|
{statusLabel}
|
|
</a>
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="bottom" align="center">
|
|
Check the Supabase status page
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
<span role="status" className="sr-only">
|
|
{isLoading ? '' : statusLabel}
|
|
</span>
|
|
</>
|
|
)
|
|
}
|