Files
Ivan VasilovandJordi Enric 56de26fe22 chore: Migrate the monorepo to use Tailwind v4 (#45318)
This PR migrates the whole monorepo to use Tailwind v4:
- Removed `@tailwindcss/container-queries` plugin since it's included by
default in v4,
- Bump all instances of Tailwind to v4. Made minimal changes to the
shared config to remove non-supported features (`alpha` mentions),
- Migrate all apps to be compatible with v4 configs,
- Fix the `typography.css` import in 3 apps,
- Add missing rules which were included by default in v3,
- Run `pnpm dlx @tailwindcss/upgrade` on all apps, which renames a lot
of classes
- Rename all misnamed classes according to
https://tailwindcss.com/docs/upgrade-guide#renamed-utilities in all
apps.

---------

Co-authored-by: Jordi Enric <jordi.err@gmail.com>
2026-04-30 10:53:24 +00:00

112 lines
3.4 KiB
TypeScript

import { BaseEdge, EdgeLabelRenderer, getSmoothStepPath, type EdgeProps } from '@xyflow/react'
import { useParams } from 'common'
import { Loader2, X } from 'lucide-react'
import { cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
import { useReplicationLagQuery } from '@/data/read-replicas/replica-lag-query'
import { formatDatabaseID } from '@/data/read-replicas/replicas.utils'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
type EdgeData = {
type: string
identifier: string
isComingUp: boolean
isReplicating: boolean
isFailed: boolean
shiftEdgeEnd: boolean
}
export const SmoothstepEdge = ({
sourceX,
sourceY,
targetX,
targetY,
sourcePosition,
targetPosition,
style = {},
markerEnd,
data,
}: EdgeProps) => {
const { ref } = useParams()
const { data: project } = useSelectedProjectQuery()
const { type, identifier, isComingUp, isReplicating, isFailed, shiftEdgeEnd } = (data ||
{}) as EdgeData
const formattedId = type === 'replica' ? formatDatabaseID(identifier ?? '') : identifier
const [edgePath, labelX, labelY] = getSmoothStepPath({
sourceX,
sourceY,
sourcePosition,
targetX,
targetY,
targetPosition,
})
const {
data: lagDuration,
isPending: isLoading,
isError,
} = useReplicationLagQuery(
{
id: identifier,
projectRef: ref,
connectionString: project?.connectionString,
},
{ enabled: type === 'replica' && isReplicating, refetchInterval: 10000 }
)
const lagValue = Number(lagDuration?.toFixed(2) ?? 0).toLocaleString()
const hasReplicationLagData = data !== undefined && !isError && isReplicating
return (
<>
<BaseEdge path={edgePath} markerEnd={markerEnd} style={style} />
{isFailed && (
<EdgeLabelRenderer>
<div
className={cn('bg-surface-100 p-1 rounded-sm absolute nodrag nopan border')}
style={{
transform: `translate(-50%, -50%) translate(${targetX - 30}px,${targetY}px)`,
}}
>
<X size={12} strokeWidth={4} className="text-destructive" />
</div>
</EdgeLabelRenderer>
)}
{(isComingUp || hasReplicationLagData) && (
<EdgeLabelRenderer>
<Tooltip>
<TooltipTrigger asChild>
<div
className={cn(
'bg-surface-100 py-1 rounded-sm absolute nodrag nopan border',
isLoading || isComingUp ? 'px-1' : 'px-1.5'
)}
style={{
transform: `translate(-50%, -50%) translate(${shiftEdgeEnd ? targetX - 30 : labelX}px,${shiftEdgeEnd ? targetY : labelY}px)`,
pointerEvents: 'all',
}}
>
{isLoading || isComingUp ? (
<Loader2 size={12} className="animate-spin" />
) : (
<p className="font-mono text-xs">{lagValue}s</p>
)}
</div>
</TooltipTrigger>
{!isComingUp && (
<TooltipContent side="bottom" align="center">
{isLoading
? `Checking replication lag for replica ID: ${formattedId}`
: `Replication lag (seconds) for replica ID: ${formattedId}`}
</TooltipContent>
)}
</Tooltip>
</EdgeLabelRenderer>
)}
</>
)
}