mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
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>
82 lines
3.3 KiB
TypeScript
82 lines
3.3 KiB
TypeScript
import { createFileRoute } from '@tanstack/react-router'
|
|
import { useFlag } from 'common'
|
|
import { ExternalLinkIcon, SearchIcon } from 'lucide-react'
|
|
import { useState } from 'react'
|
|
import { Button } from 'ui'
|
|
import { Input } from 'ui-patterns/DataInputs/Input'
|
|
|
|
import { AccessTokenList } from '@/components/interfaces/Account/AccessTokens/AccessTokenList'
|
|
import { AccessTokenNewBanner } from '@/components/interfaces/Account/AccessTokens/AccessTokenNewBanner/AccessTokenNewBanner'
|
|
import { NewTokenButton } from '@/components/interfaces/Account/AccessTokens/Classic/NewTokenButton'
|
|
import { MigrationAdmonition } from '@/components/interfaces/Account/AccessTokens/MigrationAdmonition'
|
|
import { NewScopedTokenSheet } from '@/components/interfaces/Account/AccessTokens/Scoped/NewScopedTokenSheet'
|
|
import { AccessTokensLayout } from '@/components/layouts/AccessTokens/AccessTokensLayout'
|
|
import { NewAccessToken } from '@/data/access-tokens/access-tokens-create-mutation'
|
|
import { NewScopedAccessToken } from '@/data/scoped-access-tokens/scoped-access-token-create-mutation'
|
|
import { DOCS_URL } from '@/lib/constants'
|
|
|
|
export const Route = createFileRoute('/_app/account/tokens/')({
|
|
component: AccountTokensPage,
|
|
staticData: {
|
|
defaultLayoutHeaderTitle: 'Account',
|
|
accountLayoutTitle: 'Access Tokens',
|
|
},
|
|
})
|
|
|
|
function AccountTokensPage() {
|
|
const scopedTokensEnabled = useFlag('scopedPAT')
|
|
const [newToken, setNewToken] = useState<NewScopedAccessToken | NewAccessToken | undefined>()
|
|
const [searchString, setSearchString] = useState('')
|
|
|
|
return (
|
|
<AccessTokensLayout>
|
|
<div className="space-y-4">
|
|
{scopedTokensEnabled && <MigrationAdmonition />}
|
|
{newToken && (
|
|
<AccessTokenNewBanner
|
|
token={newToken}
|
|
onClose={() => setNewToken(undefined)}
|
|
getTokenValue={(token) => token.token}
|
|
/>
|
|
)}
|
|
<div className="flex items-center justify-between gap-x-2 mb-3">
|
|
<Input
|
|
size="tiny"
|
|
autoComplete="off"
|
|
icon={<SearchIcon size={12} />}
|
|
value={searchString}
|
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setSearchString(e.target.value)}
|
|
name="search"
|
|
id="search"
|
|
placeholder="Filter tokens"
|
|
/>
|
|
<div className="flex items-center gap-x-2">
|
|
<Button asChild icon={<ExternalLinkIcon />}>
|
|
<a href={`${DOCS_URL}/reference/api/introduction`} target="_blank" rel="noreferrer">
|
|
API Docs
|
|
</a>
|
|
</Button>
|
|
<Button asChild icon={<ExternalLinkIcon />}>
|
|
<a href={`${DOCS_URL}/reference/cli/start`} target="_blank" rel="noreferrer">
|
|
CLI docs
|
|
</a>
|
|
</Button>
|
|
{scopedTokensEnabled ? (
|
|
<NewScopedTokenSheet onCreateExperimentalToken={setNewToken} />
|
|
) : (
|
|
<NewTokenButton onCreateToken={setNewToken} />
|
|
)}
|
|
</div>
|
|
</div>
|
|
<AccessTokenList
|
|
searchString={searchString}
|
|
onDeleteSuccess={(id) => {
|
|
if (id === newToken?.id) setNewToken(undefined)
|
|
}}
|
|
scopedTokensEnabled={scopedTokensEnabled}
|
|
/>
|
|
</div>
|
|
</AccessTokensLayout>
|
|
)
|
|
}
|