import { type RefObject } from 'react' import { type UseFormReturn } from 'react-hook-form' import { Button, Card, CardContent } from 'ui' import { Admonition } from 'ui-patterns/Admonition' import { PageSection, PageSectionAside, PageSectionContent, PageSectionDescription, PageSectionMeta, PageSectionSummary, PageSectionTitle, } from 'ui-patterns/PageSection' import { DiskStorageSchemaType } from './DiskManagement.schema' import { AutoScaleFields } from './fields/AutoScaleFields' import { ComputeSectionBillingBadge, ComputeSizeField, ComputeSizeFieldMeta, } from './fields/ComputeSizeField' import { DiskSizeField } from './fields/DiskSizeField' import { IOPSField } from './fields/IOPSField' import { StorageTypeField } from './fields/StorageTypeField' import { ThroughputField } from './fields/ThroughputField' import { BillingChangeBadge } from './ui/BillingChangeBadge' import { DiskCountdownRadial } from './ui/DiskCountdownRadial' import { DiskSpaceBar } from './ui/DiskSpaceBar' import { NoticeBar } from './ui/NoticeBar' import { SpendCapDisabledSection } from './ui/SpendCapDisabledSection' import { DocsButton } from '@/components/ui/DocsButton' import { HighAvailabilityDisabledSectionNotice } from '@/components/ui/HighAvailability/HighAvailabilityDisabledSectionNotice' import { RequestUpgradeToBillingOwners } from '@/components/ui/RequestUpgradeToBillingOwners' import { DOCS_URL } from '@/lib/constants' interface ComputeSectionProps { form: UseFormReturn settingsRef: RefObject showBillingBadge: boolean beforePrice: number afterPrice: number disabled: boolean } export function ComputeSection({ form, settingsRef, showBillingBadge, beforePrice, afterPrice, disabled, }: ComputeSectionProps) { return ( Compute size ) } interface DiskSectionProps { form: UseFormReturn settingsRef: RefObject showBillingBadge: boolean beforePrice: number afterPrice: number isAws: boolean isAwsK8s: boolean isBranch: boolean isNoticeVisible: boolean isReadOnlyMode: boolean usedPercentage: number isWithinCooldownWindow: boolean currentDiskSizeGb?: number disableDiskSizeInput: boolean } function getDiskNoticeDescription({ isAwsK8s, isBranch, }: Pick) { if (isAwsK8s) { return 'Configuring your disk for AWS (Revamped) projects is unavailable for now.' } if (isBranch) { return 'Delete and recreate your Preview Branch to configure disk size. It was deployed on an older branching infrastructure.' } return undefined } export function DiskSection({ form, settingsRef, showBillingBadge, beforePrice, afterPrice, isAws, isAwsK8s, isBranch, isNoticeVisible, isReadOnlyMode, usedPercentage, isWithinCooldownWindow, currentDiskSizeGb, disableDiskSizeInput, }: DiskSectionProps) { const noticeDescription = getDiskNoticeDescription({ isAwsK8s, isBranch }) return ( Disk Configure provisioned storage for your primary database. {isAws && } {isAws && ( <>
{!isReadOnlyMode && usedPercentage >= 90 && isWithinCooldownWindow && ( )} {isReadOnlyMode && ( )}
)}
) } interface AdvancedSectionProps { form: UseFormReturn autoscaleSettingsRef: RefObject storageSettingsRef: RefObject showBillingBadge: boolean beforePrice: number afterPrice: number disableIopsThroughputConfig?: boolean canUpdateDiskConfiguration: boolean isDiskTooSmallForCustomIops: boolean disableDiskInputs: boolean disableDiskSizeInput: boolean suggestedDiskSizeForCustomIops: number } export function AdvancedSection({ form, autoscaleSettingsRef, storageSettingsRef, showBillingBadge, beforePrice, afterPrice, disableIopsThroughputConfig, canUpdateDiskConfiguration, isDiskTooSmallForCustomIops, disableDiskInputs, disableDiskSizeInput, suggestedDiskSizeForCustomIops, }: AdvancedSectionProps) { return ( Advanced Configure autoscaling, storage type, IOPS, and throughput. { form.setValue('computeSize', 'ci_large', { shouldDirty: true, shouldValidate: true, }) form.trigger('provisionedIOPS') form.trigger('throughput') }} > Change to LARGE Compute ) : ( ) } /> { form.setValue('totalSize', suggestedDiskSizeForCustomIops, { shouldDirty: true, shouldValidate: true, }) }} > Increase to {suggestedDiskSizeForCustomIops} GB ) : undefined } /> ) }