Skip to content

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

feat(studio): group connection settings in the pipeline creation preview (#51570)

Danny White37fb536e6c4c
diff --git a/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineConnectionSection.test.tsx b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineConnectionSection.test.tsx
new file mode 100644
index 00000000000..756b93e5507
--- /dev/null
+++ b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineConnectionSection.test.tsx
@@ -0,0 +1,102 @@
+import { fireEvent, screen } from '@testing-library/react'
+import { mockAnimationsApi } from 'jsdom-testing-mocks'
+import { useForm } from 'react-hook-form'
+import { Form } from 'ui'
+import { describe, expect, it, vi } from 'vitest'
+
+import { AdvancedSettings } from '../DestinationPanel/DestinationForm/AdvancedSettings'
+import type { DestinationPanelSchemaType } from '../DestinationPanel/DestinationForm/DestinationForm.schema'
+import type { DestinationType } from '../DestinationPanel/DestinationPanel.types'
+import { PipelineConnectionSection } from './PipelineConnectionSection'
+import { customRender } from '@/tests/lib/custom-render'
+
+vi.mock('../DestinationPanel/DestinationForm/BigQuery/TableOptions', () => ({
+ TableOptions: () => <p>Table layout controls</p>,
+}))
+
+mockAnimationsApi()
+
+const TestSection = ({
+ type,
+ group = 'connection',
+}: {
+ type: DestinationType
+ group?: 'connection' | 'data'
+}) => {
+ const form = useForm<DestinationPanelSchemaType>({
+ defaultValues: {
+ name: '',
+ connectionPoolSize: 5,
+ maxStalenessMins: 0,
+ ducklakePoolSize: 2,
+ snowflakeRole: '',
+ },
+ })
+ return (
+ <Form {...form}>
+ {group === 'data' ? (
+ <AdvancedSettings type={type} form={form} group="data" />
+ ) : (
+ <PipelineConnectionSection type={type} form={form}>
+ <p>Credentials</p>
+ </PipelineConnectionSection>
+ )}
+ </Form>
+ )
+}
+
+describe('PipelineConnectionSection', () => {
+ it.each<{ type: DestinationType; label: string }>([
+ { type: 'BigQuery', label: 'Connection pool size' },
+ { type: 'DuckLake', label: 'Pool size' },
+ { type: 'Snowflake', label: 'Role' },
+ ])('groups $type connection fields separately from replication settings', ({ type, label }) => {
+ customRender(<TestSection type={type} />)
+ expect(screen.getByRole('region', { name: 'Destination connection' })).toBeInTheDocument()
+ expect(screen.getByRole('textbox', { name: 'Pipeline name' })).toBeInTheDocument()
+ expect(screen.getByText('Pipeline region')).toBeInTheDocument()
+ expect(screen.getByText('Credentials')).toBeInTheDocument()
+ fireEvent.click(screen.getByRole('button', { name: /Advanced settings/ }))
+ expect(screen.getByText(`Adjust how data is written to ${type}.`)).toBeInTheDocument()
+ expect(
+ screen.getByRole('button', { name: /Advanced settings/ }).closest('.border-t')
+ ).toHaveClass('border-t', 'border-default')
+ expect(screen.getByLabelText(label)).toBeInTheDocument()
+ expect(screen.queryByText('Batch wait time')).not.toBeInTheDocument()
+ expect(screen.queryByText('Table layout')).not.toBeInTheDocument()
+ })
+
+ it.each<DestinationType>(['BigQuery', 'DuckLake', 'Snowflake'])(
+ 'keeps %s data settings separate from connection settings',
+ (type) => {
+ customRender(<TestSection type={type} group="data" />)
+ fireEvent.click(screen.getByRole('button', { name: /Advanced settings/ }))
+ for (const label of [
+ 'Batch wait time',
+ 'Table sync workers',
+ 'Initial sync connections per table',
+ 'Invalidated slot behavior',
+ ]) {
+ expect(screen.getByText(label)).toBeInTheDocument()
+ }
+ expect(
+ screen.getByText('Adjust initial sync and replication slot behavior.')
+ ).toBeInTheDocument()
+ for (const label of ['Connection pool size', 'Maximum staleness', 'Pool size', 'Role']) {
+ expect(screen.queryByText(label)).not.toBeInTheDocument()
+ }
+ expect(screen.queryByText('Table layout controls') !== null).toBe(type === 'BigQuery')
+ expect(
+ screen.getByRole('button', { name: /Advanced settings/ }).closest('.border-t')
+ ).toHaveClass('border-default')
+ }
+ )
+
+ it.each<DestinationType>(['ClickHouse', 'Analytics Bucket'])(
+ 'does not show an empty connection accordion for %s',
+ (type) => {
+ customRender(<TestSection type={type} />)
+ expect(screen.queryByRole('button', { name: /Advanced settings/ })).not.toBeInTheDocument()
+ }
+ )
+})
diff --git a/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineConnectionSection.tsx b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineConnectionSection.tsx
new file mode 100644
index 00000000000..4eede44234d
--- /dev/null
+++ b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineConnectionSection.tsx
@@ -0,0 +1,30 @@
+import type { ReactNode } from 'react'
+import type { UseFormReturn } from 'react-hook-form'
+import { DialogSectionSeparator } from 'ui'
+
+import { AdvancedSettings } from '../DestinationPanel/DestinationForm/AdvancedSettings'
+import type { DestinationPanelSchemaType } from '../DestinationPanel/DestinationForm/DestinationForm.schema'
+import { DestinationNameInput } from '../DestinationPanel/DestinationForm/DestinationNameInput'
+import { PipelineRegionField } from '../DestinationPanel/DestinationForm/PipelineRegionField'
+import type { DestinationType } from '../DestinationPanel/DestinationPanel.types'
+
+export const PipelineConnectionSection = ({
+ type,
+ form,
+ children,
+}: {
+ type: DestinationType
+ form: UseFormReturn<DestinationPanelSchemaType>
+ children: ReactNode
+}) => (
+ <section aria-label="Destination connection">
+ <div className="flex flex-col gap-y-4 p-5">
+ <h3 className="text-sm font-medium text-foreground">Destination connection</h3>
+ <DestinationNameInput form={form} destinationType={type} />
+ <PipelineRegionField destinationType={type} />
+ </div>
+ <DialogSectionSeparator />
+ {children}
+ <AdvancedSettings type={type} form={form} group="connection" />
+ </section>
+)
diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/AdvancedSettings.tsx b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/AdvancedSettings.tsx
index b0dfa838610..6018707e8f9 100644
--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/AdvancedSettings.tsx
+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/AdvancedSettings.tsx
@@ -1,5 +1,5 @@
import type { UseFormReturn } from 'react-hook-form'
-import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from 'ui'
+import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, cn } from 'ui'
import { DestinationType } from '../DestinationPanel.types'
import { BigQueryConnectionFields } from './BigQuery/ConnectionFields'
@@ -12,47 +12,62 @@ import { SnowflakeConnectionFields } from './Snowflake/ConnectionFields'
export const AdvancedSettings = ({
type,
form,
+ group = 'all',
}: {
+ group?: 'all' | 'connection' | 'data'
type: DestinationType
form: UseFormReturn<DestinationPanelSchemaType>
}) => {
+ const shouldShowConnection = group !== 'data'
+ const shouldShowData = group !== 'connection'
+ if (group === 'connection' && type !== 'BigQuery' && type !== 'DuckLake' && type !== 'Snowflake')
+ return null
+
+ let description = 'Customize how the pipeline syncs and replicates data.'
+ if (type === 'DuckLake' && group === 'all')
+ description = 'Adjust catalog connections and replication settings.'
+ if (group === 'connection') description = `Adjust how data is written to ${type}.`
+ if (group === 'data') description = 'Adjust initial sync and replication slot behavior.'
+
return (
- <div className="w-full">
+ <div className={cn('w-full', group !== 'all' && 'border-t border-default')}>
<Accordion type="single" collapsible>
<AccordionItem value="item-1" className="border-none">
<AccordionTrigger className="font-normal gap-2 justify-between px-5 py-3 text-sm hover:no-underline">
<div className="flex flex-col items-start gap-0.5">
<span className="text-sm font-medium">Advanced settings</span>
- <span className="text-sm text-foreground-lighter font-normal">
- {type === 'DuckLake'
- ? 'Adjust catalog connections and replication settings.'
- : 'Customize how the pipeline syncs and replicates data.'}
- </span>
+ <span className="text-sm text-foreground-lighter font-normal">{description}</span>
</div>
</AccordionTrigger>
<AccordionContent className="pb-0! pt-3 [&>div]:flex [&>div]:flex-col [&>div]:gap-y-4 [&>div]:px-5">
- {type === 'DuckLake' && <DuckLakeConnectionFields control={form.control} />}
+ {shouldShowConnection && type === 'DuckLake' && (
+ <DuckLakeConnectionFields control={form.control} />
+ )}
- <ReplicationFields control={form.control} />
+ {shouldShowData && <ReplicationFields control={form.control} />}
{type === 'BigQuery' && (
<>
- <BigQueryConnectionFields control={form.control} />
-
- <div className="flex flex-col gap-y-3">
- <div className="flex flex-col gap-y-1">
- <span className="text-sm text-foreground">Table layout</span>
- <p className="text-sm text-foreground-lighter">
- Partitioning and clustering for each BigQuery table. Applied when a
- destination table is first created or reset.
- </p>
+ {shouldShowConnection && <BigQueryConnectionFields control={form.control} />}
+
+ {shouldShowData && (
+ <div className="flex flex-col gap-y-3">
+ <div className="flex flex-col gap-y-1">
+ <span className="text-sm text-foreground">Table layout</span>
+ <p className="text-sm text-foreground-lighter">
+ Partitioning and clustering for each BigQuery table. Applied when a
+ destination table is first created or reset.
+ </p>
+ </div>
+ <TableOptions control={form.control} />
</div>
- <TableOptions control={form.control} />
- </div>
+ )}
</>
)}
- {type === 'Snowflake' && <SnowflakeConnectionFields control={form.control} />}
+ {shouldShowConnection && type === 'Snowflake' && (
+ <SnowflakeConnectionFields control={form.control} />
+ )}
</AccordionContent>
</AccordionItem>
</Accordion>
diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.test.tsx b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.test.tsx
index 4510d391e9a..254ee8371c9 100644
--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.test.tsx
+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.test.tsx
@@ -19,6 +19,7 @@ type SourcesResponse = components['schemas']['SourcesResponse_Output']
const mocks = vi.hoisted(() => ({
isSaving: false,
+ isPreviewEnabled: false,
resetValidation: vi.fn(),
submitPipeline: vi.fn(),
validateConfiguration: vi.fn(),
@@ -188,6 +189,10 @@ vi.mock('../../useIsETLPrivateAlpha', () => ({
useIsETLSnowflakePrivateAlpha: () => false,
}))
+vi.mock('@/components/interfaces/App/FeaturePreview/FeaturePreviewContext', () => ({
+ usePipelineCreationPreview: () => ({ isEnabled: mocks.isPreviewEnabled }),
+}))
+
vi.mock('./useDestinationForm', () => ({
useDestinationForm: () => ({
isValidating: false,
@@ -254,6 +259,7 @@ describe('DestinationForm edit submission', () => {
beforeEach(() => {
pipelineTableIds = [101, 999]
mocks.isSaving = false
+ mocks.isPreviewEnabled = false
mocks.submitPipeline.mockResolvedValue(undefined)
mocks.validateConfiguration.mockResolvedValue({ canContinue: true, warnings: [] })
@@ -295,6 +301,35 @@ describe('DestinationForm edit submission', () => {
})
})
+ it.each([
+ { isPreviewEnabled: false, isEditing: false, shouldShowSection: false },
+ { isPreviewEnabled: true, isEditing: false, shouldShowSection: true },
+ { isPreviewEnabled: true, isEditing: true, shouldShowSection: false },
+ ])(
+ 'shows the connection section only for preview creation ($isPreviewEnabled, $isEditing)',
+ ({ isPreviewEnabled, isEditing, shouldShowSection }) => {
+ mocks.isPreviewEnabled = isPreviewEnabled
+ customRender(
+ <DestinationForm
+ selectedType="BigQuery"
+ visible
+ existingDestination={isEditing ? existingDestination : undefined}
+ onClose={vi.fn()}
+ />
+ )
+ expect(screen.queryByRole('region', { name: 'Destination connection' }) !== null).toBe(
+ shouldShowSection
+ )
+ if (shouldShowSection) {
+ const section = screen.getByRole('region', { name: 'Destination connection' })
+ expect(
+ section.compareDocumentPosition(screen.getByText('Data')) &
+ Node.DOCUMENT_POSITION_FOLLOWING
+ ).toBeTruthy()
+ }
+ }
+ )
+
it.each([true, false])(
'describes saving without claiming a stopped pipeline will start (enabled: %s)',
(enabled) => {
diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.tsx b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.tsx
index bcfe356fe8f..b260639232c 100644
--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.tsx
+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.tsx
@@ -10,6 +10,7 @@ import { Button, DialogSectionSeparator, Form, SheetFooter, SheetSection } from
import { Admonition } from 'ui-patterns/Admonition'
import * as z from 'zod'
+import { PipelineConnectionSection } from '../../CreatePipeline/PipelineConnectionSection'
import {
useIsETLBigQueryPrivateAlpha,
useIsETLClickHousePrivateAlpha,
@@ -53,6 +54,7 @@ import { TableCopySelection } from './TableCopySelection'
import { useDestinationForm } from './useDestinationForm'
import { ValidationFailuresSection } from './ValidationFailuresSection'
import { ValidationWarningsDialog } from './ValidationWarningsDialog'
+import { usePipelineCreationPreview } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { CreateAnalyticsBucketSheet } from '@/components/interfaces/Storage/AnalyticsBuckets/CreateAnalyticsBucketSheet'
import { useAPIKeys } from '@/data/api-keys/api-keys-query'
import { useProjectSettingsV2Query } from '@/data/config/project-settings-v2-query'
@@ -104,6 +106,8 @@ export const DestinationForm = ({
const validationSectionRef = useRef<HTMLDivElement>(null)
const editMode = !!existingDestination
+ const { isEnabled: isCreationPreviewEnabled } = usePipelineCreationPreview()
+ const shouldShowConnectionSection = isCreationPreviewEnabled && !editMode
// Compute available destinations based on feature flags
const availableDestinations = useMemo(() => {
@@ -451,6 +455,30 @@ export const DestinationForm = ({
}
}, [visible, defaultValues, form, isDirty, resetValidation])
+ const destinationFields = (
+ <>
+ {selectedType === 'BigQuery' && etlEnableBigQuery && (
+ <BigQueryFields form={form} editMode={editMode} />
+ )}
+ {selectedType === 'Analytics Bucket' && etlEnableIceberg && (
+ <AnalyticsBucketFields
+ form={form}
+ editMode={editMode}
+ onSelectNewBucket={() => setNewBucketSheetVisible(true)}
+ />
+ )}
+ {selectedType === 'DuckLake' && etlEnableDucklake && (
+ <DuckLakeFields form={form} editMode={editMode} />
+ )}
+ {selectedType === 'Snowflake' && etlEnableSnowflake && (
+ <SnowflakeFields form={form} editMode={editMode} />
+ )}
+ {selectedType === 'ClickHouse' && etlEnableClickHouse && (
+ <ClickHouseFields form={form} editMode={editMode} />
+ )}
+ </>
+ )
+
return (
<>
<SheetSection className="grow overflow-auto px-0 py-0">
@@ -461,6 +489,14 @@ export const DestinationForm = ({
<Form {...form}>
<form id={formId} onSubmit={form.handleSubmit(onSubmit)}>
<fieldset disabled={!isExistingConfigReady} className="contents">
+ {shouldShowConnectionSection && (
+ <>
+ <PipelineConnectionSection type={selectedType} form={form}>
+ {destinationFields}
+ </PipelineConnectionSection>
+ <DialogSectionSeparator />
+ </>
+ )}
<div className="p-5 flex flex-col gap-y-6">
{isErrorExistingConfig && (
<Admonition type="warning">
@@ -470,44 +506,39 @@ export const DestinationForm = ({
</p>
</Admonition>
)}
- <p className="text-sm font-medium text-foreground">Destination details</p>
+ <p className="text-sm font-medium text-foreground">
+ {shouldShowConnectionSection ? 'Data' : 'Destination details'}
+ </p>
<div className="flex flex-col gap-y-4">
- <DestinationNameInput form={form} destinationType={selectedType} />
+ {!shouldShowConnectionSection && (
+ <DestinationNameInput form={form} destinationType={selectedType} />
+ )}
<PublicationSelection
form={form}
onSelectNewPublication={() => setPublicationPanelVisible(true)}
/>
<TableCopySelection form={form} editMode={editMode} />
- <PipelineRegionField destinationType={selectedType} />
+ {!shouldShowConnectionSection && (
+ <PipelineRegionField destinationType={selectedType} />
+ )}
</div>
</div>
- <DialogSectionSeparator />
-
- {selectedType === 'BigQuery' && etlEnableBigQuery && (
- <BigQueryFields form={form} editMode={editMode} />
- )}
- {selectedType === 'Analytics Bucket' && etlEnableIceberg && (
- <AnalyticsBucketFields
- form={form}
- editMode={editMode}
- onSelectNewBucket={() => setNewBucketSheetVisible(true)}
- />
- )}
- {selectedType === 'DuckLake' && etlEnableDucklake && (
- <DuckLakeFields form={form} editMode={editMode} />
- )}
- {selectedType === 'Snowflake' && etlEnableSnowflake && (
- <SnowflakeFields form={form} editMode={editMode} />
- )}
- {selectedType === 'ClickHouse' && etlEnableClickHouse && (
- <ClickHouseFields form={form} editMode={editMode} />
+ {!shouldShowConnectionSection && (
+ <>
+ <DialogSectionSeparator />
+ {destinationFields}
+ </>
)}
- <DialogSectionSeparator />
+ {!shouldShowConnectionSection && <DialogSectionSeparator />}
- <AdvancedSettings type={selectedType} form={form} />
+ <AdvancedSettings
+ type={selectedType}
+ form={form}
+ group={shouldShowConnectionSection ? 'data' : 'all'}
+ />
{!editMode && hasRunValidation && !isValidating && (
<>