mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 18:35:07 +03:00
## Problem Pipelines loading causes layout shifts, and the update cue is hard to connect to its menu action. - Resolves [PIPE-1078](https://linear.app/supabase/issue/PIPE-1078/show-destination-rows-while-details-are-loading) - Resolves [DEPR-688](https://linear.app/supabase/issue/DEPR-688/widen-the-update-available-modal) - Resolves [DEPR-691](https://linear.app/supabase/issue/DEPR-691/clarify-the-update-available-indicator-in-pipeline-actions) ## Solution Reserve space for the graph and list while loading, show destination rows before their details arrive, align the detail header, and stack version values in the update dialog. Match the primary-colour dot on the options button and its Update available menu item. Give the status tooltip more room. | Before | After | | --- | --- | | <img width="408" height="346" alt="8294" src="https://github.com/user-attachments/assets/9a44dfe0-5473-4809-b705-fd6077efe44b" /> | <img width="844" height="738" alt="CleanShot 2026-09-28 at 17 10 34@2x" src="https://github.com/user-attachments/assets/4eba3f16-6dc4-4c02-83b4-9689203859bd" /> | | After | | --- | | <img width="426" height="472" alt="CleanShot 2026-09-28 at 17 11 27@2x" src="https://github.com/user-attachments/assets/8b3c181c-b48e-4803-a24a-fb7dce3957d4" /> | | _Links ambiguous dot to dropdown menu item_ | | <img width="1942" height="262" alt="CleanShot 2026-09-28 at 17 29 18@2x" src="https://github.com/user-attachments/assets/efc047bb-a8ea-4041-bd0d-fa2cb15f4414" /> | | _Better alignment with nav bar above it_ | ## Review instructions 1. Reload Database > Pipelines and check the loading layout and destination rows. 2. Open a pipeline detail page and check its header, update dialog, and matching update dots. ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Destination rows now appear while pipeline details are loading, with controls becoming available when the details finish loading. * **Style** * Loading states on the replication page now use diagram and table-shaped placeholders. * Updated replication page spacing, version-status tooltips, update indicators, and the version comparison layout. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
410 lines
16 KiB
TypeScript
410 lines
16 KiB
TypeScript
import { useParams } from 'common'
|
|
import {
|
|
ArrowRight,
|
|
ArrowUpCircle,
|
|
CircleStop,
|
|
Edit,
|
|
MoreVertical,
|
|
Play,
|
|
RotateCcw,
|
|
Trash,
|
|
} from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { useRouter } from 'next/router'
|
|
import { parseAsInteger, useQueryState } from 'nuqs'
|
|
import { PropsWithChildren, useState, type ReactNode } from 'react'
|
|
import { toast } from 'sonner'
|
|
import {
|
|
BreadcrumbItem,
|
|
BreadcrumbLink,
|
|
BreadcrumbList,
|
|
BreadcrumbPage,
|
|
BreadcrumbSeparator,
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
} from 'ui'
|
|
import { PageBreadcrumbs, PageBreadcrumbsActions } from 'ui-patterns/PageBreadcrumbs'
|
|
import {
|
|
PageHeader,
|
|
PageHeaderAside,
|
|
PageHeaderDescription,
|
|
PageHeaderIcon,
|
|
PageHeaderMeta,
|
|
PageHeaderSummary,
|
|
PageHeaderTitle,
|
|
} from 'ui-patterns/PageHeader'
|
|
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
import { DeleteDestination } from './DeleteDestination'
|
|
import { DestinationLogo } from './DestinationLogo'
|
|
import { DestinationPanel } from './DestinationPanel/DestinationPanel'
|
|
import { getPipelineDisplayState, getRestartRequestStatus, getStatusName } from './Pipeline.utils'
|
|
import { PipelineStatePill } from './PipelineStatePill'
|
|
import { PipelineStatusName } from './Replication.constants'
|
|
import { getReplicationDestinationType } from './ReplicationDiagram/Nodes.utils'
|
|
import { UpdateVersionModal } from './UpdateVersionModal'
|
|
import { DocsButton } from '@/components/ui/DocsButton'
|
|
import { useDeleteDestinationPipelineMutation } from '@/data/replication/delete-destination-pipeline-mutation'
|
|
import { useReplicationDestinationByIdQuery } from '@/data/replication/destination-by-id-query'
|
|
import { useReplicationPipelineByIdQuery } from '@/data/replication/pipeline-by-id-query'
|
|
import { useReplicationPipelineStatusQuery } from '@/data/replication/pipeline-status-query'
|
|
import { useReplicationPipelineVersionQuery } from '@/data/replication/pipeline-version-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 { DOCS_URL } from '@/lib/constants'
|
|
import {
|
|
PipelineStatusRequestStatus,
|
|
usePipelineRequestStatus,
|
|
} from '@/state/replication-pipeline-request-status'
|
|
import { type ResponseError } from '@/types'
|
|
|
|
type LifecycleAction = 'start' | 'stop' | 'restart'
|
|
|
|
const LIFECYCLE_BY_STATUS: Partial<
|
|
Record<PipelineStatusName, { label: string; action: LifecycleAction; icon: ReactNode }>
|
|
> = {
|
|
[PipelineStatusName.STOPPED]: { label: 'Start', action: 'start', icon: <Play /> },
|
|
[PipelineStatusName.STARTED]: { label: 'Stop', action: 'stop', icon: <CircleStop /> },
|
|
[PipelineStatusName.FAILED]: { label: 'Restart', action: 'restart', icon: <RotateCcw /> },
|
|
}
|
|
|
|
export const ReplicationPipelineLayout = ({ children }: PropsWithChildren) => {
|
|
const { ref: projectRef, pipelineId: pipelineIdParam } = useParams()
|
|
const pipelineId = Number(pipelineIdParam)
|
|
const router = useRouter()
|
|
const [showUpdateVersionModal, setShowUpdateVersionModal] = useState(false)
|
|
const [showDeleteDestination, setShowDeleteDestination] = useState(false)
|
|
const [isDeleting, setIsDeleting] = useState(false)
|
|
const [, setEdit] = useQueryState(
|
|
'edit',
|
|
parseAsInteger.withOptions({ history: 'push', clearOnDefault: true })
|
|
)
|
|
const { getRequestStatus, isRequestPending, runWithRequestStatus } = usePipelineRequestStatus()
|
|
const requestStatus = getRequestStatus(pipelineId)
|
|
const isPipelineRequestPending = isRequestPending(pipelineId)
|
|
|
|
const {
|
|
data: pipeline,
|
|
error: pipelineError,
|
|
isPending: isPipelineLoading,
|
|
} = useReplicationPipelineByIdQuery(
|
|
{ projectRef, pipelineId },
|
|
{ enabled: Number.isSafeInteger(pipelineId) }
|
|
)
|
|
const {
|
|
data: pipelineStatusData,
|
|
error: pipelineStatusError,
|
|
isLoading: isPipelineStatusLoading,
|
|
isError: isPipelineStatusError,
|
|
isSuccess: isPipelineStatusSuccess,
|
|
} = useReplicationPipelineStatusQuery({ projectRef, pipelineId }, { enabled: !!pipelineId })
|
|
const { data: versionData } = useReplicationPipelineVersionQuery({
|
|
projectRef,
|
|
pipelineId: pipeline?.id,
|
|
})
|
|
const { data: destination, isPending: isDestinationLoading } = useReplicationDestinationByIdQuery(
|
|
{
|
|
projectRef,
|
|
destinationId: pipeline?.destination_id,
|
|
}
|
|
)
|
|
|
|
const { mutateAsync: startPipeline, isPending: isStartingPipeline } = useStartPipelineMutation({
|
|
onError: () => {},
|
|
})
|
|
const { mutateAsync: stopPipeline, isPending: isStoppingPipeline } = useStopPipelineMutation({
|
|
onError: () => {},
|
|
})
|
|
const { mutateAsync: restartPipeline, isPending: isRestartingPipeline } =
|
|
useRestartPipelineMutation()
|
|
const { mutateAsync: deleteDestinationPipeline } = useDeleteDestinationPipelineMutation({
|
|
onError: () => {},
|
|
})
|
|
|
|
const statusName = getStatusName(pipelineStatusData?.status)
|
|
const displayState = getPipelineDisplayState(requestStatus, statusName)
|
|
const destinationType = getReplicationDestinationType(
|
|
destination?.config as Record<string, unknown> | undefined
|
|
)
|
|
const isPipelineIdentityLoading =
|
|
isPipelineLoading || (pipeline !== undefined && isDestinationLoading)
|
|
const hasUpdate = Boolean(versionData?.new_version)
|
|
const isTransitioning = requestStatus !== PipelineStatusRequestStatus.None
|
|
|
|
// What the primary button offers for each state it can act on. Anything not listed here (a
|
|
// pipeline mid-transition, or one in an unknown state) has no action, so the button falls back
|
|
// to the display state's own label and renders no icon.
|
|
const lifecycle = LIFECYCLE_BY_STATUS[statusName as PipelineStatusName]
|
|
const isActionable = lifecycle !== undefined
|
|
const primaryAction: LifecycleAction | undefined = lifecycle?.action
|
|
const lifecycleLabel = isTransitioning
|
|
? displayState.label
|
|
: (lifecycle?.label ?? displayState.label)
|
|
// No icon while Starting/Stopping/Restarting: those states have no entry above, and the
|
|
// button's loading state carries the transition anyway.
|
|
const lifecycleIcon = lifecycle?.icon
|
|
|
|
// The overflow menu carries the lifecycle actions the primary button isn't already offering,
|
|
// so the detail page has the same reach as the row menu on the list without repeating itself.
|
|
const isRunningOrFailed =
|
|
statusName === PipelineStatusName.STARTED || statusName === PipelineStatusName.FAILED
|
|
const canUseMenuActions =
|
|
isRunningOrFailed && !isTransitioning && !isPipelineStatusError && !!pipeline
|
|
const canRestart = canUseMenuActions && !isPipelineRequestPending && primaryAction !== 'restart'
|
|
const canStop = canUseMenuActions && !isPipelineRequestPending && primaryAction !== 'stop'
|
|
|
|
const onLifecycleAction = async (action?: LifecycleAction) => {
|
|
const resolvedAction = action ?? primaryAction
|
|
if (!projectRef || !pipeline || resolvedAction === undefined) return
|
|
|
|
try {
|
|
if (resolvedAction === 'start') {
|
|
await runWithRequestStatus(pipeline.id, PipelineStatusRequestStatus.StartRequested, () =>
|
|
startPipeline({ projectRef, pipelineId: pipeline.id })
|
|
)
|
|
} else if (resolvedAction === 'stop') {
|
|
await runWithRequestStatus(pipeline.id, PipelineStatusRequestStatus.StopRequested, () =>
|
|
stopPipeline({ projectRef, pipelineId: pipeline.id })
|
|
)
|
|
} else {
|
|
await runWithRequestStatus(pipeline.id, getRestartRequestStatus(statusName), () =>
|
|
restartPipeline({ projectRef, pipelineId: pipeline.id })
|
|
)
|
|
}
|
|
} catch (error) {
|
|
toast.error(`Failed to ${resolvedAction} pipeline: ${(error as ResponseError).message}`)
|
|
}
|
|
}
|
|
|
|
const onDeleteDestination = async () => {
|
|
if (!projectRef || !pipeline) return
|
|
|
|
try {
|
|
setIsDeleting(true)
|
|
if (statusName !== PipelineStatusName.STOPPED) {
|
|
await stopPipeline({ projectRef, pipelineId: pipeline.id })
|
|
}
|
|
await deleteDestinationPipeline({
|
|
projectRef,
|
|
destinationId: pipeline.destination_id,
|
|
pipelineId: pipeline.id,
|
|
})
|
|
setShowDeleteDestination(false)
|
|
toast.success(`Deleted pipeline "${pipeline.destination_name}"`)
|
|
router.push(`/project/${projectRef}/database/pipelines`)
|
|
} catch (error) {
|
|
toast.error(`Failed to delete pipeline: ${(error as ResponseError).message}`)
|
|
} finally {
|
|
setIsDeleting(false)
|
|
}
|
|
}
|
|
|
|
const logsUrl = `/project/${projectRef}/logs/replication-logs?f=${encodeURIComponent(
|
|
JSON.stringify({ pipeline_id: pipelineId })
|
|
)}`
|
|
|
|
return (
|
|
<div className="flex min-h-full w-full flex-col items-stretch">
|
|
<div className="bg-surface-75">
|
|
<PageBreadcrumbs
|
|
slotClassName="sticky top-0 z-20 bg-sidebar"
|
|
actions={
|
|
<PageBreadcrumbsActions>
|
|
<DocsButton href={`${DOCS_URL}/guides/database/replication/pipelines`} />
|
|
<Button asChild variant="default">
|
|
<Link href={logsUrl}>View logs</Link>
|
|
</Button>
|
|
</PageBreadcrumbsActions>
|
|
}
|
|
>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild>
|
|
<Link href={`/project/${projectRef}/database/pipelines`}>Pipelines</Link>
|
|
</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
<BreadcrumbItem>
|
|
<BreadcrumbPage>
|
|
{isPipelineLoading ? (
|
|
<span className="inline-flex items-center">
|
|
<span className="sr-only">Loading pipeline</span>
|
|
<ShimmeringLoader className="h-3 w-24 py-0" />
|
|
</span>
|
|
) : (
|
|
(pipeline?.destination_name ?? 'Pipeline')
|
|
)}
|
|
</BreadcrumbPage>
|
|
</BreadcrumbItem>
|
|
</BreadcrumbList>
|
|
</PageBreadcrumbs>
|
|
|
|
<PageHeader size="full" className="border-b py-4 [&>div]:px-4 [&>div]:xl:px-4">
|
|
<PageHeaderMeta>
|
|
<PageHeaderIcon>
|
|
{isPipelineIdentityLoading ? (
|
|
<ShimmeringLoader className="h-14 w-14 rounded-lg py-0" />
|
|
) : destinationType !== undefined ? (
|
|
<DestinationLogo type={destinationType} size="large" />
|
|
) : (
|
|
<span className="block h-14 w-14 rounded-lg border bg-surface-100" />
|
|
)}
|
|
</PageHeaderIcon>
|
|
<PageHeaderSummary>
|
|
<PageHeaderTitle>
|
|
{isPipelineLoading ? (
|
|
<span className="inline-flex items-center">
|
|
<span className="sr-only">Loading pipeline</span>
|
|
<ShimmeringLoader className="h-6 w-40 py-0" />
|
|
</span>
|
|
) : (
|
|
(pipeline?.destination_name ?? 'Pipeline')
|
|
)}
|
|
</PageHeaderTitle>
|
|
<PageHeaderDescription className="flex flex-row flex-wrap items-center gap-x-1.5 gap-y-1 text-sm!">
|
|
<PipelineStatePill
|
|
pipelineStatus={pipelineStatusData?.status}
|
|
error={pipelineStatusError}
|
|
isLoading={isPipelineLoading || isPipelineStatusLoading}
|
|
isError={isPipelineStatusError}
|
|
isSuccess={isPipelineStatusSuccess}
|
|
requestStatus={requestStatus}
|
|
projectRef={projectRef}
|
|
pipelineId={pipelineId}
|
|
/>
|
|
<span aria-hidden className="text-foreground-lighter">
|
|
·
|
|
</span>
|
|
<span className="flex items-center gap-x-1.5 text-foreground-light">
|
|
<span>Primary database</span>
|
|
<ArrowRight size={14} strokeWidth={1.5} className="text-foreground-lighter" />
|
|
{isPipelineIdentityLoading ? (
|
|
<span className="inline-flex items-center">
|
|
<span className="sr-only">Loading destination</span>
|
|
<ShimmeringLoader className="h-3 w-20 py-0" />
|
|
</span>
|
|
) : (
|
|
<span>{destinationType ?? pipeline?.destination_name ?? 'Unknown'}</span>
|
|
)}
|
|
</span>
|
|
</PageHeaderDescription>
|
|
</PageHeaderSummary>
|
|
|
|
<PageHeaderAside>
|
|
<div className="flex flex-wrap items-center justify-end gap-2">
|
|
{hasUpdate && (
|
|
<Button
|
|
variant="primary"
|
|
icon={<ArrowUpCircle />}
|
|
onClick={() => setShowUpdateVersionModal(true)}
|
|
disabled={isPipelineRequestPending || isTransitioning}
|
|
>
|
|
Update available
|
|
</Button>
|
|
)}
|
|
<Button
|
|
variant={
|
|
!hasUpdate && statusName === PipelineStatusName.STOPPED ? 'primary' : 'default'
|
|
}
|
|
icon={lifecycleIcon}
|
|
onClick={() => onLifecycleAction()}
|
|
loading={
|
|
displayState.type === 'loading' ||
|
|
isTransitioning ||
|
|
isStartingPipeline ||
|
|
isStoppingPipeline ||
|
|
isRestartingPipeline
|
|
}
|
|
disabled={
|
|
Boolean(pipelineError) ||
|
|
isPipelineStatusError ||
|
|
!pipeline ||
|
|
isTransitioning ||
|
|
isPipelineRequestPending ||
|
|
!isActionable
|
|
}
|
|
>
|
|
{lifecycleLabel}
|
|
</Button>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
variant="default"
|
|
className="w-6.5 hit-area-1"
|
|
aria-label="Pipeline options"
|
|
icon={<MoreVertical />}
|
|
disabled={isPipelineRequestPending || isTransitioning}
|
|
/>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent side="bottom" align="end" className="w-52">
|
|
{canRestart && (
|
|
<DropdownMenuItem
|
|
className="gap-x-2"
|
|
onClick={() => onLifecycleAction('restart')}
|
|
>
|
|
<RotateCcw size={14} />
|
|
<span>Restart pipeline</span>
|
|
</DropdownMenuItem>
|
|
)}
|
|
{canStop && (
|
|
<DropdownMenuItem
|
|
className="gap-x-2"
|
|
onClick={() => onLifecycleAction('stop')}
|
|
>
|
|
<CircleStop size={14} />
|
|
<span>Stop pipeline</span>
|
|
</DropdownMenuItem>
|
|
)}
|
|
{(canRestart || canStop) && <DropdownMenuSeparator />}
|
|
<DropdownMenuItem
|
|
className="gap-x-2"
|
|
disabled={pipeline === undefined}
|
|
onClick={() => {
|
|
if (pipeline !== undefined) setEdit(pipeline.destination_id)
|
|
}}
|
|
>
|
|
<Edit size={14} />
|
|
<span>Edit pipeline</span>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem
|
|
className="gap-x-2"
|
|
disabled={pipeline === undefined}
|
|
onClick={() => setShowDeleteDestination(true)}
|
|
>
|
|
<Trash size={14} />
|
|
<span>Delete pipeline</span>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</div>
|
|
</PageHeaderAside>
|
|
</PageHeaderMeta>
|
|
</PageHeader>
|
|
</div>
|
|
|
|
{children}
|
|
|
|
<DestinationPanel />
|
|
|
|
<DeleteDestination
|
|
visible={showDeleteDestination}
|
|
setVisible={setShowDeleteDestination}
|
|
onDelete={onDeleteDestination}
|
|
isLoading={isDeleting}
|
|
name={pipeline?.destination_name ?? ''}
|
|
/>
|
|
|
|
<UpdateVersionModal
|
|
visible={showUpdateVersionModal}
|
|
pipeline={pipeline}
|
|
onClose={() => setShowUpdateVersionModal(false)}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|