Files
supabase/apps/studio/routes/claim-project.tsx
Alaister YoungandAlaister Young d2eb58a0e7 [FE-3106] (part 3) – refactor(studio): move account and top-level page bodies (#53212)
Moves the account and top-level app page bodies (`/account/*`,
`/organizations`, `/new`, `/new/$slug`, `/join`, `/claim-project`,
`/aws-marketplace-onboarding`, `/stripe-atlas-application`,
`/support/new`, `/support/link`, `/integrations/github|vercel/*`) from
`pages/**` into their TanStack route files and deletes the pages. Part
of the final pass of the TanStack migration (FE-3106). Part 3 of the
stack, and the first page-move PR.

**Depends on:** #53202

**Changed:**
- `routes/_app/account/**`,
`routes/_app/{organizations,new/index,support/*}.tsx`,
`routes/{new/$slug,join,claim-project,aws-marketplace-onboarding,stripe-atlas-application}.tsx`,
`routes/integrations/**` – page bodies inlined.
`next/router`/`next/link`/`next/head` → `useNavigate`, `Link`,
`<Navigate>` and inline `<title>`. `getLayout` dropped; every old
`getLayout` was checked against the route tree and matches
- `routes/aws-marketplace-onboarding.tsx` – reads `buyer_id` through
`validateSearch` + `Route.useSearch()`
- `tests/lib/route-render.tsx` – new `renderRoute(Route, { routeId, url
})` helper that mounts a file route in a memory router (with the app's
search serializers) so route components can be tested; used by the moved
tests
- `tests/lib/route-mock.ts` – the `next/router` mock now derives its
dynamic-route patterns from `routes/**` instead of globbing `pages/**`,
so tests keep parsing params as pages disappear
- `tests/routes/**` – page tests moved from `tests/pages/**` and
rendered through the route
- `.github/CODEOWNERS` – `pages/new/index.tsx` owner moved to
`routes/_app/new/index.tsx`

**Removed:**
- 19 files under `pages/account/**`, `pages/new/**`,
`pages/support/{new,link}.tsx`, `pages/integrations/**` and the
top-level pages listed above

Addresses
[FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages).

## To test

- Open `/account/me`, `/account/security`, `/account/tokens`,
`/account/audit` – same Account layout, header title and sidebar as
before
- Open an old email-change link (`/account/me#message=...`) – lands on
`/account/security` with the hash
- `/account/tokens/scoped` – redirects to `/account/tokens`
- `/organizations` and `/new/<org>` – render with the same layout; "New
organization" links work
- Vercel install/marketplace flows – navigation keeps `?…` params

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-17 14:46:37 +09:00

127 lines
4.1 KiB
TypeScript

import { createFileRoute } from '@tanstack/react-router'
import { useParams } from 'common'
import { useMemo, useState } from 'react'
import { Admonition } from 'ui-patterns/Admonition'
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
import { ProjectClaimBenefits } from '@/components/interfaces/Organization/ProjectClaim/benefits'
import { ProjectClaimChooseOrg } from '@/components/interfaces/Organization/ProjectClaim/choose-org'
import { ProjectClaimConfirm } from '@/components/interfaces/Organization/ProjectClaim/confirm'
import { ProjectClaimLayout } from '@/components/interfaces/Organization/ProjectClaim/layout'
import { useApiAuthorizationQuery } from '@/data/api-authorization/api-authorization-query'
import { useOrganizationProjectClaimQuery } from '@/data/organizations/organization-project-claim-query'
import { useOrganizationsQuery } from '@/data/organizations/organizations-query'
import { useCustomContent } from '@/hooks/custom-content/useCustomContent'
import { withAuth } from '@/hooks/misc/withAuth'
export const Route = createFileRoute('/claim-project')({
component: ClaimProject,
})
function ClaimProject() {
const { appTitle } = useCustomContent(['app:title'])
return (
<>
<title>{`Claim project | ${appTitle ?? 'Supabase'}`}</title>
<main className="flex flex-col w-full min-h-screen overflow-y-auto">
<ClaimProjectPageWithAuth />
</main>
</>
)
}
function ClaimProjectPage() {
const { auth_id, token: claimToken } = useParams()
const [selectedOrgSlug, setSelectedOrgSlug] = useState<string>()
const [step, setStep] = useState<'choose-org' | 'benefits' | 'confirm'>('choose-org')
const {
data: requester,
isPending: isLoadingRequester,
isError: isErrorRequester,
error: errorRequester,
} = useApiAuthorizationQuery({ id: auth_id })
const { data: organizations } = useOrganizationsQuery()
const selectedOrganization = useMemo(() => {
return (organizations || []).find((org) => org.slug === selectedOrgSlug)
}, [selectedOrgSlug, organizations])
const {
data: projectClaim,
error: errorProjectClaim,
isError: isErrorProjectClaim,
isPending: isLoadingProjectClaim,
isSuccess: isSuccessProjectClaim,
} = useOrganizationProjectClaimQuery(
{
slug: selectedOrgSlug!,
token: claimToken!,
},
{
enabled: !!claimToken && !!selectedOrgSlug,
}
)
if ((selectedOrgSlug && claimToken && isLoadingProjectClaim) || isLoadingRequester) {
return (
<ProjectClaimLayout title="Claim a project" className="py-6">
<div className="space-y-2">
<ShimmeringLoader />
<ShimmeringLoader className="w-3/4" />
<ShimmeringLoader className="w-1/2" />
</div>
</ProjectClaimLayout>
)
}
if ((selectedOrgSlug && claimToken && isErrorProjectClaim) || isErrorRequester) {
return (
<ProjectClaimLayout title="Claim a project" className="py-6">
<Admonition type="warning" title="Failed to retrieve project claim request details">
<p>Please retry your claim request from the requesting app</p>
{!!errorProjectClaim && <p className="mt-2">Error: {errorProjectClaim?.message}</p>}
{!!errorRequester && <p className="mt-2">Error: {errorRequester?.message}</p>}
</Admonition>
</ProjectClaimLayout>
)
}
if (step === 'choose-org' || !selectedOrganization) {
return (
<ProjectClaimChooseOrg
onChoose={(orgSlug) => {
setSelectedOrgSlug(orgSlug)
setStep('benefits')
}}
/>
)
}
if (isSuccessProjectClaim) {
if (step === 'benefits') {
return (
<ProjectClaimBenefits
projectClaim={projectClaim}
requester={requester}
onContinue={() => setStep('confirm')}
/>
)
}
return (
<ProjectClaimConfirm
setStep={setStep}
selectedOrganization={selectedOrganization}
projectClaim={projectClaim}
requester={requester}
/>
)
}
return null
}
const ClaimProjectPageWithAuth = withAuth(ClaimProjectPage)