Files
supabase/apps/studio/routes/project/$ref/database.tsx
Danny White 4593b3ffc0 feat(studio): compose pipeline creation step navigation (#51776)
## Problem

The pipeline wizard in #49243 needs its merged components composed into
a full-page flow, with values preserved when moving backwards and
forwards.

## Solution

- Compose four full-page SteppedFlow steps behind **Pipeline creation
wizard**.
- Preserve values through step navigation and browser Back/Forward.
Refresh starts at Destination.
- Reuse Studio’s header controls and confirm before discarding changes.
- Defer step validation and creation; **Start pipeline** is disabled.
**Add pipeline** and preview-off visits keep the sheet.

| After |
| --- |
| <img width="1024" height="759" alt="New Pipeline Supabase"
src="https://github.com/user-attachments/assets/7c3c4511-9a00-4e64-a86a-d6d9489f7d75"
/> |
| _Only available by navigating to `database/pipelines/new` with the
feature preview on._ |

## Review instructions

1. Open the [Pipelines
preview](https://studio-staging-git-dnywh-featpipeline-stepped-n-ce5307-supabase.vercel.app/dashboard/project/_/database/pipelines),
select a test project and enable **Pipeline creation wizard**. Open the
[wizard
preview](https://studio-staging-git-dnywh-featpipeline-stepped-n-ce5307-supabase.vercel.app/dashboard/project/_/database/pipelines/new)
for that project. Check the full-page layout and header at desktop and
phone widths.
2. Enter connection details, select a publication and change
initial-sync and advanced settings. Use **Back/Continue**, browser
**Back/Forward**, and switch destinations to confirm values remain.
3. Check Review shows your settings, masks secrets and disables **Start
pipeline**. Refresh and confirm it restarts at Destination. Incomplete
steps are allowed in this navigation-only slice.
4. With changes, try header navigation or **Close**. Check **Keep
editing** preserves values and **Discard changes** leaves the flow. Turn
the preview off and confirm the wizard URL opens the sheet.
2026-10-16 11:09:21 +11:00

46 lines
1.8 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() {
const shouldSkipLayout = useMatches({
select: (matches) =>
matches.some(
(match) =>
(match.staticData as { skipDatabaseLayout?: boolean } | undefined)?.skipDatabaseLayout
),
})
// 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 ''
},
})
if (shouldSkipLayout) return <Outlet />
return (
<DatabaseLayout title={title}>
<Outlet />
</DatabaseLayout>
)
}