Files
supabase/apps/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsx
T
Alaister YoungandAlaister Young 4a18670367 [FE-2417] fix(studio): update disk EBS UI copy to match new limits (#47646)
Updates the dashboard disk-management copy to match the new AWS EBS
modification limits (already reflected in the docs): from the old fixed
"4-hour cooldown / once every 4 hours" framing to "up to 4 modifications
within a rolling 24-hour window".

This is a copy-only change plus one small logic-constant alignment.
Timer/countdown behavior is unchanged — this only updates wording to
bring the dashboard in line with the docs.

**Changed:**
- `DiskSpaceBar` autoscaling tooltip, `DiskCountdownRadial` card,
`DiskSizeConfiguration` "Importing a lot of data?" alert,
`DiskSizeConfigurationModal` alert title + both countdown branches,
`DiskManagementReviewAndSubmitDialog` IOPS + disk-size row descriptions,
and two code comments — all reworded to the new "4 per rolling 24-hour
window" framing
- `DiskSizeConfigurationModal` countdown now derives from the shared
`COOLDOWN_DURATION` constant (4h) instead of a stale hardcoded `6 * 60`
(6h), so the legacy resize path matches the newer disk-attributes path

## To test

- Open a Pro AWS project → **Settings → Compute and Disk** → hover the
**Autoscaling** pill on the disk bar: tooltip should read "…limited to 4
within a rolling 24-hour window" (no "once every 4 hours")
- Change IOPS only → **Review changes** → IOPS row description shows the
new "rolling 24-hour window… as soon as the previous one completes" copy
- Change disk size → **Review changes** → Disk size row shows "You can
modify disk attributes up to 4 times within a rolling 24-hour window"
(not "For 4 hours after changes…")
- On a non-AWS Pro project → **Database → Settings → Increase disk
size**: modal title reads "Disk modifications are limited to 4 per
rolling 24-hour window"; any "resize again in ~X" countdown is bounded
by 4 hours, not 6
- Sanity: none of the old "4-hour cooldown" / "once every 4 hours"
strings appear anywhere in the disk UI

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Updated disk resizing messages across the app to reflect a rolling
24-hour limit instead of a fixed 4-hour cooldown.
* Clarified when disk size, IOPS, and throughput changes are available
again, including more accurate next-available timing.
* Improved warning copy in disk configuration and review dialogs so
limit messages are consistent and easier to understand.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-07-06 23:16:00 +08:00

230 lines
9.4 KiB
TypeScript

import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useParams } from 'common'
import { ExternalLink, Info } from 'lucide-react'
import Link from 'next/link'
import { SetStateAction } from 'react'
import { toast } from 'sonner'
import { Alert, AlertDescription, AlertTitle, Button, InfoIcon } from 'ui'
import {
PageSection,
PageSectionContent,
PageSectionMeta,
PageSectionSummary,
PageSectionTitle,
} from 'ui-patterns/PageSection'
import { Markdown } from '@/components/interfaces/Markdown'
import DiskSizeConfigurationModal from '@/components/interfaces/Settings/Database/DiskSizeConfigurationModal'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { DocsButton } from '@/components/ui/DocsButton'
import Panel from '@/components/ui/Panel'
import { useProjectDiskResizeMutation } from '@/data/config/project-disk-resize-mutation'
import { useDatabaseSizeQuery } from '@/data/database/database-size-query'
import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
import {
useIsAwsNimbusCloudProvider,
useSelectedProjectQuery,
} from '@/hooks/misc/useSelectedProject'
import { useUrlState } from '@/hooks/ui/useUrlState'
import { DOCS_URL } from '@/lib/constants'
import { formatBytes } from '@/lib/helpers'
export interface DiskSizeConfigurationProps {
disabled?: boolean
}
export const DiskSizeConfiguration = ({ disabled = false }: DiskSizeConfigurationProps) => {
const { ref: projectRef } = useParams()
const { data: project } = useSelectedProjectQuery()
const { data: organization } = useSelectedOrganizationQuery()
const isAwsNimbus = useIsAwsNimbusCloudProvider()
const { reportsAll } = useIsFeatureEnabled(['reports:all'])
const [{ show_increase_disk_size_modal }, setUrlParams] = useUrlState()
const showIncreaseDiskSizeModal = show_increase_disk_size_modal === 'true'
const setShowIncreaseDiskSizeModal = (value: SetStateAction<boolean>) => {
const show = typeof value === 'function' ? value(showIncreaseDiskSizeModal) : value
setUrlParams({ show_increase_disk_size_modal: show ? 'true' : undefined })
}
const { can: canUpdateDiskSizeConfig } = useAsyncCheckPermissions(
PermissionAction.UPDATE,
'projects',
{
resource: {
project_id: project?.id,
},
}
)
const { isPending: isUpdatingDiskSize } = useProjectDiskResizeMutation({
onSuccess: (_, variables) => {
toast.success(`Successfully updated disk size to ${variables.volumeSize} GB`)
setShowIncreaseDiskSizeModal(false)
},
})
const { hasAccess: hasAccessToDiskSizeConfig } = useCheckEntitlements(
'instances.disk_modifications'
)
const currentDiskSize = project?.volumeSizeGb ?? 0
const { data } = useDatabaseSizeQuery({
projectRef: project?.ref,
connectionString: project?.connectionString,
})
const databaseSizeBytesUsed = data ?? 0
return (
<>
<PageSection id="disk-management">
<PageSectionMeta>
<PageSectionSummary>
<PageSectionTitle>Disk Management</PageSectionTitle>
</PageSectionSummary>
<DocsButton href={`${DOCS_URL}/guides/platform/database-size#disk-management`} />
</PageSectionMeta>
<PageSectionContent>
{organization?.usage_billing_enabled === true ? (
<div className="flex flex-col gap-3">
<Panel className="m-0!">
<Panel.Content>
<div>
<div>
{currentDiskSize && (
<span className="text-foreground-light flex gap-2 items-baseline">
<h4 className="text-foreground">Current Disk Storage</h4>
</span>
)}
<div className="grid grid-cols-2 items-center">
<p className="text-sm text-lighter max-w-lg">
Supabase employs auto-scaling storage and allows for manual disk size
adjustments when necessary
</p>
{!isAwsNimbus && (
<ButtonTooltip
variant="default"
className="w-min ml-auto"
disabled={!canUpdateDiskSizeConfig || disabled}
onClick={() => setShowIncreaseDiskSizeModal(true)}
tooltip={{
content: {
side: 'bottom',
text: !canUpdateDiskSizeConfig
? 'You need additional permissions to increase the disk size'
: undefined,
},
}}
>
Increase disk size
</ButtonTooltip>
)}
</div>
<div className="grid grid-cols-12 gap-2 mt-12 items-start">
<div className="col-span-4 grid grid-cols-2 gap-x-12 gap-y-4 items-start">
<div className="grid gap-2 col-span-1">
<h5>Space used</h5>
<span className="text-lg">
{formatBytes(databaseSizeBytesUsed, 2, 'GB')}
</span>
</div>
<div className="grid gap-2 col-span-1">
<h5>Total size</h5>
<span className="text-lg">{currentDiskSize} GB</span>
</div>
{reportsAll && (
<div className="col-span-2 mt-4">
<Button
asChild
variant="default"
iconRight={<ExternalLink size={14} />}
>
<Link
href={`/project/${projectRef}/reports/database#database-size-report`}
>
View detailed summary
</Link>
</Button>
</div>
)}
</div>
<div className="col-span-8">
<Alert>
<Info size={16} />
<AlertTitle>Importing a lot of data?</AlertTitle>
<AlertDescription>
<Markdown
className="max-w-full"
content={`
We auto-scale your disk as you need more storage, up to 4 modifications within a rolling 24-hour window.
If you upload more than 1.5x the current size of your storage, your database will go
into read-only mode. If you know how big your database is going to be, you can
manually increase the size here.
Read more about [disk management](${DOCS_URL}/guides/platform/database-size#disk-management) and how to [free up storage space](${DOCS_URL}/guides/platform/database-size#vacuum-operations).
`}
/>
</AlertDescription>
</Alert>
</div>
</div>
</div>
</div>
</Panel.Content>
</Panel>
</div>
) : (
<Alert>
<InfoIcon />
<AlertTitle>
{hasAccessToDiskSizeConfig === false
? 'Disk size configuration is not available for projects on the Free Plan'
: 'Disk size configuration is only available when the spend cap has been disabled'}
</AlertTitle>
<AlertDescription>
{hasAccessToDiskSizeConfig === false ? (
<p>
If you are intending to use more than 500MB of disk space, then you will need to
upgrade to at least the Pro Plan.
</p>
) : (
<p>
If you are intending to use more than 8GB of disk space, then you will need to
disable your spend cap.
</p>
)}
<Button asChild variant="default" className="mt-3">
<Link
href={`/org/${organization?.slug}/billing?panel=${
hasAccessToDiskSizeConfig === false ? 'subscriptionPlan' : 'costControl'
}`}
target="_blank"
>
{hasAccessToDiskSizeConfig === false
? 'Upgrade subscription'
: 'Disable spend cap'}
</Link>
</Button>
</AlertDescription>
</Alert>
)}
</PageSectionContent>
</PageSection>
<DiskSizeConfigurationModal
visible={showIncreaseDiskSizeModal}
loading={isUpdatingDiskSize}
hideModal={setShowIncreaseDiskSizeModal}
/>
</>
)
}