mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
## What kind of change does this PR introduce? Feature polish and a connection behaviour change. ## What is the current behaviour? The Warehouse Connect sheet presents FlightSQL and DuckDB configuration together. Enabling Warehouse also enables DuckDB catalogue access automatically, even when the user only needs FlightSQL. ## What is the new behaviour? The Connect sheet now starts with a query engine selector: - FlightSQL shows the endpoint, connection string, user, password action, and command-line example. - DuckDB shows a persistent catalogue access switch. When enabled, credentials and the attach script appear as the same numbered "Follow these steps" flow used by other connection methods. - Switching back to FlightSQL removes the DuckDB instructions. > [!NOTE] > This is an incremental change towards [this UI](https://linear.app/supabase/project/warehouse-core-mvp-b85711dc2eff/activity#project-update-4e3183e1), where the Integrations page is the control plane and Connect sheet is simply for read-only connect values. https://github.com/supabase/supabase/pull/50247 and https://github.com/supabase/supabase/pull/50195 are subsequent PRs that get us there. > [!IMPORTANT] > Enabling Warehouse no longer enables DuckDB catalogue access automatically. DuckDB users must enable it explicitly from the connection details. FlightSQL is unaffected. This keeps global Warehouse provisioning separate from optional credentials for one query engine. It also prevents successful Warehouse setup from being followed by a secondary catalogue mutation that can fail independently. | Before | After | | --- | --- | | <img width="1280" height="1323" alt="10752" src="https://github.com/user-attachments/assets/83b1069b-a262-4068-a5e3-b7f49860fdb2" /> | <img width="1280" height="1323" alt="Regular AWS Teamer Supabase" src="https://github.com/user-attachments/assets/86ff1fe4-6513-44a8-88e1-1c7985f4910e" /> | | <img width="1280" height="1323" alt="10752" src="https://github.com/user-attachments/assets/83b1069b-a262-4068-a5e3-b7f49860fdb2" /> | <img width="1280" height="1323" alt="31254" src="https://github.com/user-attachments/assets/733f074d-a52a-44a6-8898-a8f3c2b68294" /> | | _Unable to replicate._ | <img width="1280" height="1323" alt="Regular AWS Teamer Supabase" src="https://github.com/user-attachments/assets/c7d4ee59-b3f0-48b0-a6d7-2202ef5c2609" /> | ## To test 1. Open `/project/{ref}?showConnect=true&connectTab=warehouse` on a project. Enable Warehouse on 1+ table. 2. Confirm FlightSQL is selected initially and its connection fields are visible. 3. Select DuckDB and confirm the catalogue switch is always visible. 4. Enable catalogue access and confirm the environment variables and SQL appear below in two numbered steps. 5. Switch back to FlightSQL and confirm the DuckDB steps disappear. 6. Set up Warehouse on a project where it is not yet enabled and confirm DuckDB catalogue access is not enabled automatically. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a query-engine selector for FlightSQL and DuckDB connection setups. * Added guided DuckDB setup steps, copy-to-clipboard support, and reveal/hide controls for secrets. * Added a catalog access toggle with confirmation feedback. * Catalog details load only when DuckDB is selected. * **Updates** * Streamlined warehouse connection layouts with consistent spacing. * Catalog access is now controlled separately from the initial warehouse setup. * Excluded sensitive setup details from copied prompts and added copy-status announcements. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
131 lines
3.7 KiB
TypeScript
131 lines
3.7 KiB
TypeScript
import { useParams } from 'common'
|
|
import { useState } from 'react'
|
|
import { Button } from 'ui'
|
|
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
import { WarehouseConnectionDetails } from './WarehouseConnectionDetails'
|
|
import { WarehouseEnablingProgress } from './WarehouseEnablingProgress'
|
|
import type { WarehouseSetupTarget } from './WarehouseModePanel.utils'
|
|
import { WarehouseSchemaTablePicker } from './WarehouseSchemaTablePicker'
|
|
import { AlertError } from '@/components/ui/AlertError'
|
|
import { useWarehouseSetupMutation } from '@/data/warehouse/warehouse-setup-mutation'
|
|
import { useWarehouseSetupStatusQuery } from '@/data/warehouse/warehouse-setup-status-query'
|
|
|
|
const POLLING_SETUP_STATUSES = new Set(['setting_up', 'copying'])
|
|
|
|
interface WarehouseSetupCompleteProps {
|
|
onSubmit: (targets: WarehouseSetupTarget[]) => void
|
|
isSubmitting: boolean
|
|
}
|
|
|
|
const WarehouseSetupComplete = ({ onSubmit, isSubmitting }: WarehouseSetupCompleteProps) => {
|
|
const [isEditingTables, setIsEditingTables] = useState(false)
|
|
|
|
if (isEditingTables) {
|
|
return (
|
|
<div className="p-8">
|
|
<WarehouseSchemaTablePicker
|
|
onSubmit={onSubmit}
|
|
isSubmitting={isSubmitting}
|
|
onBack={() => setIsEditingTables(false)}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return <WarehouseConnectionDetails onEditTables={() => setIsEditingTables(true)} />
|
|
}
|
|
|
|
export const WarehouseModePanel = () => {
|
|
const { ref: projectRef } = useParams()
|
|
|
|
const { data, isPending, isError, error } = useWarehouseSetupStatusQuery(
|
|
{ projectRef },
|
|
{
|
|
refetchInterval: (query) => {
|
|
const status = query.state.data?.setup_status
|
|
return status && POLLING_SETUP_STATUSES.has(status) ? 3000 : false
|
|
},
|
|
}
|
|
)
|
|
|
|
const setupMutation = useWarehouseSetupMutation()
|
|
|
|
const handleSetup = (targets: WarehouseSetupTarget[]) => {
|
|
if (!projectRef || targets.length === 0) return
|
|
|
|
setupMutation.mutate({ projectRef, body: { targets } })
|
|
}
|
|
|
|
if (isPending) {
|
|
return (
|
|
<div className="p-8">
|
|
<GenericSkeletonLoader />
|
|
</div>
|
|
)
|
|
}
|
|
if (isError) {
|
|
return (
|
|
<div className="p-8">
|
|
<AlertError subject="Failed to load Warehouse status" error={error} />
|
|
</div>
|
|
)
|
|
}
|
|
if (!data) {
|
|
return (
|
|
<div className="p-8">
|
|
<GenericSkeletonLoader />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const status = data.setup_status
|
|
|
|
if (status === 'not_started') {
|
|
return (
|
|
<div className="p-8">
|
|
<WarehouseSchemaTablePicker onSubmit={handleSetup} isSubmitting={setupMutation.isPending} />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (status === 'setting_up' || status === 'copying') {
|
|
return (
|
|
<div className="p-8">
|
|
<WarehouseEnablingProgress status={data} />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (status === 'error') {
|
|
const retryTargets: WarehouseSetupTarget[] = (data.tables ?? []).map((table) => ({
|
|
type: 'table' as const,
|
|
schema: table.schema,
|
|
name: table.name,
|
|
}))
|
|
const failingStep = data.steps.find((step) => step.status === 'error')
|
|
|
|
return (
|
|
<div className="p-8">
|
|
<AlertError
|
|
subject="Warehouse setup failed"
|
|
error={{
|
|
message:
|
|
failingStep?.message ?? 'An unknown error occurred while setting up Warehouse.',
|
|
}}
|
|
additionalActions={
|
|
retryTargets.length > 0 ? (
|
|
<Button loading={setupMutation.isPending} onClick={() => handleSetup(retryTargets)}>
|
|
Retry
|
|
</Button>
|
|
) : undefined
|
|
}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
// status === 'complete'
|
|
return <WarehouseSetupComplete onSubmit={handleSetup} isSubmitting={setupMutation.isPending} />
|
|
}
|