mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 18:35:07 +03:00
## What kind of change does this PR introduce? Bug fix and internal tooling update. Resolves FE-3472. ## What is the current behavior? Custom Studio icons use inconsistent source stroke widths, and some child-level styling prevents component props from overriding them. Mixed custom and Lucide icon sets can therefore appear uneven. ## What is the new behavior? Custom stroke icons use a root-level `stroke-width="1.5"`; fill-only logos use `stroke="none"`. The build validates that contract and regenerated components preserve existing exports and props. Studio applies the same `1.5` weight across Reports categories and uses one shared destination icon mapping in the replication selector, destination rows and diagram. | Before | After | | --- | --- | | <img width="418" height="516" alt="56398" src="https://github.com/user-attachments/assets/6afa7042-e6be-40e7-9911-af2f61238c9d" /> | <img width="390" height="550" alt="CleanShot 2026-07-30 at 17 12 37@2x" src="https://github.com/user-attachments/assets/870f49cf-c8fa-40db-8be8-2eb5f264ff4a" /> | | <img width="510" height="734" alt="CleanShot 2026-07-30 at 17 19 28@2x" src="https://github.com/user-attachments/assets/a5b2c088-dcd2-4907-976b-5820794d06e3" /> | <img width="554" height="742" alt="CleanShot 2026-07-30 at 17 16 06@2x" src="https://github.com/user-attachments/assets/ed3a77c4-5d94-4ca7-b9e4-1403b725a981" /> | ## Testing At 100% zoom, compare custom and Lucide icon weight in: - Reports: **Add your first chart** and **Add block** - Database > Replication: the destination selector, destination rows and replication diagram - Command menu (`⌘K`): **Search Database Tables**, **Search RLS Policies**, **Search Edge Functions** and **Search Storage** - Authentication > Users: right-click a user row and compare the context-menu icons - Database > Schema Visualizer: open a table node overflow menu - A paused project: **Export your data > Download backups** <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added consistent destination icons across replication panels, rows, and diagrams. * Updated instance health and metric icons for clearer identification. * Standardized icon stroke weight and reduced default icon stroke thickness. * **Documentation** * Clarified custom icon requirements, default properties, and validation guidance. * **Bug Fixes** * Improved consistency of icon rendering across replication destinations and reports. * **Tests** * Added coverage for icon SVG validation and replication destination icon rendering. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
269 lines
9.7 KiB
TypeScript
269 lines
9.7 KiB
TypeScript
import { useParams } from 'common'
|
|
import { Minus } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { useEffect, useState } from 'react'
|
|
import { toast } from 'sonner'
|
|
import {
|
|
Button,
|
|
TableCell,
|
|
TableRow,
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipTrigger,
|
|
WarningIcon,
|
|
} from 'ui'
|
|
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
import { DeleteDestination } from './DeleteDestination'
|
|
import { DestinationIcon } from './DestinationIcon'
|
|
import { PipelineStatus } from './PipelineStatus'
|
|
import { PipelineStatusName, STATUS_REFRESH_FREQUENCY_MS } from './Replication.constants'
|
|
import { getFormattedLagValue } from './ReplicationPipelineStatus/ReplicationPipelineStatus.utils'
|
|
import { RowMenu } from './RowMenu'
|
|
import { UpdateVersionModal } from './UpdateVersionModal'
|
|
import { useDestinationInformation } from './useDestinationInformation'
|
|
import { AlertError } from '@/components/ui/AlertError'
|
|
import { useDeleteDestinationPipelineMutation } from '@/data/replication/delete-destination-pipeline-mutation'
|
|
import { useReplicationPipelineReplicationStatusQuery } from '@/data/replication/pipeline-replication-status-query'
|
|
import { useReplicationPipelineStatusQuery } from '@/data/replication/pipeline-status-query'
|
|
import { useReplicationPipelineVersionQuery } from '@/data/replication/pipeline-version-query'
|
|
import { useStopPipelineMutation } from '@/data/replication/stop-pipeline-mutation'
|
|
import {
|
|
PipelineStatusRequestStatus,
|
|
usePipelineRequestStatus,
|
|
} from '@/state/replication-pipeline-request-status'
|
|
import { type ResponseError } from '@/types'
|
|
|
|
interface DestinationRowProps {
|
|
destinationId: number
|
|
}
|
|
|
|
export const DestinationRow = ({ destinationId }: DestinationRowProps) => {
|
|
const { ref: projectRef } = useParams()
|
|
const [showDeleteDestinationForm, setShowDeleteDestinationForm] = useState(false)
|
|
const [isDeleting, setIsDeleting] = useState(false)
|
|
const [showUpdateVersionModal, setShowUpdateVersionModal] = useState(false)
|
|
|
|
const { type, statusName, destination, pipeline, pipelineStatus, pipelineFetcher } =
|
|
useDestinationInformation({
|
|
id: destinationId,
|
|
})
|
|
const {
|
|
error: pipelineError,
|
|
isPending: isPipelineLoading,
|
|
isError: isPipelineError,
|
|
isSuccess: isPipelineSuccess,
|
|
} = pipelineFetcher
|
|
const destinationName = destination?.name ?? ''
|
|
|
|
const {
|
|
error: pipelineStatusError,
|
|
isPending: isPipelineStatusLoading,
|
|
isError: isPipelineStatusError,
|
|
isSuccess: isPipelineStatusSuccess,
|
|
} = useReplicationPipelineStatusQuery(
|
|
{
|
|
projectRef,
|
|
pipelineId: pipeline?.id,
|
|
},
|
|
{ refetchInterval: STATUS_REFRESH_FREQUENCY_MS }
|
|
)
|
|
const { getRequestStatus, updatePipelineStatus } = usePipelineRequestStatus()
|
|
const requestStatus = pipeline?.id
|
|
? getRequestStatus(pipeline.id)
|
|
: PipelineStatusRequestStatus.None
|
|
|
|
const { mutateAsync: stopPipeline } = useStopPipelineMutation()
|
|
const { mutateAsync: deleteDestinationPipeline } = useDeleteDestinationPipelineMutation({})
|
|
|
|
// Fetch table-level replication status to surface errors in list view
|
|
const {
|
|
data: replicationStatusData,
|
|
isPending: isReplicationStatusLoading,
|
|
isError: isReplicationStatusError,
|
|
} = useReplicationPipelineReplicationStatusQuery(
|
|
{ projectRef, pipelineId: pipeline?.id },
|
|
{ refetchInterval: STATUS_REFRESH_FREQUENCY_MS }
|
|
)
|
|
const tableStatuses = replicationStatusData?.table_statuses ?? []
|
|
const errorCount = tableStatuses.filter((t) => t.state?.name === 'error').length
|
|
const applyLag = replicationStatusData?.apply_lag
|
|
// Show the byte-based slot lag (WAL the destination hasn't confirmed flushing yet). The
|
|
// time-based flush_lag from pg_stat_replication is routinely NULL for logical slots that are
|
|
// idle or don't report timed feedback, whereas confirmed_flush_lsn_bytes is always populated.
|
|
const lagBytes = applyLag?.confirmed_flush_lsn_bytes
|
|
const lag = getFormattedLagValue('bytes', lagBytes)
|
|
const isCaughtUp = lagBytes === 0
|
|
// Only show errors when pipeline is running (not when stopped or restarting)
|
|
const isPipelineStopped = statusName === PipelineStatusName.STOPPED
|
|
const isRestarting = requestStatus === PipelineStatusRequestStatus.RestartRequested
|
|
const hasTableErrors = errorCount > 0 && !isPipelineStopped && !isRestarting
|
|
|
|
// Check if a newer pipeline version is available (one-time check cached for session)
|
|
const { data: versionData } = useReplicationPipelineVersionQuery({
|
|
projectRef,
|
|
pipelineId: pipeline?.id,
|
|
})
|
|
const hasUpdate = Boolean(versionData?.new_version)
|
|
|
|
const onDeleteClick = async () => {
|
|
if (!projectRef) {
|
|
return console.error('Project ref is required')
|
|
}
|
|
if (!pipeline) {
|
|
return toast.error('No pipeline found')
|
|
}
|
|
|
|
try {
|
|
setIsDeleting(true)
|
|
await stopPipeline({ projectRef, pipelineId: pipeline.id })
|
|
await deleteDestinationPipeline({
|
|
projectRef,
|
|
destinationId: destinationId,
|
|
pipelineId: pipeline.id,
|
|
})
|
|
// Close dialog after successful deletion
|
|
setShowDeleteDestinationForm(false)
|
|
toast.success(`Deleted destination "${destinationName}"`)
|
|
} catch (error) {
|
|
toast.error(`Failed to delete destination: ${(error as ResponseError).message}`)
|
|
} finally {
|
|
setIsDeleting(false)
|
|
}
|
|
}
|
|
|
|
useEffect(() => {
|
|
if (pipeline?.id) {
|
|
updatePipelineStatus(pipeline.id, statusName)
|
|
}
|
|
}, [pipeline?.id, statusName, updatePipelineStatus])
|
|
|
|
return (
|
|
<>
|
|
{isPipelineError && (
|
|
<TableRow>
|
|
<TableCell colSpan={6}>
|
|
<AlertError error={pipelineError} subject="Failed to retrieve pipeline information" />
|
|
</TableCell>
|
|
</TableRow>
|
|
)}
|
|
{isPipelineSuccess && (
|
|
<TableRow>
|
|
<TableCell>
|
|
<DestinationIcon
|
|
type={type ?? 'Read Replica'}
|
|
size={18}
|
|
className="text-foreground-light"
|
|
/>
|
|
</TableCell>
|
|
|
|
<TableCell className="max-w-[180px]">
|
|
{isPipelineLoading ? (
|
|
<ShimmeringLoader />
|
|
) : (
|
|
<div className="flex flex-col gap-y-0.5">
|
|
<p className="text-sm font-medium text-foreground truncate">
|
|
{destinationName || type}
|
|
</p>
|
|
<div className="flex items-center gap-x-1.5 text-xs text-foreground-lighter">
|
|
<span className="font-mono">#{pipeline?.id}</span>
|
|
<span aria-hidden>·</span>
|
|
<span>{type}</span>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</TableCell>
|
|
|
|
<TableCell>
|
|
{isPipelineLoading || !pipeline ? (
|
|
<ShimmeringLoader />
|
|
) : (
|
|
<PipelineStatus
|
|
pipelineStatus={pipelineStatus?.status}
|
|
error={pipelineStatusError}
|
|
isLoading={isPipelineStatusLoading}
|
|
isError={isPipelineStatusError}
|
|
isSuccess={isPipelineStatusSuccess}
|
|
requestStatus={requestStatus}
|
|
pipelineId={pipeline?.id}
|
|
/>
|
|
)}
|
|
</TableCell>
|
|
|
|
<TableCell>
|
|
{!pipeline ? (
|
|
<Minus size={18} className="text-foreground-lighter" />
|
|
) : isReplicationStatusLoading ? (
|
|
<ShimmeringLoader />
|
|
) : isReplicationStatusError || !applyLag ? (
|
|
<Minus size={18} className="text-foreground-lighter" />
|
|
) : isCaughtUp ? (
|
|
<span className="text-foreground-light whitespace-nowrap">Caught up</span>
|
|
) : (
|
|
<span className="text-foreground whitespace-nowrap">{lag.display}</span>
|
|
)}
|
|
</TableCell>
|
|
|
|
<TableCell>
|
|
{isPipelineLoading || !pipeline ? (
|
|
<ShimmeringLoader />
|
|
) : (
|
|
pipeline.config.publication_name
|
|
)}
|
|
</TableCell>
|
|
|
|
<TableCell>
|
|
<div className="flex items-center justify-end gap-x-2">
|
|
{hasTableErrors && (
|
|
<Tooltip>
|
|
<TooltipTrigger>
|
|
<WarningIcon />
|
|
</TooltipTrigger>
|
|
<TooltipContent side="bottom">
|
|
{errorCount} table{errorCount === 1 ? '' : 's'} encountered replication errors.
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
)}
|
|
<Button asChild variant="default" className="relative">
|
|
<Link href={`/project/${projectRef}/database/replication/${pipeline?.id}`}>
|
|
View pipeline
|
|
</Link>
|
|
</Button>
|
|
<RowMenu
|
|
destinationId={destinationId}
|
|
pipeline={pipeline}
|
|
pipelineStatus={pipelineStatus?.status}
|
|
error={pipelineStatusError}
|
|
isLoading={isPipelineStatusLoading}
|
|
isError={isPipelineStatusError}
|
|
onDeleteClick={() => setShowDeleteDestinationForm(true)}
|
|
hasUpdate={hasUpdate}
|
|
onUpdateClick={() => setShowUpdateVersionModal(true)}
|
|
/>
|
|
</div>
|
|
</TableCell>
|
|
</TableRow>
|
|
)}
|
|
|
|
<DeleteDestination
|
|
visible={showDeleteDestinationForm}
|
|
setVisible={setShowDeleteDestinationForm}
|
|
onDelete={onDeleteClick}
|
|
isLoading={isDeleting}
|
|
name={destinationName}
|
|
/>
|
|
|
|
<UpdateVersionModal
|
|
visible={showUpdateVersionModal}
|
|
pipeline={pipeline}
|
|
onClose={() => setShowUpdateVersionModal(false)}
|
|
confirmLabel={
|
|
statusName === PipelineStatusName.STARTED || statusName === PipelineStatusName.FAILED
|
|
? 'Update and restart'
|
|
: 'Update version'
|
|
}
|
|
/>
|
|
</>
|
|
)
|
|
}
|