The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(studio): add pipeline wizard destination selection (#51568)
Danny Whited457ab59c713
diff --git a/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineDestinationSelection.test.tsx b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineDestinationSelection.test.tsxnew file mode 100644index 00000000000..a7120a87928--- /dev/null+++ b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineDestinationSelection.test.tsx@@ -0,0 +1,83 @@+import { fireEvent, render, screen, waitFor } from '@testing-library/react'+import userEvent from '@testing-library/user-event'+import { describe, expect, it, vi } from 'vitest'++import { PipelineDestinationSelection } from './PipelineDestinationSelection'++const destinations = ['BigQuery', 'DuckLake', 'Snowflake', 'ClickHouse'] satisfies Parameters<+ typeof PipelineDestinationSelection+>[0]['availableDestinations']++describe('PipelineDestinationSelection', () => {+ it('shows only available destinations in the intended order', () => {+ render(+ <PipelineDestinationSelection+ availableDestinations={['ClickHouse', 'BigQuery']}+ value="BigQuery"+ onChange={vi.fn()}+ />+ )+ expect(screen.getAllByRole('radio').map((radio) => radio.getAttribute('value'))).toEqual([+ 'BigQuery',+ 'ClickHouse',+ ])+ expect(screen.getByRole('radio', { name: /BigQuery/ })).toBeChecked()+ expect(screen.queryByText('Analytics Bucket')).not.toBeInTheDocument()+ })++ it('supports pointer and keyboard selection', async () => {+ const onChange = vi.fn()+ render(+ <PipelineDestinationSelection+ availableDestinations={destinations}+ value="BigQuery"+ onChange={onChange}+ />+ )+ await userEvent.click(screen.getByRole('radio', { name: /BigQuery/ }))+ await userEvent.keyboard('{ArrowDown}')+ await waitFor(() => expect(screen.getByRole('radio', { name: /DuckLake/ })).toHaveFocus())+ await userEvent.keyboard(' ')+ expect(onChange).toHaveBeenLastCalledWith('DuckLake')+ fireEvent.click(screen.getByRole('radio', { name: /Snowflake/ }))+ expect(onChange).toHaveBeenLastCalledWith('Snowflake')+ })++ it('blocks changes while disabled', () => {+ const onChange = vi.fn()+ render(+ <PipelineDestinationSelection+ availableDestinations={destinations}+ value="BigQuery"+ onChange={onChange}+ disabled+ />+ )+ fireEvent.click(screen.getByRole('radio', { name: /DuckLake/ }))+ expect(onChange).not.toHaveBeenCalled()+ })++ it('gives Analytics Bucket an accessible label without whitespace in its ID', () => {+ render(+ <PipelineDestinationSelection+ availableDestinations={['Analytics Bucket']}+ value="Analytics Bucket"+ onChange={vi.fn()}+ />+ )+ const radio = screen.getByRole('radio', { name: /Analytics Bucket/ })+ expect(radio.id).not.toMatch(/\s/)+ expect(radio).toHaveAccessibleName(/Analytics Bucket/)+ expect(radio).toBeChecked()+ })++ it('handles no available destinations without selecting one', () => {+ const onChange = vi.fn()+ render(+ <PipelineDestinationSelection availableDestinations={[]} value={null} onChange={onChange} />+ )+ expect(screen.getByText('No destinations are available.')).toBeInTheDocument()+ expect(screen.queryByRole('radiogroup')).not.toBeInTheDocument()+ expect(onChange).not.toHaveBeenCalled()+ })+})diff --git a/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineDestinationSelection.tsx b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineDestinationSelection.tsxnew file mode 100644index 00000000000..a5b406aeafa--- /dev/null+++ b/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineDestinationSelection.tsx@@ -0,0 +1,79 @@+import { useId, type ReactNode } from 'react'+import { Badge, RadioGroupStacked, RadioGroupStackedItem } from 'ui'++export type PipelineDestinationType =+ | 'BigQuery'+ | 'DuckLake'+ | 'Snowflake'+ | 'ClickHouse'+ | 'Analytics Bucket'++const DESTINATIONS: { type: PipelineDestinationType; description: string }[] = [+ { type: 'BigQuery', description: 'Replicate changes to BigQuery for analytics and BI' },+ { type: 'DuckLake', description: 'Replicate changes to DuckLake for open lakehouse storage' },+ { type: 'Snowflake', description: 'Replicate changes to Snowflake for cloud data warehousing' },+ { type: 'ClickHouse', description: 'Replicate changes to ClickHouse for real-time analytics' },+ {+ type: 'Analytics Bucket',+ description: 'Replicate changes to Supabase Storage as Apache Iceberg tables',+ },+]++export const PipelineDestinationSelection = ({+ availableDestinations,+ value,+ onChange,+ disabled = false,+ renderLogo,+}: {+ availableDestinations: PipelineDestinationType[]+ value: PipelineDestinationType | null+ onChange: (value: PipelineDestinationType) => void+ disabled?: boolean+ renderLogo?: (type: PipelineDestinationType) => ReactNode+}) => {+ const id = useId()+ const options = DESTINATIONS.filter(({ type }) => availableDestinations.includes(type))++ if (options.length === 0)+ return <p className="text-sm text-foreground-light">No destinations are available.</p>++ return (+ <div className="space-y-3">+ <p className="text-sm font-medium text-foreground">Destination type</p>+ <RadioGroupStacked+ aria-label="Destination type"+ orientation="vertical"+ value={value ?? ''}+ disabled={disabled}+ onValueChange={(nextValue) => {+ const option = options.find(({ type }) => type === nextValue)+ if (option) onChange(option.type)+ }}+ >+ {options.map(({ type, description }) => (+ <RadioGroupStackedItem+ key={type}+ id={`${id}-${type.replace(/\s+/g, '-')}`}+ value={type}+ className="[&>div]:items-center [&>div]:py-3.5"+ label={+ <span className="flex items-center gap-x-3.5">+ {renderLogo?.(type)}+ <span className="flex flex-col">+ <span className="flex items-center gap-x-2 font-medium text-foreground">+ {type}+ {type === 'Analytics Bucket' && <Badge variant="warning">DEPRECATED</Badge>}+ </span>+ <span className="text-sm text-foreground-lighter text-balance">+ {description}+ </span>+ </span>+ </span>+ }+ />+ ))}+ </RadioGroupStacked>+ </div>+ )+}diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsx b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsxindex 3197d0389dd..8e5c1c844ff 100644--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsx+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsx@@ -16,6 +16,11 @@ mockAnimationsApi()// Feature flags are not API calls — mock at the module level so tests can// control per-destination-type visibility without hitting PostHog.+const mockCreationPreview = vi.fn()+vi.mock('@/components/interfaces/App/FeaturePreview/FeaturePreviewContext', () => ({+ usePipelineCreationPreview: () => ({ isEnabled: mockCreationPreview() }),+}))+const mockBigQueryEnabled = vi.fn()const mockIcebergEnabled = vi.fn()const mockDucklakeEnabled = vi.fn()@@ -52,6 +57,7 @@ const addBackgroundMocks = () => {describe('DestinationTypeSelection', () => {beforeEach(() => {window.localStorage.clear()+ mockCreationPreview.mockReturnValue(false)mockBigQueryEnabled.mockReturnValue(false)mockIcebergEnabled.mockReturnValue(false)mockDucklakeEnabled.mockReturnValue(false)@@ -60,6 +66,27 @@ describe('DestinationTypeSelection', () => {addBackgroundMocks()})+ test('uses radio cards only when creation preview is enabled', async () => {+ mockCreationPreview.mockReturnValue(true)+ mockBigQueryEnabled.mockReturnValue(true)+ mockDucklakeEnabled.mockReturnValue(true)+ mockIcebergEnabled.mockReturnValue(true)+ customRender(<DestinationTypeSelection />)+ expect(await screen.findByRole('radiogroup', { name: 'Destination type' })).toBeInTheDocument()+ expect(screen.queryByRole('combobox')).not.toBeInTheDocument()+ expect(screen.getByRole('radio', { name: /Analytics Bucket/ })).toBeInTheDocument()+ expect(screen.getByText('DEPRECATED')).toBeInTheDocument()+ fireEvent.click(screen.getByRole('radio', { name: /Analytics Bucket/ }))+ expect(await screen.findByRole('radio', { name: /Analytics Bucket/ })).toBeChecked()+ expect(+ screen.getByText(+ 'Destination type cannot be changed after creation. Analytics Bucket is deprecated.'+ )+ ).toBeInTheDocument()+ fireEvent.click(screen.getByRole('radio', { name: /DuckLake/ }))+ expect(await screen.findByRole('radio', { name: /DuckLake/ })).toBeChecked()+ })+test('shows placeholder when no type is selected', async () => {customRender(<DestinationTypeSelection />)@@ -115,30 +142,34 @@ describe('DestinationTypeSelection', () => {})- test('disables the selector in edit mode so the destination type cannot be changed', async () => {- mockBigQueryEnabled.mockReturnValue(true)- // Edit mode triggers useDestinationInformation({ id: 1 }) which fires destination-by-id- addAPIMock({- method: 'get',- path: '/platform/replication/:ref/destinations/:destination_id',- response: () =>- HttpResponse.json<ReplicationDestinationResponse>({- tenant_id: 't',- id: 1,- name: 'My BigQuery Destination',- config: {- big_query: {- project_id: 'gcp-proj',- dataset_id: 'analytics',- connection_pool_size: 5,+ test.each([false, true])(+ 'keeps the edit selector locked (creation preview: %s)',+ async (isEnabled) => {+ mockCreationPreview.mockReturnValue(isEnabled)+ mockBigQueryEnabled.mockReturnValue(true)+ // Edit mode triggers useDestinationInformation({ id: 1 }) which fires destination-by-id+ addAPIMock({+ method: 'get',+ path: '/platform/replication/:ref/destinations/:destination_id',+ response: () =>+ HttpResponse.json<ReplicationDestinationResponse>({+ tenant_id: 't',+ id: 1,+ name: 'My BigQuery Destination',+ config: {+ big_query: {+ project_id: 'gcp-proj',+ dataset_id: 'analytics',+ connection_pool_size: 5,+ },},- },- }),- })+ }),+ })- // ?edit=1 locks the type to the existing destination- customRender(<DestinationTypeSelection />, { nuqs: { searchParams: { edit: '1' } } })+ // ?edit=1 locks the type to the existing destination+ customRender(<DestinationTypeSelection />, { nuqs: { searchParams: { edit: '1' } } })- expect(await screen.findByRole('combobox')).toBeDisabled()- })+ expect(await screen.findByRole('combobox')).toBeDisabled()+ }+ )})diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.tsx b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.tsxindex 50ea80272d0..dddeec2e6f7 100644--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.tsx+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.tsx@@ -10,6 +10,7 @@ import {} from 'ui'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'+import { PipelineDestinationSelection } from '../CreatePipeline/PipelineDestinationSelection'import { DestinationLogo } from '../DestinationLogo'import { useDestinationInformation } from '../useDestinationInformation'import {@@ -20,6 +21,7 @@ import {useIsETLSnowflakePrivateAlpha,} from '../useIsETLPrivateAlpha'import { DestinationType } from './DestinationPanel.types'+import { usePipelineCreationPreview } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'interface DestinationTypeOption {value: DestinationType@@ -35,6 +37,7 @@ interface DestinationTypeGroup {}export const DestinationTypeSelection = () => {+ const { isEnabled: isCreationPreviewEnabled } = usePipelineCreationPreview()const etlEnableBigQuery = useIsETLBigQueryPrivateAlpha()const etlEnableIceberg = useIsETLIcebergPrivateAlpha()const etlEnableDucklake = useIsETLDucklakePrivateAlpha()@@ -143,6 +146,21 @@ export const DestinationTypeSelection = () => {</span>) : undefined+ if (isCreationPreviewEnabled && !editMode) {+ const availableDestinations = options.map(({ value }) => value)+ return (+ <div className="p-5">+ <PipelineDestinationSelection+ availableDestinations={availableDestinations}+ value={destinationType ?? null}+ onChange={(value) => setDestinationType(value)}+ renderLogo={(type) => <DestinationLogo type={type} />}+ />+ <p className="mt-3 text-sm text-foreground-lighter">{typeDescription}</p>+ </div>+ )+ }+return (<><FormItemLayout