Files
supabase/apps/studio/components/interfaces/Database/Replication/UpdateVersionModal.tsx
T
Danny White 5951fb6c47 fix(studio): polish Pipelines loading and update cues (#50963)
## 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 -->
2026-09-29 11:42:58 +10:00

104 lines
3.7 KiB
TypeScript

import { useParams } from 'common'
import { toast } from 'sonner'
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { getRestartRequestStatus, getStatusName } from './Pipeline.utils'
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'
interface UpdateVersionModalProps {
visible: boolean
pipeline?: Pipeline
onClose: () => void
}
export const UpdateVersionModal = ({ visible, pipeline, onClose }: UpdateVersionModalProps) => {
const { ref: projectRef } = useParams()
const { runWithRequestStatus } = usePipelineRequestStatus()
const { data: pipelineStatusData } = useReplicationPipelineStatusQuery({
projectRef,
pipelineId: pipeline?.id,
})
const pipelineStatus = pipelineStatusData?.status
const statusName = getStatusName(pipelineStatus)
const requestStatus = getRestartRequestStatus(statusName)
const shouldRestart = requestStatus === PipelineStatusRequestStatus.StopRequested
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 runWithRequestStatus(pipeline.id, requestStatus, () =>
updatePipelineVersion({
projectRef,
pipelineId: pipeline.id,
versionId,
skipStatusInvalidation: true,
})
)
} catch {
// The mutation reports errors and refreshes version info if the default image changed.
return
}
toast.success('Pipeline version updated.')
onClose()
}
return (
<ConfirmationModal
size="small"
variant={shouldRestart ? 'warning' : 'default'}
visible={visible}
title="Update available"
confirmLabel={shouldRestart ? 'Update and restart' : 'Update version'}
confirmLabelLoading="Updating version..."
loading={isUpdating}
onCancel={onClose}
onConfirm={onConfirmUpdate}
>
<div className="flex flex-col gap-y-3">
<p className="text-sm text-foreground-light">
{shouldRestart
? 'A newer pipeline version is available with improvements and bug fixes. The pipeline will restart and continue from where it left off.'
: 'A newer pipeline version is available with improvements and bug fixes.'}
</p>
<dl className="divide-y overflow-hidden rounded-md border text-sm" aria-live="polite">
<div className="px-3 py-2">
<dt className="text-foreground-lighter">Current</dt>
<dd className="mt-1 break-all text-foreground" translate="no">
{isLoadingVersion ? 'Loading…' : (currentVersionName ?? 'Unknown')}
</dd>
</div>
<div className="px-3 py-2">
<dt className="text-foreground-lighter">New</dt>
<dd className="mt-1 break-all text-foreground" translate="no">
{isLoadingVersion ? 'Loading…' : (newVersionName ?? 'Unknown')}
</dd>
</div>
</dl>
</div>
</ConfirmationModal>
)
}