mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 09:55:06 +03:00
## What kind of change does this PR introduce? Studio UI and interaction polish. This is the second PR in the Pipelines review stack and depends on #50251. ## What is the current behaviour? Pipeline rows require a separate view action, cannot be sorted, and present lifecycle, lag, and destination terminology inconsistently. ## What is the new behaviour? Makes rows navigable with link-like mouse and keyboard behaviour, adds Name and Status sorting, reuses cached status queries, and moves row actions into the overflow menu. It also clarifies pipeline terminology, adds Docs and feedback actions, and standardises state, error, lag, and loading presentation with accessible announcements. | Before | After | | --- | --- | | <img width="1280" height="1323" alt="Replication Database ETL BigTable ETL Team Supabase" src="https://github.com/user-attachments/assets/53a62283-0e58-4408-8409-2b87a38af159" /> | <img width="1280" height="1323" alt="Replication Database Agua Basket Supabase" src="https://github.com/user-attachments/assets/ba4de1e0-4a84-43b4-8975-ca05a3056bcf" /> | ## To test 1. Open `/project/<ref>/database/replication`. 2. Sort by Name and Status, then confirm failed and stopped pipelines surface first when Status is ascending. 3. Click a row, use Enter or Space, and modifier-click or middle-click to verify link behaviour. 4. Open the row overflow menu and confirm it does not navigate. 5. Check loading, initial sync, caught up, numeric lag, unavailable lag, and table-error states where available. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added sortable pipeline lists with clearer loading, empty, and error states. - Pipeline rows now support direct navigation, detail viewing, status indicators, lag progress, and table error summaries. - Added initial-sync progress indicators and accessible status announcements. - Added documentation and feedback links. - Improved pipeline version update and enable/disable dialogs. - **Bug Fixes** - Prevented right-clicks from triggering navigation. - Improved unavailable lag and initial-sync handling. - **Style** - Standardized replication terminology and confirmation messaging around pipelines. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
210 lines
7.2 KiB
TypeScript
210 lines
7.2 KiB
TypeScript
import { useParams } from 'common'
|
|
import { ArrowUpRight } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { parseAsInteger, parseAsStringEnum, useQueryState } from 'nuqs'
|
|
import { useEffect, useRef } from 'react'
|
|
import { toast } from 'sonner'
|
|
import {
|
|
Button,
|
|
cn,
|
|
DialogSectionSeparator,
|
|
Sheet,
|
|
SheetContent,
|
|
SheetDescription,
|
|
SheetHeader,
|
|
SheetSection,
|
|
SheetTitle,
|
|
} from 'ui'
|
|
import { Admonition } from 'ui-patterns/Admonition'
|
|
|
|
import { EnablePipelinesCallout } from '../EnablePipelinesCallout'
|
|
import { PipelineStatusName } from '../Replication.constants'
|
|
import { useDestinationInformation } from '../useDestinationInformation'
|
|
import { useIsETLPrivateAlpha } from '../useIsETLPrivateAlpha'
|
|
import { DestinationForm } from './DestinationForm'
|
|
import { DestinationType } from './DestinationPanel.types'
|
|
import { DestinationTypeSelection } from './DestinationTypeSelection'
|
|
import { DiscardChangesConfirmationDialog } from '@/components/ui-patterns/Dialogs/DiscardChangesConfirmationDialog'
|
|
import { DocsButton } from '@/components/ui/DocsButton'
|
|
import { useReplicationDestinationsQuery } from '@/data/replication/destinations-query'
|
|
import { checkLocalETLNotSetUp } from '@/data/replication/utils'
|
|
import { useConfirmOnClose } from '@/hooks/ui/useConfirmOnClose'
|
|
import { DOCS_URL } from '@/lib/constants'
|
|
|
|
export const DestinationPanel = () => {
|
|
const { ref: projectRef } = useParams()
|
|
const enablePgReplicate = useIsETLPrivateAlpha()
|
|
const { error: destinationsError } = useReplicationDestinationsQuery({ projectRef })
|
|
const isLocalETLNotSetUp = checkLocalETLNotSetUp(destinationsError)
|
|
|
|
const [urlDestinationType, setDestinationType] = useQueryState(
|
|
'destinationType',
|
|
parseAsStringEnum<DestinationType>([
|
|
'BigQuery',
|
|
'Analytics Bucket',
|
|
'DuckLake',
|
|
'Snowflake',
|
|
'ClickHouse',
|
|
]).withOptions({
|
|
history: 'push',
|
|
clearOnDefault: true,
|
|
})
|
|
)
|
|
|
|
const [edit, setEdit] = useQueryState(
|
|
'edit',
|
|
parseAsInteger.withOptions({
|
|
history: 'push',
|
|
clearOnDefault: true,
|
|
})
|
|
)
|
|
|
|
const visible = urlDestinationType !== null || edit !== null
|
|
const editMode = edit !== null
|
|
|
|
const {
|
|
sourceId,
|
|
pipeline,
|
|
statusName,
|
|
replicationNotEnabled,
|
|
type: existingDestinationType,
|
|
destinationFetcher,
|
|
} = useDestinationInformation({ id: edit })
|
|
const destinationType = existingDestinationType ?? urlDestinationType
|
|
const invalidExistingDestination = destinationFetcher.error?.code === 404
|
|
|
|
const existingDestination = editMode
|
|
? {
|
|
sourceId,
|
|
destinationId: edit,
|
|
pipelineId: pipeline?.id,
|
|
statusName,
|
|
enabled:
|
|
statusName === PipelineStatusName.STARTED || statusName === PipelineStatusName.FAILED,
|
|
}
|
|
: undefined
|
|
|
|
const checkIsDirtyRef = useRef<() => boolean>(() => false)
|
|
|
|
const onClose = () => {
|
|
checkIsDirtyRef.current = () => false
|
|
setDestinationType(null)
|
|
setEdit(null)
|
|
}
|
|
|
|
const { confirmOnClose, handleOpenChange, modalProps } = useConfirmOnClose({
|
|
checkIsDirty: () => checkIsDirtyRef.current(),
|
|
onClose,
|
|
})
|
|
|
|
const docsUrl =
|
|
destinationType === 'BigQuery'
|
|
? `${DOCS_URL}/guides/database/replication/bigquery#configure-bigquery-as-a-destination`
|
|
: `${DOCS_URL}/guides/database/replication/pipelines#step-3-configure-a-destination`
|
|
|
|
useEffect(() => {
|
|
if (edit !== null && invalidExistingDestination) {
|
|
toast(`Unable to find destination ID ${edit}`)
|
|
setEdit(null)
|
|
}
|
|
}, [edit, invalidExistingDestination, setEdit])
|
|
|
|
const typeSelection = (
|
|
<>
|
|
<DestinationTypeSelection />
|
|
<DialogSectionSeparator />
|
|
</>
|
|
)
|
|
|
|
const pipelinesTypeSelection = (
|
|
<>
|
|
{typeSelection}
|
|
{destinationType != null && isLocalETLNotSetUp && (
|
|
<SheetSection className="pb-0!">
|
|
<Admonition
|
|
type="warning"
|
|
title="Replication unavailable locally"
|
|
description="Configure the replication API to manage pipelines in local development."
|
|
/>
|
|
</SheetSection>
|
|
)}
|
|
</>
|
|
)
|
|
|
|
return (
|
|
<>
|
|
<Sheet open={visible} onOpenChange={handleOpenChange}>
|
|
<SheetContent size="lg" showClose={false} className="max-w-3xl">
|
|
<div className="flex flex-col h-full min-h-0" tabIndex={-1}>
|
|
<SheetHeader className="flex items-center justify-between">
|
|
<div>
|
|
<SheetTitle>{editMode ? 'Edit pipeline' : 'Add pipeline'}</SheetTitle>
|
|
<SheetDescription>
|
|
{editMode
|
|
? 'Update how this pipeline sends data to its destination.'
|
|
: 'Send tables to an external destination for analytics workloads.'}
|
|
</SheetDescription>
|
|
</div>
|
|
<DocsButton
|
|
href={docsUrl}
|
|
topic={`${destinationType ?? 'destination'} pipeline settings`}
|
|
/>
|
|
</SheetHeader>
|
|
|
|
{!enablePgReplicate ? (
|
|
<div className="grow overflow-auto min-h-0">
|
|
{pipelinesTypeSelection}
|
|
<SheetSection>
|
|
<div className={cn('border rounded-md p-6 flex flex-col gap-y-4')}>
|
|
<div className="flex flex-col gap-y-1">
|
|
<h4>Request Pipelines access</h4>
|
|
<p className="text-sm text-foreground-light">
|
|
Pipelines is in <span className="text-foreground">public alpha</span> and
|
|
being rolled out gradually. Request access below to join the waitlist.
|
|
</p>
|
|
</div>
|
|
<div className="flex gap-x-2">
|
|
<Button
|
|
asChild
|
|
variant="secondary"
|
|
iconRight={<ArrowUpRight size={16} strokeWidth={1.5} />}
|
|
>
|
|
<Link
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
href="https://forms.supabase.com/pg_replicate"
|
|
>
|
|
Request Pipelines access
|
|
</Link>
|
|
</Button>
|
|
<DocsButton href={`${DOCS_URL}/guides/database/replication#pipelines`} />
|
|
</div>
|
|
</div>
|
|
</SheetSection>
|
|
</div>
|
|
) : replicationNotEnabled ? (
|
|
<div className="grow overflow-auto min-h-0">
|
|
{pipelinesTypeSelection}
|
|
<SheetSection>
|
|
<EnablePipelinesCallout className="p-6!" type={destinationType} />
|
|
</SheetSection>
|
|
</div>
|
|
) : (
|
|
<DestinationForm
|
|
visible={visible}
|
|
selectedType={destinationType ?? 'BigQuery'}
|
|
existingDestination={existingDestination}
|
|
typeSelection={pipelinesTypeSelection}
|
|
checkIsDirtyRef={checkIsDirtyRef}
|
|
onClose={onClose}
|
|
onCancel={confirmOnClose}
|
|
/>
|
|
)}
|
|
</div>
|
|
</SheetContent>
|
|
</Sheet>
|
|
<DiscardChangesConfirmationDialog {...modalProps} />
|
|
</>
|
|
)
|
|
}
|