Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat(studio): compose pipeline creation step navigation (#51776)

Danny White4593b3ffc070
diff --git a/apps/studio/TANSTACK_MIGRATION.md b/apps/studio/TANSTACK_MIGRATION.md
index 76f013f044e..5487cbd55f2 100644
--- a/apps/studio/TANSTACK_MIGRATION.md
+++ b/apps/studio/TANSTACK_MIGRATION.md
@@ -183,6 +183,7 @@ These are the layout-only TanStack files. Most hold a single product layout comp
- [x] A `routes/project/$ref/database/publications/index.tsx` ← `pages/project/[ref]/database/publications/index.tsx`
- [x] A `routes/project/$ref/database/publications/$id.tsx` ← `pages/project/[ref]/database/publications/[id].tsx`
- [x] A `routes/project/$ref/database/pipelines/index.tsx` ← `pages/project/[ref]/database/pipelines/index.tsx`
+- [x] A `routes/project/$ref/database/pipelines/new.tsx` ← `pages/project/[ref]/database/pipelines/new.tsx`
- [x] A `routes/project/$ref/database/pipelines/$pipelineId.tsx` ← `pages/project/[ref]/database/pipelines/[pipelineId].tsx`
- [x] A `routes/project/$ref/database/replication/replica/$replicaId.tsx` ← `pages/project/[ref]/database/replication/replica/[replicaId].tsx` (redirects to Infrastructure)
- [x] A `routes/project/$ref/database/triggers/index.tsx` ← `pages/project/[ref]/database/triggers/index.tsx`
diff --git a/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationFlow.test.tsx b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationFlow.test.tsx
new file mode 100644
index 00000000000..c30ea9095c8
--- /dev/null
+++ b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationFlow.test.tsx
@@ -0,0 +1,196 @@
+import { act, fireEvent, screen, waitFor } from '@testing-library/react'
+import type { components } from 'api-types'
+import { mockAnimationsApi } from 'jsdom-testing-mocks'
+import { HttpResponse } from 'msw'
+import { NuqsAdapter } from 'nuqs/adapters/react'
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+
+import { PipelineCreationFlow } from './PipelineCreationFlow'
+import { customRender } from '@/tests/lib/custom-render'
+import { addAPIMock } from '@/tests/lib/msw'
+
+vi.mock('@/components/layouts/Navigation/LayoutHeader/HomeIcon', () => ({
+ HomeIcon: () => (
+ <a tabIndex={0} href="/organizations">
+ Supabase home
+ </a>
+ ),
+}))
+vi.mock('@/components/layouts/AppLayout/OrganizationDropdown', () => ({
+ OrganizationDropdown: () => <span>Organisation</span>,
+}))
+vi.mock('@/components/layouts/Navigation/NavigationBar/OrgSelector', () => ({
+ OrgSelector: () => <span>Organisation</span>,
+}))
+vi.mock('@/components/layouts/AppLayout/ProjectDropdown', () => ({
+ ProjectDropdown: () => <span>Project</span>,
+}))
+
+mockAnimationsApi()
+beforeEach(() => {
+ addAPIMock({
+ method: 'get',
+ path: '/platform/replication/:ref/sources',
+ response: () =>
+ HttpResponse.json<components['schemas']['SourcesResponse_Output']>({
+ sources: [
+ {
+ id: 1,
+ name: 'default',
+ tenant_id: 'tenant',
+ config: { host: 'db.internal', port: 5432, name: 'postgres', username: 'postgres' },
+ },
+ ],
+ }),
+ })
+ addAPIMock({
+ method: 'get',
+ path: '/platform/replication/v2/:ref/sources/:source_id/publications',
+ response: () =>
+ HttpResponse.json<components['schemas']['ReadPublicationsResponse_Output']>({
+ publications: [],
+ }),
+ })
+})
+const next = () => fireEvent.click(screen.getByRole('button', { name: 'Continue' }))
+const back = () => fireEvent.click(screen.getByRole('button', { name: 'Back' }))
+
+describe('PipelineCreationFlow', () => {
+ it('uses browser Back and Forward to revisit steps without losing values', async () => {
+ window.history.replaceState(null, '', '/project/default/database/pipelines/new')
+ customRender(
+ <NuqsAdapter>
+ <PipelineCreationFlow availableDestinations={['BigQuery']} onClose={vi.fn()} />
+ </NuqsAdapter>
+ )
+ next()
+ await waitFor(() => expect(window.location.search).toBe('?step=connection'))
+ fireEvent.change(screen.getByRole('textbox', { name: 'Project ID' }), {
+ target: { value: 'history-project' },
+ })
+ next()
+ await waitFor(() => expect(window.location.search).toBe('?step=data'))
+ await act(async () => {
+ await new Promise<void>((resolve) => {
+ window.addEventListener('popstate', () => resolve(), { once: true })
+ window.history.back()
+ })
+ })
+ expect(screen.getByText(/Step 2 of 4/)).toBeInTheDocument()
+ expect(screen.getByRole('textbox', { name: 'Project ID' })).toHaveValue('history-project')
+ await act(async () => {
+ await new Promise<void>((resolve) => {
+ window.addEventListener('popstate', () => resolve(), { once: true })
+ window.history.forward()
+ })
+ })
+ expect(screen.getByText(/Step 3 of 4/)).toBeInTheDocument()
+ back()
+ await waitFor(() => expect(window.location.search).toBe('?step=connection'))
+ expect(screen.getByRole('textbox', { name: 'Project ID' })).toHaveValue('history-project')
+ })
+
+ it.each(['connection', 'data', 'review', 'invalid'])(
+ 'starts a fresh session at Destination for step=%s',
+ async (step) => {
+ window.history.replaceState(null, '', `/project/default/database/pipelines/new?step=${step}`)
+ customRender(
+ <NuqsAdapter>
+ <PipelineCreationFlow availableDestinations={['BigQuery']} onClose={vi.fn()} />
+ </NuqsAdapter>
+ )
+ await waitFor(() => expect(window.location.search).toBe(''))
+ expect(screen.getByText(/Step 1 of 4/)).toBeInTheDocument()
+ }
+ )
+
+ it('preserves connection and data values across steps and destination changes', () => {
+ customRender(
+ <PipelineCreationFlow availableDestinations={['BigQuery', 'Snowflake']} onClose={vi.fn()} />,
+ { nuqs: { hasMemory: true } }
+ )
+ expect(screen.getByText(/Step [1-4] of 4/)).toHaveTextContent('Step 1 of 4')
+ next()
+ fireEvent.change(screen.getByRole('textbox', { name: 'Pipeline name' }), {
+ target: { value: 'Warehouse' },
+ })
+ fireEvent.change(screen.getByRole('textbox', { name: 'Project ID' }), {
+ target: { value: 'my-project' },
+ })
+ next()
+ expect(screen.getByText(/Step [1-4] of 4/)).toHaveTextContent('Step 3 of 4')
+ fireEvent.click(screen.getByRole('button', { name: /Advanced settings/ }))
+ fireEvent.change(screen.getByRole('spinbutton', { name: 'Batch wait time' }), {
+ target: { value: '750' },
+ })
+ back()
+ expect(screen.getByRole('textbox', { name: 'Project ID' })).toHaveValue('my-project')
+ back()
+ fireEvent.click(screen.getByRole('radio', { name: /Snowflake/ }))
+ next()
+ expect(screen.getByRole('textbox', { name: 'Pipeline name' })).toHaveValue('Warehouse')
+ back()
+ fireEvent.click(screen.getByRole('radio', { name: /BigQuery/ }))
+ next()
+ expect(screen.getByRole('textbox', { name: 'Project ID' })).toHaveValue('my-project')
+ next()
+ fireEvent.click(screen.getByRole('button', { name: /Advanced settings/ }))
+ expect(screen.getByRole('spinbutton', { name: 'Batch wait time' })).toHaveValue(750)
+ next()
+ expect(screen.getByText(/Step [1-4] of 4/)).toHaveTextContent('Step 4 of 4')
+ expect(screen.getByRole('button', { name: 'Start pipeline' })).toBeDisabled()
+ expect(screen.getByDisplayValue('Warehouse')).toBeInTheDocument()
+ })
+
+ it('confirms destination-only changes and treats a reverted selection as pristine', async () => {
+ const onClose = vi.fn()
+ customRender(
+ <PipelineCreationFlow availableDestinations={['BigQuery', 'Snowflake']} onClose={onClose} />
+ )
+ fireEvent.click(screen.getByRole('radio', { name: /Snowflake/ }))
+ fireEvent.click(screen.getByRole('button', { name: 'Close' }))
+ expect(await screen.findByRole('alertdialog')).toBeInTheDocument()
+ expect(onClose).not.toHaveBeenCalled()
+ fireEvent.click(screen.getByRole('button', { name: 'Keep editing' }))
+ fireEvent.click(screen.getByRole('radio', { name: /BigQuery/ }))
+ fireEvent.click(screen.getByRole('button', { name: 'Close' }))
+ expect(onClose).toHaveBeenCalledOnce()
+ })
+
+ it('confirms dirty dismissal and allows keeping the form', async () => {
+ const onClose = vi.fn()
+ customRender(<PipelineCreationFlow availableDestinations={['BigQuery']} onClose={onClose} />, {
+ nuqs: { hasMemory: true },
+ })
+ next()
+ fireEvent.change(screen.getByRole('textbox', { name: 'Pipeline name' }), {
+ target: { value: 'Keep me' },
+ })
+ const unload = new Event('beforeunload', { cancelable: true })
+ window.dispatchEvent(unload)
+ expect(unload.defaultPrevented).toBe(true)
+ fireEvent.click(screen.getByRole('button', { name: 'Close' }))
+ expect(await screen.findByRole('alertdialog')).toBeInTheDocument()
+ fireEvent.click(screen.getByRole('button', { name: 'Keep editing' }))
+ expect(onClose).not.toHaveBeenCalled()
+ fireEvent.click(screen.getByRole('link', { name: 'Supabase home' }))
+ expect(await screen.findByRole('alertdialog')).toBeInTheDocument()
+ expect(onClose).not.toHaveBeenCalled()
+ fireEvent.click(screen.getByRole('button', { name: 'Keep editing' }))
+ expect(screen.getByRole('textbox', { name: 'Pipeline name' })).toHaveValue('Keep me')
+ fireEvent.click(screen.getByRole('button', { name: 'Close' }))
+ fireEvent.click(await screen.findByRole('button', { name: 'Discard changes' }))
+ await waitFor(() => expect(onClose).toHaveBeenCalledOnce())
+ const confirmedUnload = new Event('beforeunload', { cancelable: true })
+ window.dispatchEvent(confirmedUnload)
+ expect(confirmedUnload.defaultPrevented).toBe(false)
+ })
+
+ it('closes a pristine form and blocks progression without destinations', () => {
+ const onClose = vi.fn()
+ customRender(<PipelineCreationFlow availableDestinations={[]} onClose={onClose} />)
+ expect(screen.getByRole('button', { name: 'Continue' })).toBeDisabled()
+ fireEvent.click(screen.getByRole('button', { name: 'Close' }))
+ expect(onClose).toHaveBeenCalledOnce()
+ })
+})
diff --git a/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationFlow.tsx b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationFlow.tsx
new file mode 100644
index 00000000000..8e7c1a12bcd
--- /dev/null
+++ b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationFlow.tsx
@@ -0,0 +1,188 @@
+import { useParams } from 'common'
+import { parseAsStringEnum, useQueryState } from 'nuqs'
+import { useEffect, useId, useRef, useState } from 'react'
+import { useForm, useWatch } from 'react-hook-form'
+import { Form, Separator } from 'ui'
+
+import { DestinationLogo } from '../DestinationLogo'
+import { BigQueryFields } from '../DestinationPanel/DestinationForm/BigQuery/Fields'
+import { ClickHouseFields } from '../DestinationPanel/DestinationForm/ClickHouse/Fields'
+import type { DestinationPanelSchemaType } from '../DestinationPanel/DestinationForm/DestinationForm.schema'
+import { generateDefaultValues } from '../DestinationPanel/DestinationForm/DestinationForm.utils'
+import { DuckLakeFields } from '../DestinationPanel/DestinationForm/DuckLake/Fields'
+import { NewPublicationPanel } from '../DestinationPanel/DestinationForm/NewPublicationPanel'
+import { SnowflakeFields } from '../DestinationPanel/DestinationForm/Snowflake/Fields'
+import { PipelineConnectionSection } from './PipelineConnectionSection'
+import { PipelineCreationHeader } from './PipelineCreationHeader'
+import { PipelineDataReview } from './PipelineDataReview'
+import { PipelineDataSection } from './PipelineDataSection'
+import { PipelineDestinationReview } from './PipelineDestinationReview'
+import { PipelineDestinationSelection } from './PipelineDestinationSelection'
+import { PipelineReviewCosts } from './PipelineReviewCosts'
+import { DiscardChangesConfirmationDialog } from '@/components/ui-patterns/Dialogs/DiscardChangesConfirmationDialog'
+import { SteppedFlow, SteppedFlowHeader } from '@/components/ui/SteppedFlow/SteppedFlow'
+import { useReplicationPublicationQuery } from '@/data/replication/publication-query'
+import { useReplicationSourceId } from '@/data/replication/sources-query'
+import { useConfirmOnClose } from '@/hooks/ui/useConfirmOnClose'
+
+type FlowDestination = 'BigQuery' | 'DuckLake' | 'Snowflake' | 'ClickHouse'
+const steps = [
+ { id: 'destination', label: 'Destination', title: 'Choose a destination' },
+ { id: 'connection', label: 'Connection', title: 'Authorize the destination' },
+ { id: 'data', label: 'Data', title: 'Choose what to replicate' },
+ { id: 'review', label: 'Review', title: 'Review and create' },
+]
+
+const stepParser = parseAsStringEnum(steps.map(({ id }) => id))
+ .withDefault('destination')
+ .withOptions({ history: 'push', shallow: true, clearOnDefault: true })
+
+export const PipelineCreationFlow = ({
+ availableDestinations,
+ onClose,
+}: {
+ availableDestinations: FlowDestination[]
+ onClose: () => void
+}) => {
+ const [step, setStep] = useQueryState('step', stepParser)
+ const hasInitializedStepRef = useRef(false)
+
+ useEffect(() => {
+ if (hasInitializedStepRef.current) return
+ hasInitializedStepRef.current = true
+ void setStep('destination', { history: 'replace' })
+ }, [setStep])
+ const [type, setType] = useState<FlowDestination>(availableDestinations[0] ?? 'BigQuery')
+ const [isPublicationPanelVisible, setIsPublicationPanelVisible] = useState(false)
+ const formId = useId()
+ const form = useForm<DestinationPanelSchemaType>({
+ defaultValues: generateDefaultValues({ catalogToken: '', editMode: false }),
+ shouldUnregister: false,
+ })
+ const canLeaveRef = useRef(false)
+ const pendingHrefRef = useRef<string | undefined>(undefined)
+ const initialTypeRef = useRef(type)
+ const { isDirty } = form.formState
+ const hasUnsavedChanges = isDirty || type !== initialTypeRef.current
+ const { confirmOnClose, modalProps } = useConfirmOnClose({
+ checkIsDirty: () => hasUnsavedChanges,
+ onClose: () => {
+ canLeaveRef.current = true
+ if (pendingHrefRef.current) window.location.assign(pendingHrefRef.current)
+ else onClose()
+ },
+ })
+ const handleClose = () => {
+ pendingHrefRef.current = undefined
+ confirmOnClose()
+ }
+ const { ref: projectRef } = useParams()
+ const sourceId = useReplicationSourceId({ projectRef })
+ const publicationName = useWatch({ control: form.control, name: 'publicationName' })
+ const { data: publication } = useReplicationPublicationQuery({
+ projectRef,
+ sourceId,
+ publicationName,
+ })
+ const currentStep = steps.find((item) => item.id === step) ?? steps[0]
+ const canSelectDestination = availableDestinations.includes(type)
+
+ useEffect(() => {
+ if (!hasUnsavedChanges) return
+ const handleBeforeUnload = (event: BeforeUnloadEvent) => {
+ if (canLeaveRef.current) return
+ event.preventDefault()
+ event.returnValue = ''
+ }
+ window.addEventListener('beforeunload', handleBeforeUnload)
+ return () => window.removeEventListener('beforeunload', handleBeforeUnload)
+ }, [hasUnsavedChanges])
+
+ return (
+ <div className="flex min-h-screen flex-col bg-dash-sidebar">
+ <PipelineCreationHeader
+ onClose={handleClose}
+ onNavigate={(href) => {
+ pendingHrefRef.current = href
+ confirmOnClose()
+ }}
+ />
+ <main className="flex-1">
+ <Form {...form}>
+ <form id={formId} onSubmit={(event) => event.preventDefault()}>
+ <SteppedFlow
+ steps={steps}
+ currentStep={step}
+ onStepChange={setStep}
+ nextLabel="Continue"
+ nextDisabled={step === 'destination' && !canSelectDestination}
+ onCancel={handleClose}
+ finalAction={{ label: 'Start pipeline', disabled: true }}
+ >
+ <SteppedFlowHeader title={currentStep.title} />
+ {step === 'destination' && (
+ <div className="p-5">
+ <PipelineDestinationSelection
+ availableDestinations={availableDestinations}
+ value={type}
+ onChange={(value) => {
+ const next = availableDestinations.find((item) => item === value)
+ if (next) setType(next)
+ }}
+ renderLogo={(value) => <DestinationLogo type={value} />}
+ />
+ </div>
+ )}
+ {step === 'connection' && (
+ <PipelineConnectionSection type={type} form={form}>
+ {type === 'BigQuery' && <BigQueryFields form={form} editMode={false} />}
+ {type === 'DuckLake' && <DuckLakeFields form={form} editMode={false} />}
+ {type === 'Snowflake' && <SnowflakeFields form={form} editMode={false} />}
+ {type === 'ClickHouse' && <ClickHouseFields form={form} editMode={false} />}
+ </PipelineConnectionSection>
+ )}
+ {step === 'data' && (
+ <PipelineDataSection
+ type={type}
+ form={form}
+ onSelectNewPublication={() => setIsPublicationPanelVisible(true)}
+ />
+ )}
+ {step === 'review' && (
+ <>
+ <PipelineDestinationReview type={type} control={form.control} />
+ <Separator />
+ <PipelineDataReview
+ type={type}
+ control={form.control}
+ publication={publication}
+ />
+ <PipelineReviewCosts control={form.control} publication={publication} />
+ <p className="p-5 text-sm text-foreground-light">
+ Pipeline creation is not available in this preview yet.
+ </p>
+ </>
+ )}
+ </SteppedFlow>
+ </form>
+ </Form>
+ </main>
+ <NewPublicationPanel
+ visible={isPublicationPanelVisible}
+ onClose={(name) => {
+ if (name) {
+ form.setValue('publicationName', name, { shouldDirty: true, shouldValidate: true })
+ form.setValue('tableSyncCopyMode', 'include_all_tables', {
+ shouldDirty: true,
+ shouldValidate: true,
+ })
+ form.setValue('tableSyncCopyTableIds', [], { shouldDirty: true, shouldValidate: true })
+ form.setValue('tableOptions', [], { shouldDirty: true, shouldValidate: true })
+ }
+ setIsPublicationPanelVisible(false)
+ }}
+ />
+ <DiscardChangesConfirmationDialog {...modalProps} />
+ </div>
+ )
+}
diff --git a/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationHeader.test.tsx b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationHeader.test.tsx
new file mode 100644
index 00000000000..cec6211b725
--- /dev/null
+++ b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationHeader.test.tsx
@@ -0,0 +1,54 @@
+import { fireEvent, screen } from '@testing-library/react'
+import { describe, expect, it, vi } from 'vitest'
+
+import { PipelineCreationHeader } from './PipelineCreationHeader'
+import { customRender } from '@/tests/lib/custom-render'
+
+vi.mock('@/components/layouts/Navigation/LayoutHeader/HomeIcon', () => ({
+ HomeIcon: () => (
+ <a tabIndex={0} href="/organizations">
+ Supabase home
+ </a>
+ ),
+}))
+vi.mock('@/components/layouts/AppLayout/OrganizationDropdown', () => ({
+ OrganizationDropdown: () => <span>Organization</span>,
+}))
+vi.mock('@/components/layouts/Navigation/NavigationBar/OrgSelector', async () => {
+ const { SidebarMenuButton } = await import('ui')
+ return { OrgSelector: () => <SidebarMenuButton>Organization</SidebarMenuButton> }
+})
+vi.mock('@/components/layouts/AppLayout/ProjectDropdown', async () => {
+ const { createPortal } = await import('react-dom')
+ return {
+ ProjectDropdown: () =>
+ createPortal(
+ <a tabIndex={0} href="/project/other/database/pipelines">
+ Project
+ </a>,
+ document.body
+ ),
+ }
+})
+
+describe('PipelineCreationHeader', () => {
+ it('shows the project context and routes close through its handler', () => {
+ const onClose = vi.fn()
+ customRender(<PipelineCreationHeader onClose={onClose} onNavigate={vi.fn()} />)
+ expect(screen.getByRole('navigation', { name: 'Pipeline creation' })).toBeInTheDocument()
+ expect(screen.getByText('New pipeline')).toBeInTheDocument()
+ fireEvent.click(screen.getByRole('button', { name: 'Close' }))
+ expect(onClose).toHaveBeenCalledOnce()
+ })
+ it.each(['Supabase home', 'Project'])('guards navigation from %s', (name) => {
+ const onNavigate = vi.fn()
+ customRender(<PipelineCreationHeader onClose={vi.fn()} onNavigate={onNavigate} />)
+ const link = screen.getByRole('link', { name })
+ expect(fireEvent.click(link)).toBe(false)
+ expect(onNavigate).toHaveBeenCalledWith(
+ link.getAttribute('href') === '/organizations'
+ ? 'http://localhost:3000/organizations'
+ : 'http://localhost:3000/project/other/database/pipelines'
+ )
+ })
+})
diff --git a/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationHeader.tsx b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationHeader.tsx
new file mode 100644
index 00000000000..10d3e1ec823
--- /dev/null
+++ b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationHeader.tsx
@@ -0,0 +1,62 @@
+import { XIcon } from 'lucide-react'
+import type { MouseEvent } from 'react'
+import { Button, SidebarProvider } from 'ui'
+
+import { OrganizationDropdown } from '@/components/layouts/AppLayout/OrganizationDropdown'
+import { ProjectDropdown } from '@/components/layouts/AppLayout/ProjectDropdown'
+import { HomeIcon } from '@/components/layouts/Navigation/LayoutHeader/HomeIcon'
+import { LayoutHeaderDivider } from '@/components/layouts/Navigation/LayoutHeader/LayoutHeaderDivider'
+import { OrgSelector } from '@/components/layouts/Navigation/NavigationBar/OrgSelector'
+
+export const PipelineCreationHeader = ({
+ onClose,
+ onNavigate,
+}: {
+ onClose: () => void
+ onNavigate: (href: string) => void
+}) => {
+ const handleLinkClick = (event: MouseEvent<HTMLElement>) => {
+ if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)
+ return
+ const link = event.target instanceof Element ? event.target.closest('a') : null
+ if (!link || link.target === '_blank') return
+ event.preventDefault()
+ event.stopPropagation()
+ onNavigate(link.href)
+ }
+
+ return (
+ <header
+ className="flex h-12 shrink-0 items-center justify-between gap-2 border-b bg-dash-sidebar px-3 md:px-4"
+ onClickCapture={handleLinkClick}
+ >
+ <nav
+ aria-label="Pipeline creation"
+ className="hide-scrollbar flex min-w-0 items-center gap-2 overflow-x-auto text-sm md:gap-0"
+ >
+ <HomeIcon className="md:mr-2" />
+ <LayoutHeaderDivider className="hidden shrink-0 md:block" />
+ <div className="hidden md:block">
+ <OrganizationDropdown />
+ </div>
+ <div className="md:hidden">
+ <SidebarProvider defaultOpen={false} className="contents">
+ <OrgSelector />
+ </SidebarProvider>
+ </div>
+ <LayoutHeaderDivider className="hidden shrink-0 md:block" />
+ <ProjectDropdown />
+ <LayoutHeaderDivider className="hidden shrink-0 md:block" />
+ <span className="shrink-0 text-foreground">New pipeline</span>
+ </nav>
+ <Button
+ type="button"
+ variant="text"
+ icon={<XIcon size={16} />}
+ className="shrink-0 px-1"
+ aria-label="Close"
+ onClick={onClose}
+ />
+ </header>
+ )
+}
diff --git a/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationPage.test.tsx b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationPage.test.tsx
new file mode 100644
index 00000000000..78d5cf47964
--- /dev/null
+++ b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationPage.test.tsx
@@ -0,0 +1,84 @@
+import { screen } from '@testing-library/react'
+import { beforeEach, expect, it, vi } from 'vitest'
+
+import PipelineCreationPage from '@/pages/project/[ref]/database/pipelines/new'
+import { customRender } from '@/tests/lib/custom-render'
+
+const state = vi.hoisted(() => ({
+ enabled: false,
+ loading: false,
+ flagsLoaded: true,
+ orgPending: false,
+ isHighAvailability: false,
+ canUseReplication: true,
+}))
+vi.mock('common', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('common')>()),
+ useFeatureFlags: () => ({ hasLoaded: state.flagsLoaded }),
+}))
+vi.mock('@/hooks/misc/withAuth', () => ({ withAuth: (component: unknown) => component }))
+vi.mock('@/hooks/misc/useSelectedOrganization', () => ({
+ useSelectedOrganizationQuery: () => ({ isPending: state.orgPending }),
+}))
+vi.mock('@/hooks/misc/useHighAvailability', () => ({
+ useHighAvailability: () => ({ isPending: false, isHighAvailability: state.isHighAvailability }),
+}))
+vi.mock('@/hooks/misc/useIsFeatureEnabled', () => ({
+ useIsFeatureEnabled: () => state.canUseReplication,
+}))
+vi.mock('@/components/interfaces/App/FeaturePreview/FeaturePreviewContext', () => ({
+ usePipelineCreationPreview: () => ({ isEnabled: state.enabled, isLoading: state.loading }),
+}))
+vi.mock('@/components/interfaces/Database/Replication/useIsETLPrivateAlpha', () => ({
+ useIsETLBigQueryPrivateAlpha: () => true,
+ useIsETLDucklakePrivateAlpha: () => false,
+ useIsETLSnowflakePrivateAlpha: () => false,
+ useIsETLClickHousePrivateAlpha: () => false,
+}))
+vi.mock('./PipelineCreationFlow', () => ({ PipelineCreationFlow: () => <div>Wizard form</div> }))
+
+beforeEach(() => {
+ Object.assign(state, {
+ enabled: true,
+ loading: false,
+ flagsLoaded: true,
+ orgPending: false,
+ isHighAvailability: false,
+ canUseReplication: true,
+ })
+})
+it('renders the page body when the preview and project allow access', () => {
+ customRender(<PipelineCreationPage />)
+ expect(screen.getByText('Wizard form')).toBeInTheDocument()
+})
+it.each(['loading', 'orgPending'] as const)('waits while %s', (key) => {
+ state[key] = true
+ customRender(<PipelineCreationPage />)
+ expect(screen.queryByText('Wizard form')).not.toBeInTheDocument()
+})
+it('waits for rollout flags', () => {
+ state.flagsLoaded = false
+ customRender(<PipelineCreationPage />)
+ expect(screen.queryByText('Wizard form')).not.toBeInTheDocument()
+})
+it.each(['enabled', 'canUseReplication'] as const)(
+ 'does not expose the wizard when %s is false',
+ (key) => {
+ state[key] = false
+ customRender(<PipelineCreationPage />)
+ expect(screen.queryByText('Wizard form')).not.toBeInTheDocument()
+ }
+)
+it('does not expose the wizard for High Availability projects', () => {
+ state.isHighAvailability = true
+ customRender(<PipelineCreationPage />)
+ expect(screen.queryByText('Wizard form')).not.toBeInTheDocument()
+})
+
+it('falls back when the preview is off even if organisation and project queries stay pending', () => {
+ state.enabled = false
+ state.orgPending = true
+ state.flagsLoaded = false
+ customRender(<PipelineCreationPage />)
+ expect(screen.getByRole('status')).toHaveTextContent('Returning to Pipelines')
+})
diff --git a/apps/studio/components/layouts/Navigation/LayoutHeader/LayoutHeader.tsx b/apps/studio/components/layouts/Navigation/LayoutHeader/LayoutHeader.tsx
index bf67cf64913..519f3303ae4 100644
--- a/apps/studio/components/layouts/Navigation/LayoutHeader/LayoutHeader.tsx
+++ b/apps/studio/components/layouts/Navigation/LayoutHeader/LayoutHeader.tsx
@@ -12,6 +12,7 @@ import { AdminStudioButton } from './AdminStudioButton'
import { BreadcrumbsView } from './BreadcrumbsView'
import { FeedbackDropdown } from './FeedbackDropdown/FeedbackDropdown'
import { HomeIcon } from './HomeIcon'
+import { LayoutHeaderDivider } from './LayoutHeaderDivider'
import { LocalVersionPopover } from './LocalVersionPopover'
import { MergeRequestButton } from './MergeRequestButton'
import { ConnectButton } from '@/components/interfaces/ConnectButton/ConnectButton'
@@ -34,25 +35,6 @@ import { useTrack } from '@/lib/telemetry/track'
import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
import { useIsShortcutEnabled } from '@/state/shortcuts/useIsShortcutEnabled'
-const LayoutHeaderDivider = ({ className, ...props }: React.HTMLProps<HTMLSpanElement>) => (
- <span className={cn('text-border-stronger pr-2', className)} {...props}>
- <svg
- viewBox="0 0 24 24"
- width="16"
- height="16"
- stroke="currentColor"
- strokeWidth="1"
- strokeLinecap="round"
- strokeLinejoin="round"
- fill="none"
- shapeRendering="geometricPrecision"
- aria-hidden={true}
- >
- <path d="M16 3.549L7.12 20.600" />
- </svg>
- </span>
-)
-
interface LayoutHeaderProps {
customHeaderComponents?: ReactNode
breadcrumbs?: unknown[]
diff --git a/apps/studio/components/layouts/Navigation/LayoutHeader/LayoutHeaderDivider.tsx b/apps/studio/components/layouts/Navigation/LayoutHeader/LayoutHeaderDivider.tsx
new file mode 100644
index 00000000000..b343fde0f34
--- /dev/null
+++ b/apps/studio/components/layouts/Navigation/LayoutHeader/LayoutHeaderDivider.tsx
@@ -0,0 +1,21 @@
+import type { HTMLProps } from 'react'
+import { cn } from 'ui'
+
+export const LayoutHeaderDivider = ({ className, ...props }: HTMLProps<HTMLSpanElement>) => (
+ <span className={cn('text-border-stronger pr-2', className)} {...props}>
+ <svg
+ viewBox="0 0 24 24"
+ width="16"
+ height="16"
+ stroke="currentColor"
+ strokeWidth="1"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ fill="none"
+ shapeRendering="geometricPrecision"
+ aria-hidden={true}
+ >
+ <path d="M16 3.549L7.12 20.600" />
+ </svg>
+ </span>
+)
diff --git a/apps/studio/pages/project/[ref]/database/pipelines/new.tsx b/apps/studio/pages/project/[ref]/database/pipelines/new.tsx
new file mode 100644
index 00000000000..1795de9d6f7
--- /dev/null
+++ b/apps/studio/pages/project/[ref]/database/pipelines/new.tsx
@@ -0,0 +1,62 @@
+import { useFeatureFlags, useParams } from 'common'
+import Head from 'next/head'
+import { useEffect } from 'react'
+import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
+
+import { usePipelineCreationPreview } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { PipelineCreationFlow } from '@/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationFlow'
+import {
+ useIsETLBigQueryPrivateAlpha,
+ useIsETLClickHousePrivateAlpha,
+ useIsETLDucklakePrivateAlpha,
+ useIsETLSnowflakePrivateAlpha,
+} from '@/components/interfaces/Database/Replication/useIsETLPrivateAlpha'
+import { useHighAvailability } from '@/hooks/misc/useHighAvailability'
+import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
+import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
+import { withAuth } from '@/hooks/misc/withAuth'
+import { BASE_PATH } from '@/lib/constants'
+
+const PipelineCreationPage = () => {
+ const { ref } = useParams()
+ const { hasLoaded } = useFeatureFlags()
+ const { isPending: isOrganizationPending } = useSelectedOrganizationQuery()
+ const { isEnabled, isLoading } = usePipelineCreationPreview()
+ const { isHighAvailability, isPending } = useHighAvailability()
+ const canUseReplication = useIsFeatureEnabled('database:replication')
+ const bigQuery = useIsETLBigQueryPrivateAlpha()
+ const duckLake = useIsETLDucklakePrivateAlpha()
+ const snowflake = useIsETLSnowflakePrivateAlpha()
+ const clickHouse = useIsETLClickHousePrivateAlpha()
+ const listHref = `${BASE_PATH}/project/${ref}/database/pipelines`
+ const isAccessLoading =
+ isLoading || (isEnabled && (!hasLoaded || isOrganizationPending || isPending))
+ const canOpenFlow = isEnabled && !isHighAvailability && canUseReplication
+ useEffect(() => {
+ if (!isAccessLoading && !canOpenFlow) {
+ const fallback = isEnabled ? listHref : `${listHref}?destinationType=BigQuery`
+ window.location.replace(fallback)
+ }
+ }, [isAccessLoading, canOpenFlow, isEnabled, listHref])
+ if (isAccessLoading)
+ return <GenericSkeletonLoader className="mx-auto w-full max-w-[760px] px-6 py-8" />
+ if (!canOpenFlow) return <p role="status">Returning to Pipelines…</p>
+ return (
+ <>
+ <Head>
+ <title>New Pipeline | Supabase</title>
+ </Head>
+ <PipelineCreationFlow
+ availableDestinations={[
+ ...(bigQuery ? ['BigQuery' as const] : []),
+ ...(duckLake ? ['DuckLake' as const] : []),
+ ...(snowflake ? ['Snowflake' as const] : []),
+ ...(clickHouse ? ['ClickHouse' as const] : []),
+ ]}
+ onClose={() => window.location.assign(listHref)}
+ />
+ </>
+ )
+}
+
+export default withAuth(PipelineCreationPage)
diff --git a/apps/studio/routeTree.gen.ts b/apps/studio/routeTree.gen.ts
index b2f86cc10b1..16fc846d45c 100644
--- a/apps/studio/routeTree.gen.ts
+++ b/apps/studio/routeTree.gen.ts
@@ -251,6 +251,7 @@ import { Route as ProjectRefDatabaseBackupsRestoreToNewProjectRouteImport } from
import { Route as ProjectRefDatabaseBackupsScheduledRouteImport } from './routes/project/$ref/database/backups/scheduled'
import { Route as ProjectRefDatabasePipelinesIndexRouteImport } from './routes/project/$ref/database/pipelines/index'
import { Route as ProjectRefDatabasePipelinesPipelineIdRouteImport } from './routes/project/$ref/database/pipelines/$pipelineId'
+import { Route as ProjectRefDatabasePipelinesNewRouteImport } from './routes/project/$ref/database/pipelines/new'
import { Route as ProjectRefDatabasePublicationsIndexRouteImport } from './routes/project/$ref/database/publications/index'
import { Route as ProjectRefDatabasePublicationsIdRouteImport } from './routes/project/$ref/database/publications/$id'
import { Route as ProjectRefDatabaseTablesIndexRouteImport } from './routes/project/$ref/database/tables/index'
@@ -1652,6 +1653,12 @@ const ProjectRefDatabasePipelinesPipelineIdRoute =
path: '/$pipelineId',
getParentRoute: () => ProjectRefDatabasePipelinesRoute,
} as any)
+const ProjectRefDatabasePipelinesNewRoute =
+ ProjectRefDatabasePipelinesNewRouteImport.update({
+ id: '/new',
+ path: '/new',
+ getParentRoute: () => ProjectRefDatabasePipelinesRoute,
+ } as any)
const ProjectRefDatabasePublicationsIndexRoute =
ProjectRefDatabasePublicationsIndexRouteImport.update({
id: '/publications/',
@@ -2393,6 +2400,7 @@ export interface FileRoutesByFullPath {
'/project/$ref/database/backups/restore-to-new-project': typeof ProjectRefDatabaseBackupsRestoreToNewProjectRoute
'/project/$ref/database/backups/scheduled': typeof ProjectRefDatabaseBackupsScheduledRoute
'/project/$ref/database/pipelines/$pipelineId': typeof ProjectRefDatabasePipelinesPipelineIdRoute
+ '/project/$ref/database/pipelines/new': typeof ProjectRefDatabasePipelinesNewRoute
'/project/$ref/database/publications/$id': typeof ProjectRefDatabasePublicationsIdRoute
'/project/$ref/database/tables/$id': typeof ProjectRefDatabaseTablesIdRoute
'/project/$ref/database/triggers/data': typeof ProjectRefDatabaseTriggersDataRoute
@@ -2704,6 +2712,7 @@ export interface FileRoutesByTo {
'/project/$ref/database/backups/restore-to-new-project': typeof ProjectRefDatabaseBackupsRestoreToNewProjectRoute
'/project/$ref/database/backups/scheduled': typeof ProjectRefDatabaseBackupsScheduledRoute
'/project/$ref/database/pipelines/$pipelineId': typeof ProjectRefDatabasePipelinesPipelineIdRoute
+ '/project/$ref/database/pipelines/new': typeof ProjectRefDatabasePipelinesNewRoute
'/project/$ref/database/publications/$id': typeof ProjectRefDatabasePublicationsIdRoute
'/project/$ref/database/tables/$id': typeof ProjectRefDatabaseTablesIdRoute
'/project/$ref/database/triggers/data': typeof ProjectRefDatabaseTriggersDataRoute
@@ -3033,6 +3042,7 @@ export interface FileRoutesById {
'/project/$ref/database/backups/restore-to-new-project': typeof ProjectRefDatabaseBackupsRestoreToNewProjectRoute
'/project/$ref/database/backups/scheduled': typeof ProjectRefDatabaseBackupsScheduledRoute
'/project/$ref/database/pipelines/$pipelineId': typeof ProjectRefDatabasePipelinesPipelineIdRoute
+ '/project/$ref/database/pipelines/new': typeof ProjectRefDatabasePipelinesNewRoute
'/project/$ref/database/publications/$id': typeof ProjectRefDatabasePublicationsIdRoute
'/project/$ref/database/tables/$id': typeof ProjectRefDatabaseTablesIdRoute
'/project/$ref/database/triggers/data': typeof ProjectRefDatabaseTriggersDataRoute
@@ -3361,6 +3371,7 @@ export interface FileRouteTypes {
| '/project/$ref/database/backups/restore-to-new-project'
| '/project/$ref/database/backups/scheduled'
| '/project/$ref/database/pipelines/$pipelineId'
+ | '/project/$ref/database/pipelines/new'
| '/project/$ref/database/publications/$id'
| '/project/$ref/database/tables/$id'
| '/project/$ref/database/triggers/data'
@@ -3672,6 +3683,7 @@ export interface FileRouteTypes {
| '/project/$ref/database/backups/restore-to-new-project'
| '/project/$ref/database/backups/scheduled'
| '/project/$ref/database/pipelines/$pipelineId'
+ | '/project/$ref/database/pipelines/new'
| '/project/$ref/database/publications/$id'
| '/project/$ref/database/tables/$id'
| '/project/$ref/database/triggers/data'
@@ -4000,6 +4012,7 @@ export interface FileRouteTypes {
| '/project/$ref/database/backups/restore-to-new-project'
| '/project/$ref/database/backups/scheduled'
| '/project/$ref/database/pipelines/$pipelineId'
+ | '/project/$ref/database/pipelines/new'
| '/project/$ref/database/publications/$id'
| '/project/$ref/database/tables/$id'
| '/project/$ref/database/triggers/data'
@@ -5915,6 +5928,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ProjectRefDatabasePipelinesPipelineIdRouteImport
parentRoute: typeof ProjectRefDatabasePipelinesRoute
}
+ '/project/$ref/database/pipelines/new': {
+ id: '/project/$ref/database/pipelines/new'
+ path: '/new'
+ fullPath: '/project/$ref/database/pipelines/new'
+ preLoaderRoute: typeof ProjectRefDatabasePipelinesNewRouteImport
+ parentRoute: typeof ProjectRefDatabasePipelinesRoute
+ }
'/project/$ref/database/publications/': {
id: '/project/$ref/database/publications/'
path: '/publications'
@@ -6758,6 +6778,7 @@ const ProjectRefComputeRouteWithChildren =
interface ProjectRefDatabasePipelinesRouteChildren {
ProjectRefDatabasePipelinesPipelineIdRoute: typeof ProjectRefDatabasePipelinesPipelineIdRoute
+ ProjectRefDatabasePipelinesNewRoute: typeof ProjectRefDatabasePipelinesNewRoute
ProjectRefDatabasePipelinesIndexRoute: typeof ProjectRefDatabasePipelinesIndexRoute
}
@@ -6765,6 +6786,7 @@ const ProjectRefDatabasePipelinesRouteChildren: ProjectRefDatabasePipelinesRoute
{
ProjectRefDatabasePipelinesPipelineIdRoute:
ProjectRefDatabasePipelinesPipelineIdRoute,
+ ProjectRefDatabasePipelinesNewRoute: ProjectRefDatabasePipelinesNewRoute,
ProjectRefDatabasePipelinesIndexRoute:
ProjectRefDatabasePipelinesIndexRoute,
}
@@ -7412,13 +7434,3 @@ const rootRouteChildren: RootRouteChildren = {
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes<FileRouteTypes>()
-
-import type { getRouter } from './router.tsx'
-import type { startInstance } from './start.ts'
-declare module '@tanstack/react-start' {
- interface Register {
- ssr: true
- router: Awaited<ReturnType<typeof getRouter>>
- config: Awaited<ReturnType<typeof startInstance.getOptions>>
- }
-}
diff --git a/apps/studio/routes/project/$ref.tsx b/apps/studio/routes/project/$ref.tsx
index b68a96dd63d..79de2c65873 100644
--- a/apps/studio/routes/project/$ref.tsx
+++ b/apps/studio/routes/project/$ref.tsx
@@ -1,4 +1,4 @@
-import { createFileRoute, Outlet } from '@tanstack/react-router'
+import { createFileRoute, Outlet, useMatches } from '@tanstack/react-router'
import { DefaultLayout } from '@/components/layouts/DefaultLayout'
@@ -7,6 +7,15 @@ export const Route = createFileRoute('/project/$ref')({
})
function ProjectShell() {
+ const shouldSkipLayout = useMatches({
+ select: (matches) =>
+ matches.some(
+ (match) =>
+ (match.staticData as { skipProjectLayout?: boolean } | undefined)?.skipProjectLayout
+ ),
+ })
+ if (shouldSkipLayout) return <Outlet />
+
return (
<DefaultLayout>
<Outlet />
diff --git a/apps/studio/routes/project/$ref/database.tsx b/apps/studio/routes/project/$ref/database.tsx
index 2cdf0393f8d..d30310bdb02 100644
--- a/apps/studio/routes/project/$ref/database.tsx
+++ b/apps/studio/routes/project/$ref/database.tsx
@@ -7,6 +7,13 @@ export const Route = createFileRoute('/project/$ref/database')({
})
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
@@ -28,6 +35,8 @@ function DatabaseShell() {
},
})
+ if (shouldSkipLayout) return <Outlet />
+
return (
<DatabaseLayout title={title}>
<Outlet />
diff --git a/apps/studio/routes/project/$ref/database/pipelines/new.tsx b/apps/studio/routes/project/$ref/database/pipelines/new.tsx
new file mode 100644
index 00000000000..6322452ef37
--- /dev/null
+++ b/apps/studio/routes/project/$ref/database/pipelines/new.tsx
@@ -0,0 +1,8 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+import PipelineCreationPage from '@/pages/project/[ref]/database/pipelines/new'
+
+export const Route = createFileRoute('/project/$ref/database/pipelines/new')({
+ staticData: { skipProjectLayout: true, skipDatabaseLayout: true },
+ component: () => <PipelineCreationPage />,
+})