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? 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 -->
120 lines
4.5 KiB
TypeScript
120 lines
4.5 KiB
TypeScript
import { useParams } from 'common'
|
|
import { toast } from 'sonner'
|
|
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
|
|
|
|
import { getStatusName } from './Pipeline.utils'
|
|
import { PipelineStatusName, STATUS_REFRESH_FREQUENCY_MS } from './Replication.constants'
|
|
import { useReplicationPipelineStatusQuery } from '@/data/replication/pipeline-status-query'
|
|
import { useReplicationPipelineVersionQuery } from '@/data/replication/pipeline-version-query'
|
|
import { Pipeline } from '@/data/replication/pipelines-query'
|
|
import { useUpdatePipelineVersionMutation } from '@/data/replication/update-pipeline-version-mutation'
|
|
import {
|
|
PipelineStatusRequestStatus,
|
|
usePipelineRequestStatus,
|
|
} from '@/state/replication-pipeline-request-status'
|
|
import { type ResponseError } from '@/types'
|
|
|
|
interface UpdateVersionModalProps {
|
|
visible: boolean
|
|
pipeline?: Pipeline
|
|
confirmLabel?: string
|
|
confirmLabelLoading?: string
|
|
onClose: () => void
|
|
}
|
|
|
|
export const UpdateVersionModal = ({
|
|
visible,
|
|
pipeline,
|
|
confirmLabel,
|
|
confirmLabelLoading = 'Updating…',
|
|
onClose,
|
|
}: UpdateVersionModalProps) => {
|
|
const { ref: projectRef } = useParams()
|
|
const { setRequestStatus } = usePipelineRequestStatus()
|
|
|
|
const { data: pipelineStatusData } = useReplicationPipelineStatusQuery(
|
|
{ projectRef, pipelineId: pipeline?.id },
|
|
{ refetchInterval: STATUS_REFRESH_FREQUENCY_MS }
|
|
)
|
|
const pipelineStatus = pipelineStatusData?.status
|
|
const statusName = getStatusName(pipelineStatus)
|
|
// Treat an unresolved/unknown status as stopped so we don't optimistically claim a restart
|
|
// for a pipeline whose active state hasn't been confirmed yet.
|
|
const isStopped = statusName === undefined || statusName === PipelineStatusName.STOPPED
|
|
|
|
const { data: versionData, isPending: isLoadingVersion } = useReplicationPipelineVersionQuery({
|
|
projectRef,
|
|
pipelineId: pipeline?.id,
|
|
})
|
|
const currentVersionName = versionData?.version?.name
|
|
const newVersionName = versionData?.new_version?.name
|
|
|
|
const { mutateAsync: updatePipelineVersion, isPending: isUpdating } =
|
|
useUpdatePipelineVersionMutation()
|
|
|
|
const onConfirmUpdate = async () => {
|
|
if (!projectRef || !pipeline?.id) return
|
|
const versionId = versionData?.new_version?.id
|
|
if (!versionId) return
|
|
|
|
try {
|
|
await updatePipelineVersion({ projectRef, pipelineId: pipeline.id, versionId })
|
|
} catch (e) {
|
|
// 404: default changed; version cache will refresh via mutation onError. Keep dialog open.
|
|
if ((e as ResponseError)?.code === 404) return
|
|
return
|
|
}
|
|
|
|
if (!isStopped) {
|
|
setRequestStatus(pipeline.id, PipelineStatusRequestStatus.RestartRequested, statusName)
|
|
toast.success('Pipeline successfully updated and is currently restarting')
|
|
} else {
|
|
toast.success('Pipeline successfully updated')
|
|
}
|
|
|
|
onClose()
|
|
}
|
|
|
|
const resolvedConfirmLabel = confirmLabel ?? (isStopped ? 'Update version' : 'Update and restart')
|
|
|
|
return (
|
|
<ConfirmationModal
|
|
size="small"
|
|
variant={isStopped ? 'default' : 'warning'}
|
|
visible={visible}
|
|
title="Update available"
|
|
confirmLabel={resolvedConfirmLabel}
|
|
confirmLabelLoading={confirmLabelLoading}
|
|
loading={isUpdating}
|
|
onCancel={onClose}
|
|
onConfirm={onConfirmUpdate}
|
|
>
|
|
<div className="flex flex-col gap-y-3">
|
|
<p className="text-sm text-foreground-light">
|
|
{isStopped
|
|
? 'A newer pipeline version is available with improvements and bug fixes.'
|
|
: 'A newer pipeline version is available with improvements and bug fixes. The pipeline will restart and continue from where it left off.'}
|
|
</p>
|
|
<div className="overflow-hidden rounded-md border">
|
|
<table className="w-full text-sm">
|
|
<tbody aria-live="polite" aria-atomic="true">
|
|
<tr className="border-b">
|
|
<td className="px-3 py-2 text-foreground-lighter">Current</td>
|
|
<td className="px-3 py-2 text-right text-foreground" translate="no">
|
|
{isLoadingVersion ? 'Loading…' : (currentVersionName ?? 'Unknown')}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td className="px-3 py-2 text-foreground-lighter">New</td>
|
|
<td className="px-3 py-2 text-right text-foreground" translate="no">
|
|
{isLoadingVersion ? 'Loading…' : (newVersionName ?? 'Unknown')}
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</ConfirmationModal>
|
|
)
|
|
}
|