mirror of
https://github.com/supabase/supabase.git
synced 2026-10-09 19:35:06 +03:00
**Stack 5.1/6** of the TanStack Start migration (#46424). The original S5 (174 files) was over CodeRabbit's 150-file review cap, so it's split into 5.1 + 5.2 by product. Stacked on **#47113** (S4). > [!NOTE] > Thin route wrappers rendering the existing pages-router components via compat shims. Next-safe (full Next build run). The TanStack app isn't functional end-to-end until 5.2 + the matrix flip. ## What's in this PR - **Data-cluster project routes:** database, editor, sql, storage, realtime, branches. - **Top-level / onboarding routes:** `authorize`, `join`, `logout`, `redeem`, `verify-email`, `claim-project`, aws-marketplace, Vercel/GitHub integration entrypoints; `_app`/`_auth` layout shells; `/org/_` + `/project/_` catch-alls. - **Supporting edits:** hoist `BranchesPageWrapper` out of `getLayout`, `ConnectStepsSection` `import.meta.glob`, `api/server.js`. - `routeTree.gen.ts` regenerated for the routes present so far. ## Verification On top of S1–S4: `studio` typecheck ✓, lint (0 errors) ✓, **Next build ✓ (181/181 pages)**. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Restructured application routing infrastructure for improved code organization and maintainability. * Extracted and refactored layout wrapper components for enhanced reusability across different sections of the application. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
37 lines
1.5 KiB
TypeScript
37 lines
1.5 KiB
TypeScript
import { createFileRoute, Outlet, useMatches } from '@tanstack/react-router'
|
|
|
|
import DatabaseLayout from '@/components/layouts/DatabaseLayout/DatabaseLayout'
|
|
|
|
export const Route = createFileRoute('/project/$ref/database')({
|
|
component: DatabaseShell,
|
|
})
|
|
|
|
function DatabaseShell() {
|
|
// useMatches() returns a fresh array reference on every router tick, which
|
|
// re-renders the shell (and its subtree, e.g. DatabaseLayout → ProjectLayout
|
|
// → the route content) even when the leaf staticData hasn't changed. The
|
|
// `select` form lets TanStack compare the selected value (a string) and
|
|
// only re-render when it actually changes — required to keep heavy children
|
|
// like ReactFlow stable, otherwise their internal compose-refs chain runs
|
|
// setRef → setState every render and trips React's max-update-depth.
|
|
const title = useMatches({
|
|
select: (matches) => {
|
|
// Walk up from the leaf to the nearest match that declares a title.
|
|
// Section layouts like `database/triggers.tsx` set `databaseLayoutTitle`
|
|
// while their leaf children (`triggers/data`, `triggers/event`, the
|
|
// index) don't, so a leaf-only read would drop the title to ''.
|
|
for (let i = matches.length - 1; i >= 0; i--) {
|
|
const data = matches[i]?.staticData as { databaseLayoutTitle?: string } | undefined
|
|
if (typeof data?.databaseLayoutTitle === 'string') return data.databaseLayoutTitle
|
|
}
|
|
return ''
|
|
},
|
|
})
|
|
|
|
return (
|
|
<DatabaseLayout title={title}>
|
|
<Outlet />
|
|
</DatabaseLayout>
|
|
)
|
|
}
|