The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Chore/disk mgt UI updates (#29313)
Joshen Lima7c25d31863e
diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagement.constants.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagement.constants.tsxindex f92e8579637..95e59e9eb71 100644--- a/apps/studio/components/interfaces/DiskManagement/DiskManagement.constants.tsx+++ b/apps/studio/components/interfaces/DiskManagement/DiskManagement.constants.tsx@@ -5,14 +5,23 @@ export enum DiskType {IO2 = 'io2',}+export const IOPS_RANGE = {+ [DiskType.GP3]: { min: 3000, max: 16000 },+ [DiskType.IO2]: { min: 100, max: 256000 },+}++export const THROUGHPUT_RANGE = {+ [DiskType.GP3]: { min: 125, max: 1000 },+}+export const DISK_PRICING = {[DiskType.GP3]: {- storage: 0.125, // per GB per month+ storage: 0.125, // per GiB per monthiops: 0.024, // per IOPS per month, charged after 3000 IOPSthroughput: 0.095, // per MB/s per month, charged after 125 MB/s},[DiskType.IO2]: {- storage: 0.195, // per GB per month+ storage: 0.195, // per GiB per monthiops: 0.119, // per IOPS per month},}@@ -51,3 +60,29 @@ export const PLAN_DETAILS: Record<PlanType, PlanDetails> = {team: { includedDiskGB: { gp3: 8, io2: 0 } },enterprise: { includedDiskGB: { gp3: 8, io2: 0 } },}++export const COMPUTE_SIZE_MAX_IOPS = {+ ci_micro: 11800,+ ci_small: 11800,+ ci_medium: 11800,+ ci_large: 4750,+ ci_xlarge: 20000,+ ci_2xlarge: 20000,+ ci_4xlarge: 20000,+ ci_8xlarge: 40000,+ ci_12xlarge: 50000,+ ci_16xlarge: 80000,+}++export const COMPUTE_SIZE_MAX_THROUGHPUT = {+ ci_micro: 260.625,+ ci_small: 260.625,+ ci_medium: 260.625,+ ci_large: 593.75,+ ci_xlarge: 593.75,+ ci_2xlarge: 593.75,+ ci_4xlarge: 593.75,+ ci_8xlarge: 1187.5,+ ci_12xlarge: 1781.25,+ ci_16xlarge: 2375,+}diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsxindex a165ca3741f..04c65a935d6 100644--- a/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx+++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx@@ -1,6 +1,6 @@import { zodResolver } from '@hookform/resolvers/zod'import { AnimatePresence, motion } from 'framer-motion'-import { InfoIcon, RotateCcw } from 'lucide-react'+import { HelpCircle, InfoIcon, RotateCcw } from 'lucide-react'import Link from 'next/link'import { useEffect, useState } from 'react'import { useForm } from 'react-hook-form'@@ -8,14 +8,15 @@ import { toast } from 'sonner'import { useParams } from 'common'import DiskSpaceBar from 'components/interfaces/DiskManagement/DiskSpaceBar'-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'import { FormHeader } from 'components/ui/Forms/FormHeader'import {useDiskAttributesQuery,useRemainingDurationForDiskAttributeUpdate,} from 'data/config/disk-attributes-query'import { useUpdateDiskAttributesMutation } from 'data/config/disk-attributes-update-mutation'+import { useDiskUtilizationQuery } from 'data/config/disk-utilization-query'import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'+import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'import { GB } from 'lib/constants'import {@@ -34,12 +35,22 @@ import {RadioGroupCard,RadioGroupCardItem,Separator,+ Tooltip_Shadcn_,+ TooltipContent_Shadcn_,+ TooltipTrigger_Shadcn_,} from 'ui'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'import { FormFooterChangeBadge } from '../DataWarehouse/FormFooterChangeBadge'import BillingChangeBadge from './BillingChangeBadge'import { DiskCountdownRadial } from './DiskCountdownRadial'-import { DiskType, PLAN_DETAILS } from './DiskManagement.constants'+import {+ COMPUTE_SIZE_MAX_IOPS,+ COMPUTE_SIZE_MAX_THROUGHPUT,+ DiskType,+ IOPS_RANGE,+ PLAN_DETAILS,+ THROUGHPUT_RANGE,+} from './DiskManagement.constants'import {calculateDiskSizePrice,calculateIOPSPrice,@@ -49,11 +60,9 @@ import { DiskManagementDiskSizeReadReplicas } from './DiskManagementDiskSizeReadimport { DiskStorageSchema, DiskStorageSchemaType } from './DiskManagementPanelSchema'import { DiskManagementPlanUpgradeRequired } from './DiskManagementPlanUpgradeRequired'import { DiskManagementReviewAndSubmitDialog } from './DiskManagementReviewAndSubmitDialog'-import { useDiskUtilizationQuery } from 'data/config/disk-utilization-query'export function DiskManagementPanelForm() {const org = useSelectedOrganization()- const { project } = useProjectContext()const { ref: projectRef } = useParams()const [isDialogOpen, setIsDialogOpen] = useState<boolean>(false)@@ -94,6 +103,17 @@ export function DiskManagementPanelForm() {projectRef,})+ const { data: addons } = useProjectAddonsQuery({ projectRef })+ const currentCompute = (addons?.selected_addons ?? []).find(+ (x) => x.type === 'compute_instance'+ )?.variant+ const maxIopsBasedOnCompute =+ COMPUTE_SIZE_MAX_IOPS[(currentCompute?.identifier ?? '') as keyof typeof COMPUTE_SIZE_MAX_IOPS]+ const maxThroughputBasedOnCompute =+ COMPUTE_SIZE_MAX_THROUGHPUT[+ (currentCompute?.identifier ?? '') as keyof typeof COMPUTE_SIZE_MAX_THROUGHPUT+ ]+const { data: subscription } = useOrgSubscriptionQuery({orgSlug: org?.slug,})@@ -142,12 +162,17 @@ export function DiskManagementPanelForm() {PLAN_DETAILS?.[planId as keyof typeof PLAN_DETAILS] ?? {}const includedDiskGB = includedDiskGBMeta[watchedStorageType]+ const minIOPS = IOPS_RANGE[watchedStorageType]?.min ?? 0const maxIOPS =watchedStorageType === 'gp3'- ? Math.min(500 * watchedTotalSize, 16000)- : Math.min(1000 * watchedTotalSize, 256000)+ ? Math.min(500 * watchedTotalSize, IOPS_RANGE[DiskType.GP3].max)+ : Math.min(1000 * watchedTotalSize, IOPS_RANGE[DiskType.IO2].max)+ const minThroughput =+ watchedStorageType === 'gp3' ? THROUGHPUT_RANGE[watchedStorageType]?.min ?? 0 : 0const maxThroughput =- watchedStorageType === 'gp3' ? Math.min(0.25 * watchedIOPS, 1000) : undefined+ watchedStorageType === 'gp3'+ ? Math.min(0.25 * watchedIOPS, THROUGHPUT_RANGE[DiskType.GP3].max)+ : undefinedconst onSubmit = async (data: DiskStorageSchemaType) => {if (projectRef === undefined) return console.error('Project ref is required')@@ -187,8 +212,9 @@ export function DiskManagementPanelForm() {} else if (watchedStorageType === 'gp3') {// Ensure throughput is within the allowed range if it's greater than or equal to 400 GiBconst currentThroughput = form.getValues('throughput')- if (!currentThroughput || currentThroughput < 125 || currentThroughput > 1000) {- setValue('throughput', 125) // Reset to default if undefined or out of bounds+ const { min, max } = THROUGHPUT_RANGE[DiskType.GP3]+ if (!currentThroughput || currentThroughput < min || currentThroughput > max) {+ setValue('throughput', min) // Reset to default if undefined or out of bounds}}}, [watchedStorageType, watchedTotalSize, setValue, form])@@ -338,19 +364,64 @@ export function DiskManagementPanelForm() {layout="horizontal"label="IOPS"description={- watchedStorageType === 'io2' ? (- <>- For <code className="text-xs">io2</code> storage type, IOPS must be{' '}- {watchedTotalSize >= 8 ? `between 100 and ${maxIOPS}.` : `at least 100`}- </>- ) : (- <>- For <code className="text-xs">gp3</code> storage type, IOPS must be{' '}- {watchedTotalSize >= 8- ? `between 3,000 and ${maxIOPS.toLocaleString()}.`- : `at least 3,000`}- </>- )+ <>+ {watchedStorageType === 'io2' ? (+ <div className="flex items-center gap-x-2">+ <span>+ IOPS must be{' '}+ {watchedTotalSize >= 8+ ? `between ${minIOPS} and ${maxIOPS.toLocaleString()} based on your disk size.`+ : `at least ${minIOPS}`}+ </span>+ <Tooltip_Shadcn_>+ <TooltipTrigger_Shadcn_ asChild>+ <HelpCircle+ size={14}+ className="transition hover:text-foreground"+ />+ </TooltipTrigger_Shadcn_>+ <TooltipContent_Shadcn_ side="bottom">+ For io2 storage type, min IOPS is at {minIOPS}, while max IOPS is+ at 1000 * disk size in GiB or{' '}+ {IOPS_RANGE[DiskType.IO2].max.toLocaleString()}, whichever is+ lower+ </TooltipContent_Shadcn_>+ </Tooltip_Shadcn_>+ </div>+ ) : (+ <div className="flex items-center gap-x-2">+ <span>+ IOPS must be{' '}+ {watchedTotalSize >= 8+ ? `between ${minIOPS.toLocaleString()} and ${maxIOPS.toLocaleString()} based on your disk size.`+ : `at least ${minIOPS.toLocaleString()}`}+ </span>+ <Tooltip_Shadcn_>+ <TooltipTrigger_Shadcn_ asChild>+ <HelpCircle+ size={14}+ className="transition hover:text-foreground"+ />+ </TooltipTrigger_Shadcn_>+ <TooltipContent_Shadcn_ side="bottom" className="w-64">+ For gp3 storage type, min IOPS is at {minIOPS} while max IOPS is+ at 500 * disk size in GiB or{' '}+ {IOPS_RANGE[DiskType.GP3].max.toLocaleString()}, whichever is+ lower+ </TooltipContent_Shadcn_>+ </Tooltip_Shadcn_>+ </div>+ )}+ {field.value > maxIopsBasedOnCompute && (+ <p>+ Note: Final usable IOPS will be at{' '}+ <span className="text-foreground">+ {maxIopsBasedOnCompute.toLocaleString()}+ </span>{' '}+ based on your current compute size of {currentCompute?.name}+ </p>+ )}+ </>}labelOptional="Input/output operations per second. Higher IOPS is suitable for applications requiring high throughput.">@@ -407,8 +478,35 @@ export function DiskManagementPanelForm() {layout="horizontal"description={<>- For <code className="text-xs">gp3</code> storage type, throughput- must be between 125 and {maxThroughput} MiBps+ <div className="flex items-center gap-x-2">+ <span>+ Throughput must be between {minThroughput} and {maxThroughput}{' '}+ MiBps based on your IOPS.+ </span>+ <Tooltip_Shadcn_>+ <TooltipTrigger_Shadcn_ asChild>+ <HelpCircle+ size={14}+ className="transition hover:text-foreground"+ />+ </TooltipTrigger_Shadcn_>+ <TooltipContent_Shadcn_ side="bottom" className="w-64">+ Min throughput is at 125MiBps, while max throughput is at+ 0.25MiBps * IOPS or 1000, whichever is lower+ </TooltipContent_Shadcn_>+ </Tooltip_Shadcn_>+ </div>+ {field.value !== undefined &&+ field.value > maxThroughputBasedOnCompute && (+ <p>+ Note: Final usable throughput will be at{' '}+ <span className="text-foreground">+ {maxThroughputBasedOnCompute.toFixed(0)}+ </span>{' '}+ MiBps based on your current compute size of{' '}+ {currentCompute?.name}+ </p>+ )}</>}>@@ -457,7 +555,14 @@ export function DiskManagementPanelForm() {name="totalSize"control={control}render={({ field }) => (- <FormItemLayout label="Disk Size" layout="horizontal">+ <FormItemLayout+ label="Disk Size"+ layout="horizontal"+ description={+ includedDiskGB > 0 &&+ `Your plan includes ${includedDiskGB} GiB of disk size for ${watchedStorageType}.`+ }+ ><div className="mt-1 relative flex gap-2 items-center"><div className="flex -space-x-px max-w-48"><FormControl_Shadcn_>@@ -491,7 +596,6 @@ export function DiskManagementPanelForm() {animate={{ opacity: 1, scale: 1, x: 0 }}exit={{ opacity: 0, scale: 0.95, x: -2 }}transition={{ duration: 0.15 }}- style={{ overflow: 'hidden' }}><ButtonhtmlType="button"@@ -514,12 +618,6 @@ export function DiskManagementPanelForm() {diskSizePrice.oldPrice !== diskSizePrice.newPrice}/>- {includedDiskGB > 0 && (- <div className="text-xs text-foreground-light">- Your plan includes {includedDiskGB} GiB of disk size for{' '}- {watchedStorageType}.- </div>- )}</div></FormItemLayout>)}diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelSchema.ts b/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelSchema.tsindex 0564d7a99f7..88916a0bef8 100644--- a/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelSchema.ts+++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelSchema.ts@@ -5,7 +5,7 @@ const baseSchema = z.object({totalSize: z.number().min(8, { message: 'Allocated disk size must be at least 8 GiB.' })- .max(16384, { message: 'Allocated disk size must not exceed 16 TiB.' })+ .max(16384, { message: 'Allocated disk size must not exceed 16,384 GiB.' }).describe('Allocated disk size in GiB'),provisionedIOPS: z.number().describe('Provisioned IOPS for storage type'),throughput: z.number().optional().describe('Throughput in MiBps for gp3'),@@ -20,14 +20,14 @@ export const DiskStorageSchema = baseSchema.superRefine((data, ctx) => {if (provisionedIOPS < 100) {ctx.addIssue({code: z.ZodIssueCode.custom,- message: 'Provisioned IOPS must be at least 100 for io2.',+ message: 'Provisioned IOPS must be at least 100',path: ['provisionedIOPS'],})} else if (provisionedIOPS > maxIOPS) {if (totalSize >= 8) {ctx.addIssue({code: z.ZodIssueCode.custom,- message: `Provisioned IOPS must be at most ${maxIOPS} for io2.`,+ message: `Provisioned IOPS must be at most ${maxIOPS}.`,path: ['provisionedIOPS'],})} else {@@ -53,14 +53,14 @@ export const DiskStorageSchema = baseSchema.superRefine((data, ctx) => {if (provisionedIOPS < 3000) {ctx.addIssue({code: z.ZodIssueCode.custom,- message: `Provisioned IOPS must be at least 3000 for gp3.`,+ message: `Provisioned IOPS must be at least 3000`,path: ['provisionedIOPS'],})} else if (provisionedIOPS > maxIOPS) {if (totalSize >= 8) {ctx.addIssue({code: z.ZodIssueCode.custom,- message: `Provisioned IOPS must be at most ${maxIOPS} for gp3.`,+ message: `Provisioned IOPS must be at most ${maxIOPS}`,path: ['provisionedIOPS'],})} else {diff --git a/apps/studio/components/interfaces/DiskManagement/DiskSpaceBar.tsx b/apps/studio/components/interfaces/DiskManagement/DiskSpaceBar.tsxindex 83012b5ee9f..d4bd6a0c2c1 100644--- a/apps/studio/components/interfaces/DiskManagement/DiskSpaceBar.tsx+++ b/apps/studio/components/interfaces/DiskManagement/DiskSpaceBar.tsx@@ -5,9 +5,6 @@ import { useState } from 'react'import {badgeVariants,cn,- HoverCard,- HoverCardContent,- HoverCardTrigger,Tooltip_Shadcn_,TooltipContent_Shadcn_,TooltipTrigger_Shadcn_,@@ -26,8 +23,6 @@ export default function DiskSpaceBar({usedSize,newTotalSize,}: DiskSpaceBarProps) {- // const [totalSize, setTotalSize] = useState<number>(8) // 8 GB total disk size- // const [usedSize, setUsedSize] = useState<number>(4) // Starting with 4 GB used (50% usage)const [resizeThreshold, setResizeThreshold] = useState<number>(0.5) // 500 MB threshold for resizeconst usedPercentage = (usedSize / totalSize) * 100@@ -42,7 +37,7 @@ export default function DiskSpaceBar({<div className="flex flex-col gap-2"><div className="flex items-center h-6 gap-3"><span className="text-foreground-light text-sm font-mono flex items-center gap-2">- {usedSize.toFixed(2)} GB used of{' '}+ {usedSize.toFixed(2)} GiB used of{' '}<span className="text-foreground font-semibold -mt-[2px]"><MotionNumbervalue={newTotalSize}@@ -53,7 +48,7 @@ export default function DiskSpaceBar({className="font-mono"/></span>{' '}- GB+ GiB</span></div><div className="relative">