mirror of
https://github.com/supabase/supabase.git
synced 2026-09-22 13:37:53 +08:00
edec85d1ca
## Summary Make pipeline actions and status feedback reliable while requests are running or fail. Let the backend coordinate table resets and restarts, keep stopped pipelines stopped after resets or settings changes, and refresh the UI from confirmed backend state. ## Pipeline actions and recovery - Reset one table, all errored tables, or all tables through the rollback endpoint without separate frontend stop/start requests. Explain which destination data is deleted, which rows are copied again, initial sync charges, and the skip-initial-sync setting. - Keep pending feedback until the action and a fresh status read finish, including across navigation and polling errors. Prevent overlapping actions and disable start/stop controls when status is unavailable or transitioning. - Close the creation form once the pipeline is created. If its initial start fails, users can retry Start on the existing pipeline without creating a duplicate. - Wait for confirmed shutdown before deletion; a shutdown error or timeout leaves deletion retryable. Keep failed version updates open and avoid reporting success. - Clarify recovery guidance and pending labels, suppress duplicate error toasts, and hide stale table errors during transitions. ## Status updates and shared UI - Poll pipeline status and table metrics one second after each response, share in-flight reads, pause dashboard polling in background tabs, and respect rate-limit backoff. The shutdown waiter continues in the background. - Refresh metadata after mutations even when an older read is in flight, while preserving shared polling requests. Refresh affected data after failures that may follow a committed reset or settings change. - Move pending request state into the shared, project-keyed `DatabaseLayout` so the list, detail page, and diagram stay consistent. The surrounding database-page changes update named imports in both Next.js and TanStack routes. - Simplify action, status, and form rendering; announce status changes to assistive technology; and sort table statuses without mutating cached data. --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com>
123 lines
3.7 KiB
TypeScript
123 lines
3.7 KiB
TypeScript
import { PipelineStatusName } from './Replication.constants'
|
|
import { ReplicationPipelineStatusData } from '@/data/replication/pipeline-status-query'
|
|
import { PipelineStatusRequestStatus } from '@/state/replication-pipeline-request-status'
|
|
|
|
export const getStatusName = (
|
|
status: ReplicationPipelineStatusData['status'] | undefined
|
|
): PipelineStatusName | undefined => {
|
|
if (!status || typeof status !== 'object' || !('name' in status)) return undefined
|
|
return normalizePipelineStatusName(status.name)
|
|
}
|
|
|
|
export const normalizePipelineStatusName = (statusName?: string): PipelineStatusName | undefined =>
|
|
typeof statusName === 'string' &&
|
|
(Object.values(PipelineStatusName) as string[]).includes(statusName)
|
|
? (statusName as PipelineStatusName)
|
|
: undefined
|
|
|
|
export type PipelineDisplayStateKey =
|
|
| 'starting'
|
|
| 'stopping'
|
|
| 'failed'
|
|
| 'stopped'
|
|
| 'running'
|
|
| 'unknown'
|
|
|
|
export type PipelineDisplayType = 'failure' | 'loading' | 'success' | 'idle'
|
|
|
|
export interface PipelineDisplayState {
|
|
key: PipelineDisplayStateKey
|
|
label: string
|
|
title: string
|
|
message: string
|
|
badge: string
|
|
type: PipelineDisplayType
|
|
}
|
|
|
|
const PIPELINE_DISPLAY_STATES: Record<PipelineDisplayStateKey, PipelineDisplayState> = {
|
|
starting: {
|
|
key: 'starting',
|
|
label: 'Starting',
|
|
title: 'Starting pipeline',
|
|
message: 'Starting the pipeline. Replication will resume once running.',
|
|
badge: 'Starting',
|
|
type: 'loading',
|
|
},
|
|
stopping: {
|
|
key: 'stopping',
|
|
label: 'Stopping',
|
|
title: 'Stopping pipeline',
|
|
message: 'Stopping replication. Data transfer will stop after in-flight work finishes.',
|
|
badge: 'Stopping',
|
|
type: 'loading',
|
|
},
|
|
failed: {
|
|
key: 'failed',
|
|
label: 'Failed',
|
|
title: 'Pipeline failed',
|
|
message: 'Replication has encountered an error',
|
|
badge: 'Failed',
|
|
type: 'failure',
|
|
},
|
|
stopped: {
|
|
key: 'stopped',
|
|
label: 'Stopped',
|
|
title: 'Pipeline stopped',
|
|
message: 'Replication is stopped. Start the pipeline to resume data synchronization.',
|
|
badge: 'Stopped',
|
|
type: 'idle',
|
|
},
|
|
running: {
|
|
key: 'running',
|
|
label: 'Running',
|
|
title: 'Pipeline running',
|
|
message: 'Replication is active and processing changes',
|
|
badge: 'Running',
|
|
type: 'success',
|
|
},
|
|
unknown: {
|
|
key: 'unknown',
|
|
label: 'Unknown',
|
|
title: 'Pipeline status unknown',
|
|
message: 'Unable to determine pipeline status',
|
|
badge: 'Unknown',
|
|
type: 'idle',
|
|
},
|
|
}
|
|
|
|
export const getPipelineDisplayState = (
|
|
requestStatus?: PipelineStatusRequestStatus,
|
|
statusName?: PipelineStatusName
|
|
): PipelineDisplayState => {
|
|
if (requestStatus === PipelineStatusRequestStatus.StartRequested) {
|
|
return PIPELINE_DISPLAY_STATES.starting
|
|
}
|
|
if (requestStatus === PipelineStatusRequestStatus.StopRequested) {
|
|
return PIPELINE_DISPLAY_STATES.stopping
|
|
}
|
|
|
|
switch (statusName) {
|
|
case PipelineStatusName.STARTING:
|
|
return PIPELINE_DISPLAY_STATES.starting
|
|
case PipelineStatusName.FAILED:
|
|
return PIPELINE_DISPLAY_STATES.failed
|
|
case PipelineStatusName.STOPPED:
|
|
return PIPELINE_DISPLAY_STATES.stopped
|
|
case PipelineStatusName.STARTED:
|
|
return PIPELINE_DISPLAY_STATES.running
|
|
case PipelineStatusName.STOPPING:
|
|
return PIPELINE_DISPLAY_STATES.stopping
|
|
case PipelineStatusName.UNKNOWN:
|
|
default:
|
|
return PIPELINE_DISPLAY_STATES.unknown
|
|
}
|
|
}
|
|
|
|
/** Resetting tables or applying settings must not imply starting an inactive pipeline. */
|
|
export const getRestartRequestStatus = (statusName?: PipelineStatusName) => {
|
|
if (statusName === PipelineStatusName.STARTED || statusName === PipelineStatusName.FAILED) {
|
|
return PipelineStatusRequestStatus.StopRequested
|
|
}
|
|
return PipelineStatusRequestStatus.None
|
|
}
|