mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 02:15:05 +03:00
## What kind of change does this PR introduce? Studio UI improvement. ## What is the current behavior? The pipeline Overview uses bespoke loading, metrics, table-state and empty-state layouts that shift while data resolves and repeat status information from the detail header. ## What is the new behavior? Rebuilds the Overview around stable **Pipeline health** and **Replicated tables** sections. It adds layout-matched loading geometry, prioritised pipeline notices, initial-sync progress, clearer empty states, and accessible loading announcements. Complete pipeline configuration remains deferred to #49631. | Before | After | | --- | --- | | <img width="1024" height="759" alt="54861" src="https://github.com/user-attachments/assets/56e5cc5a-5d49-44c8-94d7-e1f1e0c827d5" /> | <img width="1024" height="759" alt="Replication Database Agua Basket Supabase" src="https://github.com/user-attachments/assets/43b6d0f6-6fd5-47f9-b3e5-788a33511304" /> | This is the final independent slice in the review series: #50443, #50444, #50445, #50446, then this PR. Each PR targets `master` and can merge on its own. Rebase this PR as earlier slices merge. ## To test 1. Open `/project/<ref>/database/replication` and select a pipeline. 2. Throttle the initial requests and confirm **Pipeline health** and **Replicated tables** keep their final geometry while loading. 3. Check running, initial-sync, stopped, failed, disconnected and unavailable states. 4. Confirm the Overview contains Pipeline health and Replicated tables only, without a Configuration section. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Reorganized replication pipeline status into Pipeline health and Replicated tables sections. - Added loading skeletons with accessible status announcements. - Added clearer notices for pipeline health, failed or disconnected pipelines, paused updates, lag, and synchronization progress. - Improved empty states when table data is unavailable or the pipeline is inactive. - Added options to view logs and reset failed tables. - **Tests** - Added coverage for loading behavior, pipeline notices, table counts, synchronization progress, and empty states. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
234 lines
7.9 KiB
TypeScript
234 lines
7.9 KiB
TypeScript
import { useParams } from 'common'
|
|
import {
|
|
ArrowUpCircle,
|
|
CircleStop,
|
|
Edit,
|
|
Eye,
|
|
MoreVertical,
|
|
Play,
|
|
RotateCcw,
|
|
Trash,
|
|
} from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { parseAsInteger, useQueryState } from 'nuqs'
|
|
import { toast } from 'sonner'
|
|
import {
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipTrigger,
|
|
WarningIcon,
|
|
} from 'ui'
|
|
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
import {
|
|
getStatusName,
|
|
PIPELINE_DISABLE_ALLOWED_FROM,
|
|
PIPELINE_ENABLE_ALLOWED_FROM,
|
|
} from './Pipeline.utils'
|
|
import { PipelineStatusName } from './Replication.constants'
|
|
import { ReplicationPipelineStatusData } from '@/data/replication/pipeline-status-query'
|
|
import { Pipeline } from '@/data/replication/pipelines-query'
|
|
import { useRestartPipelineMutation } from '@/data/replication/restart-pipeline-mutation'
|
|
import { useStartPipelineMutation } from '@/data/replication/start-pipeline-mutation'
|
|
import { useStopPipelineMutation } from '@/data/replication/stop-pipeline-mutation'
|
|
import {
|
|
PipelineStatusRequestStatus,
|
|
usePipelineRequestStatus,
|
|
} from '@/state/replication-pipeline-request-status'
|
|
import type { ResponseError } from '@/types'
|
|
|
|
interface RowMenuProps {
|
|
destinationId: number
|
|
pipeline: Pipeline | undefined
|
|
pipelineStatus?: ReplicationPipelineStatusData['status']
|
|
error: ResponseError | null
|
|
isLoading: boolean
|
|
isError: boolean
|
|
hasUpdate?: boolean
|
|
onDeleteClick: () => void
|
|
onUpdateClick?: () => void
|
|
}
|
|
|
|
export const RowMenu = ({
|
|
destinationId,
|
|
pipeline,
|
|
pipelineStatus,
|
|
error,
|
|
isLoading,
|
|
isError,
|
|
hasUpdate = false,
|
|
onDeleteClick,
|
|
onUpdateClick,
|
|
}: RowMenuProps) => {
|
|
const { ref: projectRef } = useParams()
|
|
const statusName = getStatusName(pipelineStatus)
|
|
|
|
const [, setEdit] = useQueryState(
|
|
'edit',
|
|
parseAsInteger.withOptions({ history: 'push', clearOnDefault: true })
|
|
)
|
|
|
|
const { mutateAsync: startPipeline } = useStartPipelineMutation()
|
|
const { mutateAsync: stopPipeline } = useStopPipelineMutation()
|
|
const { mutateAsync: restartPipeline } = useRestartPipelineMutation()
|
|
const { getRequestStatus, setRequestStatus: setGlobalRequestStatus } = usePipelineRequestStatus()
|
|
const requestStatus = pipeline?.id
|
|
? getRequestStatus(pipeline.id)
|
|
: PipelineStatusRequestStatus.None
|
|
|
|
// Show actions when not in a transitional state
|
|
const canPerformActions =
|
|
requestStatus === PipelineStatusRequestStatus.None &&
|
|
statusName !== PipelineStatusName.STARTING &&
|
|
[PipelineStatusName.STOPPED, PipelineStatusName.STARTED, PipelineStatusName.FAILED].includes(
|
|
statusName as PipelineStatusName
|
|
)
|
|
|
|
// Show both stop and restart for started/failed states
|
|
const showStopAndRestart =
|
|
canPerformActions &&
|
|
(statusName === PipelineStatusName.STARTED || statusName === PipelineStatusName.FAILED)
|
|
|
|
// Show only start for stopped state
|
|
const showStart = canPerformActions && statusName === PipelineStatusName.STOPPED
|
|
|
|
const onEnablePipeline = async () => {
|
|
if (!projectRef) return console.error('Project ref is required')
|
|
if (!pipeline) return toast.error('No pipeline found')
|
|
|
|
try {
|
|
// Only show 'enabling' when transitioning from allowed states
|
|
if (PIPELINE_ENABLE_ALLOWED_FROM.includes(statusName as PipelineStatusName)) {
|
|
setGlobalRequestStatus(pipeline.id, PipelineStatusRequestStatus.StartRequested, statusName)
|
|
}
|
|
await startPipeline({ projectRef, pipelineId: pipeline.id })
|
|
} catch (error) {
|
|
setGlobalRequestStatus(pipeline.id, PipelineStatusRequestStatus.None)
|
|
toast.error(`Failed to start pipeline: ${(error as ResponseError).message}`)
|
|
}
|
|
}
|
|
|
|
const onDisablePipeline = async () => {
|
|
if (!projectRef) return console.error('Project ref is required')
|
|
if (!pipeline) return toast.error('No pipeline found')
|
|
|
|
try {
|
|
// Only show 'disabling' when transitioning from allowed states
|
|
if (PIPELINE_DISABLE_ALLOWED_FROM.includes(statusName as PipelineStatusName)) {
|
|
setGlobalRequestStatus(pipeline.id, PipelineStatusRequestStatus.StopRequested, statusName)
|
|
}
|
|
await stopPipeline({ projectRef, pipelineId: pipeline.id })
|
|
} catch (error) {
|
|
setGlobalRequestStatus(pipeline.id, PipelineStatusRequestStatus.None)
|
|
toast.error(`Failed to stop pipeline: ${(error as ResponseError).message}`)
|
|
}
|
|
}
|
|
|
|
const onRestartPipeline = async () => {
|
|
if (!projectRef) return console.error('Project ref is required')
|
|
if (!pipeline) return toast.error('No pipeline found')
|
|
|
|
try {
|
|
setGlobalRequestStatus(pipeline.id, PipelineStatusRequestStatus.RestartRequested, statusName)
|
|
await restartPipeline({ projectRef, pipelineId: pipeline.id })
|
|
} catch (error) {
|
|
setGlobalRequestStatus(pipeline.id, PipelineStatusRequestStatus.None)
|
|
toast.error(`Failed to restart pipeline: ${(error as ResponseError).message}`)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="flex justify-end items-center space-x-2">
|
|
{isLoading && <ShimmeringLoader />}
|
|
|
|
{isError && (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<span className="flex items-center" tabIndex={0}>
|
|
<WarningIcon />
|
|
</span>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="bottom" className="max-w-xs">
|
|
Couldn't load status{error?.message ? `: ${error.message}` : '.'}
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
)}
|
|
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<div className="relative">
|
|
<Button
|
|
variant="default"
|
|
className="px-1.25 hit-area-2"
|
|
aria-label={hasUpdate ? 'Pipeline options, update available' : 'Pipeline options'}
|
|
icon={<MoreVertical />}
|
|
/>
|
|
{hasUpdate && (
|
|
<span
|
|
className="absolute -top-0.5 -right-0.5 h-2 w-2 bg-brand rounded-full"
|
|
aria-hidden
|
|
/>
|
|
)}
|
|
</div>
|
|
</DropdownMenuTrigger>
|
|
|
|
<DropdownMenuContent side="bottom" align="end" className="w-44">
|
|
<DropdownMenuItem className="space-x-2" asChild disabled={!pipeline}>
|
|
<Link href={`/project/${projectRef}/database/replication/${pipeline?.id}`}>
|
|
<Eye size={14} />
|
|
<p>View details</p>
|
|
</Link>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
{hasUpdate && (
|
|
<>
|
|
<DropdownMenuItem className="space-x-2" onClick={() => onUpdateClick?.()}>
|
|
<ArrowUpCircle size={14} />
|
|
<p>Update available</p>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
</>
|
|
)}
|
|
{showStart && (
|
|
<>
|
|
<DropdownMenuItem className="space-x-2" onClick={onEnablePipeline}>
|
|
<Play size={14} />
|
|
<p>Start pipeline</p>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
</>
|
|
)}
|
|
{showStopAndRestart && (
|
|
<>
|
|
<DropdownMenuItem className="space-x-2" onClick={onRestartPipeline}>
|
|
<RotateCcw size={14} />
|
|
<p>Restart pipeline</p>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem className="space-x-2" onClick={onDisablePipeline}>
|
|
<CircleStop size={14} />
|
|
<p>Stop pipeline</p>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
</>
|
|
)}
|
|
|
|
<DropdownMenuItem className="space-x-2" onClick={() => setEdit(destinationId)}>
|
|
<Edit size={14} />
|
|
<p>Edit pipeline</p>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem className="space-x-2" onClick={onDeleteClick}>
|
|
<Trash size={14} />
|
|
<p>Delete pipeline</p>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</div>
|
|
)
|
|
}
|