import { useParams } from 'common' import { AnimatePresence, motion } from 'framer-motion' import { Alert, AlertDescription, AlertTitle, InfoIcon } from 'ui' import { BillingChangeBadge } from './BillingChangeBadge' import { DISK_LIMITS, DISK_PRICING, DiskType } from './DiskManagement.constants' import { useReadReplicasQuery } from '@/data/read-replicas/replicas-query' import { formatDatabaseID } from '@/data/read-replicas/replicas.utils' interface DiskManagementDiskSizeReadReplicasProps { isDirty: boolean totalSize: number usedSize: number newTotalSize: number oldStorageType: DiskType newStorageType: DiskType } export const DiskManagementDiskSizeReadReplicas = ({ isDirty, totalSize, usedSize: _usedSize, newTotalSize, oldStorageType, newStorageType, }: DiskManagementDiskSizeReadReplicasProps) => { const { ref: projectRef } = useParams() const { data: databases } = useReadReplicasQuery({ projectRef }) const readReplicas = (databases ?? []).filter((db) => db.identifier !== projectRef) const beforePrice = totalSize * DISK_PRICING[oldStorageType]?.storage const afterPrice = newTotalSize * DISK_PRICING[newStorageType]?.storage if (readReplicas.length === 0) return null return ( <> {isDirty && ( Read replicas are provisioned with extra 25% disk size to account for WAL files Each replica will have a disk size of {newTotalSize}GB, and are billed separately
    {readReplicas.map((replica, index) => (
  • ID: {formatDatabaseID(replica.identifier)} ({replica.region}):
  • ))}
)}
{/* Hide for now until we have the utilization for each RR specifically */} {/*

Read replica disk size information

{isOpen && (

Read replicas have 25% more disk size than the primary database to account for WAL files{' '}

)}
*/} ) } export const DiskManagementIOPSReadReplicas = ({ isDirty, oldIOPS, newIOPS, oldStorageType, newStorageType, }: { isDirty: boolean oldIOPS: number newIOPS: number oldStorageType: DiskType newStorageType: DiskType }) => { const { ref: projectRef } = useParams() const { data: databases } = useReadReplicasQuery({ projectRef }) const readReplicas = (databases ?? []).filter((db) => db.identifier !== projectRef) const beforePrice = (oldIOPS - DISK_LIMITS[oldStorageType]?.includedIops) * DISK_PRICING[oldStorageType]?.iops const afterPrice = (newIOPS - DISK_LIMITS[newStorageType]?.includedIops) * DISK_PRICING[newStorageType]?.iops if (readReplicas.length === 0) return null return ( {isDirty && ( Read replica IOPS will also be updated to the same value
    {readReplicas.map((replica, index) => (
  • ID: {formatDatabaseID(replica.identifier)} ({replica.region}):
  • ))}
)}
) } export const DiskManagementThroughputReadReplicas = ({ isDirty, oldThroughput, newThroughput, oldStorageType, newStorageType, }: { isDirty: boolean oldThroughput: number newThroughput: number oldStorageType: DiskType newStorageType: DiskType }) => { const { ref: projectRef } = useParams() const { data: databases } = useReadReplicasQuery({ projectRef }) const readReplicas = (databases ?? []).filter((db) => db.identifier !== projectRef) const beforePrice = oldStorageType === DiskType.GP3 ? (oldThroughput - DISK_LIMITS[oldStorageType].includedThroughput) * DISK_PRICING[oldStorageType]?.throughput : 0 const afterPrice = newStorageType === DiskType.GP3 ? (newThroughput - DISK_LIMITS[newStorageType].includedThroughput) * DISK_PRICING[newStorageType]?.throughput : 0 if (readReplicas.length === 0) return null return ( {isDirty && ( Read replica throughput will also be updated to the same value
    {readReplicas.map((replica, index) => (
  • ID: {formatDatabaseID(replica.identifier)} ({replica.region}):
  • ))}
)}
) }