Skip to content

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

feat(studio): add destination review for preview pipeline creation (#51633)

Danny White17a7d2a00f0a
diff --git a/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineDestinationReview.test.tsx b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineDestinationReview.test.tsx
new file mode 100644
index 00000000000..9aa609740ae
--- /dev/null
+++ b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineDestinationReview.test.tsx
@@ -0,0 +1,116 @@
+import { fireEvent, screen } from '@testing-library/react'
+import { useForm } from 'react-hook-form'
+import { Button } from 'ui'
+import { describe, expect, it } from 'vitest'
+
+import type { DestinationPanelSchemaType } from '../DestinationPanel/DestinationForm/DestinationForm.schema'
+import type { DestinationType } from '../DestinationPanel/DestinationPanel.types'
+import { PipelineDestinationReview } from './PipelineDestinationReview'
+import { customRender } from '@/tests/lib/custom-render'
+
+const catalogUrl = 'postgres://user:[email protected]/postgres?token=secret'
+const defaults = {
+ name: 'Analytics',
+ projectId: 'warehouse-project',
+ datasetId: 'dataset',
+ serviceAccountKey: 'private-service-account',
+ ducklakeMode: 'custom',
+ ducklakeCatalogUrl: catalogUrl,
+ ducklakeDataPath: 's3://warehouse/data',
+ ducklakeS3SecretAccessKey: 'private-s3-key',
+ ducklakeStorageBucket: 'lake-bucket',
+ snowflakeAccountId: 'my-account',
+ snowflakeDatabase: 'warehouse',
+ snowflakeSchema: 'PUBLIC',
+ snowflakePrivateKey: 'private-snowflake-key',
+ clickhouseUrl: 'https://user:[email protected]',
+ clickhouseDatabase: 'events',
+ clickhouseEngine: 'merge_tree',
+ clickhousePassword: 'private-password',
+ warehouseName: 'bucket',
+ namespace: 'namespace',
+} satisfies Partial<DestinationPanelSchemaType>
+
+const TestReview = ({
+ type,
+ values = defaults,
+}: {
+ type: DestinationType
+ values?: Partial<DestinationPanelSchemaType>
+}) => {
+ const form = useForm<DestinationPanelSchemaType>({ defaultValues: values })
+ return (
+ <>
+ <PipelineDestinationReview type={type} control={form.control} />
+ <Button
+ onClick={() =>
+ form.setValue('ducklakeCatalogUrl', 'postgres://new:[email protected]/db')
+ }
+ >
+ Change URL
+ </Button>
+ <Button onClick={() => form.setValue('name', 'Updated name')}>Change name</Button>
+ </>
+ )
+}
+
+describe('PipelineDestinationReview', () => {
+ it.each<{ type: DestinationType; details: string[] }>([
+ { type: 'BigQuery', details: ['warehouse-project', 'dataset'] },
+ { type: 'DuckLake', details: ['s3://warehouse/data'] },
+ { type: 'Snowflake', details: ['my-account', 'warehouse', 'PUBLIC'] },
+ { type: 'ClickHouse', details: ['events', 'MergeTree'] },
+ { type: 'Analytics Bucket', details: ['bucket', 'namespace'] },
+ ])('shows $type details without credentials', ({ type, details }) => {
+ const { container } = customRender(<TestReview type={type} />)
+ expect(screen.getByDisplayValue('Analytics')).toHaveAttribute('readonly')
+ for (const detail of details) expect(screen.getByDisplayValue(detail)).toBeInTheDocument()
+ for (const secret of [
+ 'private-service-account',
+ 'private-s3-key',
+ 'private-snowflake-key',
+ 'private-password',
+ catalogUrl,
+ defaults.clickhouseUrl,
+ ]) {
+ expect(container.innerHTML).not.toContain(secret)
+ }
+ expect(screen.getByText('Pipeline region')).toBeInTheDocument()
+ })
+
+ it('reveals and hides the entire catalog URL and remasks a changed URL', () => {
+ const { container } = customRender(<TestReview type="DuckLake" />)
+ fireEvent.click(screen.getByRole('button', { name: 'Show catalog URL' }))
+ expect(screen.getByDisplayValue(catalogUrl)).toBeInTheDocument()
+ fireEvent.click(screen.getByRole('button', { name: 'Hide catalog URL' }))
+ expect(container.innerHTML).not.toContain(catalogUrl)
+ fireEvent.click(screen.getByRole('button', { name: 'Show catalog URL' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Change URL' }))
+ expect(screen.getByRole('button', { name: 'Show catalog URL' })).toBeInTheDocument()
+ expect(container.innerHTML).not.toContain('new:secret')
+ })
+
+ it('shows Supabase DuckLake bucket details and updates live form values', () => {
+ customRender(<TestReview type="DuckLake" values={{ ...defaults, ducklakeMode: 'supabase' }} />)
+ expect(screen.getByDisplayValue('lake-bucket')).toBeInTheDocument()
+ expect(screen.queryByRole('button', { name: 'Show catalog URL' })).not.toBeInTheDocument()
+ fireEvent.click(screen.getByRole('button', { name: 'Change name' }))
+ expect(screen.getByDisplayValue('Updated name')).toBeInTheDocument()
+ })
+
+ it('masks a ClickHouse URL containing credentials until explicitly revealed', () => {
+ const { container } = customRender(<TestReview type="ClickHouse" />)
+ const button = screen.getByRole('button', { name: 'Show HTTPS endpoint' })
+ expect(button).toHaveAttribute('type', 'button')
+ fireEvent.click(button)
+ expect(screen.getByDisplayValue(defaults.clickhouseUrl)).toBeInTheDocument()
+ fireEvent.click(screen.getByRole('button', { name: 'Hide HTTPS endpoint' }))
+ expect(container.innerHTML).not.toContain(defaults.clickhouseUrl)
+ })
+
+ it('shows missing values without exposing inactive destination details', () => {
+ customRender(<TestReview type="BigQuery" values={{ name: 'Analytics' }} />)
+ expect(screen.getAllByDisplayValue('Not set')).toHaveLength(2)
+ expect(screen.queryByText('Catalog URL')).not.toBeInTheDocument()
+ })
+})
diff --git a/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineDestinationReview.tsx b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineDestinationReview.tsx
new file mode 100644
index 00000000000..77245e8ec02
--- /dev/null
+++ b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineDestinationReview.tsx
@@ -0,0 +1,191 @@
+import { Eye, EyeOff } from 'lucide-react'
+import { useState } from 'react'
+import { useWatch, type Control } from 'react-hook-form'
+import { Button, Input, Separator } from 'ui'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
+
+import { DestinationLogo } from '../DestinationLogo'
+import { CREATE_NEW_NAMESPACE } from '../DestinationPanel/DestinationForm/DestinationForm.constants'
+import type { DestinationPanelSchemaType } from '../DestinationPanel/DestinationForm/DestinationForm.schema'
+import {
+ ANALYTICS_BUCKET_BUCKET_FIELD_COPY,
+ ANALYTICS_BUCKET_NAMESPACE_FIELD_COPY,
+ BIGQUERY_DATASET_ID_FIELD_COPY,
+ BIGQUERY_PROJECT_ID_FIELD_COPY,
+ CLICKHOUSE_DATABASE_FIELD_COPY,
+ CLICKHOUSE_ENGINE_FIELD_COPY,
+ CLICKHOUSE_URL_FIELD_COPY,
+ DUCKLAKE_BUCKET_FIELD_COPY,
+ DUCKLAKE_CATALOG_URL_FIELD_COPY,
+ DUCKLAKE_DATA_PATH_FIELD_COPY,
+ PIPELINE_NAME_FIELD_COPY,
+ SNOWFLAKE_ACCOUNT_ID_FIELD_COPY,
+ SNOWFLAKE_DATABASE_FIELD_COPY,
+ SNOWFLAKE_SCHEMA_FIELD_COPY,
+} from '../DestinationPanel/DestinationForm/DestinationFormFieldCopy'
+import {
+ getPipelineRegionDescription,
+ PipelineRegionReadonly,
+} from '../DestinationPanel/DestinationForm/PipelineRegionField'
+import type { DestinationType } from '../DestinationPanel/DestinationPanel.types'
+
+const MaskedUrl = ({ value, label }: { value: string; label: string }) => {
+ const [isVisible, setIsVisible] = useState(false)
+ if (!value) return <Input readOnly value="Not set" aria-label={label} />
+ return (
+ <div className="flex min-w-0 items-center gap-2">
+ <Input readOnly aria-label={label} value={isVisible ? value : '••••••••'} />
+ <Button
+ type="button"
+ variant="text"
+ size="tiny"
+ aria-label={`${isVisible ? 'Hide' : 'Show'} ${label.replace(/^[A-Z][a-z]+/, (word) => word.toLowerCase())}`}
+ aria-pressed={isVisible}
+ icon={isVisible ? <EyeOff size={14} /> : <Eye size={14} />}
+ onClick={() => setIsVisible(!isVisible)}
+ />
+ </div>
+ )
+}
+
+export const PipelineDestinationReview = ({
+ type,
+ control,
+}: {
+ type: DestinationType
+ control: Control<DestinationPanelSchemaType>
+}) => {
+ const [
+ name,
+ projectId,
+ datasetId,
+ mode,
+ catalogUrl,
+ dataPath,
+ bucket,
+ account,
+ database,
+ schema,
+ url,
+ clickhouseDatabase,
+ engine,
+ warehouse,
+ namespace,
+ newNamespace,
+ ] = useWatch({
+ control,
+ name: [
+ 'name',
+ 'projectId',
+ 'datasetId',
+ 'ducklakeMode',
+ 'ducklakeCatalogUrl',
+ 'ducklakeDataPath',
+ 'ducklakeStorageBucket',
+ 'snowflakeAccountId',
+ 'snowflakeDatabase',
+ 'snowflakeSchema',
+ 'clickhouseUrl',
+ 'clickhouseDatabase',
+ 'clickhouseEngine',
+ 'warehouseName',
+ 'namespace',
+ 'newNamespaceName',
+ ],
+ })
+ const rows: { label: string; value?: string; description?: string; isMasked?: boolean }[] = []
+ switch (type) {
+ case 'BigQuery':
+ rows.push(
+ { ...BIGQUERY_PROJECT_ID_FIELD_COPY, value: projectId },
+ { ...BIGQUERY_DATASET_ID_FIELD_COPY, value: datasetId }
+ )
+ break
+ case 'DuckLake':
+ if (mode === 'custom') {
+ rows.push(
+ {
+ ...DUCKLAKE_CATALOG_URL_FIELD_COPY,
+ description: DUCKLAKE_CATALOG_URL_FIELD_COPY.createDescription,
+ value: catalogUrl,
+ isMasked: true,
+ },
+ { ...DUCKLAKE_DATA_PATH_FIELD_COPY, value: dataPath }
+ )
+ } else {
+ rows.push({ ...DUCKLAKE_BUCKET_FIELD_COPY, value: bucket })
+ }
+ break
+ case 'Snowflake':
+ rows.push(
+ { ...SNOWFLAKE_ACCOUNT_ID_FIELD_COPY, value: account },
+ { ...SNOWFLAKE_DATABASE_FIELD_COPY, value: database },
+ { ...SNOWFLAKE_SCHEMA_FIELD_COPY, value: schema }
+ )
+ break
+ case 'ClickHouse':
+ rows.push(
+ { ...CLICKHOUSE_URL_FIELD_COPY, value: url, isMasked: true },
+ { ...CLICKHOUSE_DATABASE_FIELD_COPY, value: clickhouseDatabase },
+ {
+ ...CLICKHOUSE_ENGINE_FIELD_COPY,
+ value: engine === 'merge_tree' ? 'MergeTree' : 'ReplacingMergeTree',
+ }
+ )
+ break
+ case 'Analytics Bucket':
+ rows.push(
+ { ...ANALYTICS_BUCKET_BUCKET_FIELD_COPY, value: warehouse },
+ {
+ ...ANALYTICS_BUCKET_NAMESPACE_FIELD_COPY,
+ value: namespace === CREATE_NEW_NAMESPACE ? newNamespace : namespace,
+ }
+ )
+ break
+ }
+ return (
+ <section aria-label="Destination review">
+ <div className="space-y-6 p-5">
+ <h3 className="text-sm font-medium text-foreground">Destination</h3>
+ <FormItemLayout
+ isReactForm={false}
+ layout="horizontal"
+ label="Type"
+ description={`Destination type cannot be changed after creation. ${type === 'Analytics Bucket' ? 'Analytics Bucket is deprecated.' : `${type} support is in public alpha.`}`}
+ >
+ <div className="flex items-center gap-3 rounded-md border bg-surface-200 p-3">
+ <DestinationLogo type={type} />
+ <span className="text-sm text-foreground">{type}</span>
+ </div>
+ </FormItemLayout>
+ </div>
+ <Separator />
+ <div className="space-y-6 p-5">
+ <h3 className="text-sm font-medium text-foreground">Connection</h3>
+ {[{ ...PIPELINE_NAME_FIELD_COPY, value: name }, ...rows].map((row) => (
+ <FormItemLayout
+ key={row.label}
+ isReactForm={false}
+ layout="horizontal"
+ label={row.label}
+ description={row.description}
+ >
+ {row.isMasked ? (
+ <MaskedUrl key={`${type}-${row.value}`} value={row.value ?? ''} label={row.label} />
+ ) : (
+ <Input readOnly aria-label={row.label} value={row.value || 'Not set'} />
+ )}
+ </FormItemLayout>
+ ))}
+ <FormItemLayout
+ isReactForm={false}
+ layout="horizontal"
+ label="Pipeline region"
+ description={getPipelineRegionDescription(type)}
+ >
+ <PipelineRegionReadonly />
+ </FormItemLayout>
+ </div>
+ </section>
+ )
+}
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 461fa0d43b7..23d9d27265f 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
@@ -317,6 +317,9 @@ describe('DestinationForm edit submission', () => {
onClose={vi.fn()}
/>
)
+ expect(screen.queryByRole('region', { name: 'Destination review' }) !== null).toBe(
+ shouldShowSection
+ )
expect(screen.queryByRole('region', { name: 'Data' }) !== null).toBe(shouldShowSection)
expect(screen.queryByRole('region', { name: 'Destination connection' }) !== null).toBe(
shouldShowSection
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 6955b4bafca..5b3a9aca81f 100644
--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.tsx
+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/index.tsx
@@ -12,6 +12,7 @@ import * as z from 'zod'
import { PipelineConnectionSection } from '../../CreatePipeline/PipelineConnectionSection'
import { PipelineDataSection } from '../../CreatePipeline/PipelineDataSection'
+import { PipelineDestinationReview } from '../../CreatePipeline/PipelineDestinationReview'
import {
useIsETLBigQueryPrivateAlpha,
useIsETLClickHousePrivateAlpha,
@@ -537,6 +538,13 @@ export const DestinationForm = ({
</>
)}
+ {shouldShowConnectionSection && (
+ <>
+ <DialogSectionSeparator />
+ <PipelineDestinationReview type={selectedType} control={form.control} />
+ </>
+ )}
+
{!editMode && hasRunValidation && !isValidating && (
<>
<DialogSectionSeparator />