IOPSField() — supabase Function Reference
Architecture documentation for the IOPSField() function in IOPSField.tsx from the supabase codebase.
Entity Profile
Dependency Diagram
graph TD e4f4740e_699b_cee8_77fb_38343fd520bf["IOPSField()"] 358afe46_09fa_dd8b_54eb_6c8758ac6b45["calculateIOPSPrice()"] e4f4740e_699b_cee8_77fb_38343fd520bf -->|calls| 358afe46_09fa_dd8b_54eb_6c8758ac6b45 5a5e7bf2_43db_cf41_0d0b_243b77c1d79d["calculateComputeSizeRequiredForIops()"] e4f4740e_699b_cee8_77fb_38343fd520bf -->|calls| 5a5e7bf2_43db_cf41_0d0b_243b77c1d79d b53797de_ebc6_57df_780c_1f609f8111e4["mapAddOnVariantIdToComputeSize()"] e4f4740e_699b_cee8_77fb_38343fd520bf -->|calls| b53797de_ebc6_57df_780c_1f609f8111e4 style e4f4740e_699b_cee8_77fb_38343fd520bf fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
apps/studio/components/interfaces/DiskManagement/fields/IOPSField.tsx lines 26–134
export function IOPSField({ form, disableInput }: IOPSFieldProps) {
const { ref: projectRef } = useParams()
const { control, formState, setValue, trigger, getValues, watch } = form
const watchedStorageType = watch('storageType')
const watchedComputeSize = watch('computeSize')
const watchedIOPS = watch('provisionedIOPS') ?? 0
const { isPending: isLoading, error, isError } = useDiskAttributesQuery({ projectRef })
const iopsPrice = calculateIOPSPrice({
oldStorageType: formState.defaultValues?.storageType as DiskType,
oldProvisionedIOPS: formState.defaultValues?.provisionedIOPS || 0,
newStorageType: getValues('storageType') as DiskType,
newProvisionedIOPS: getValues('provisionedIOPS'),
})
const disableIopsInput =
RESTRICTED_COMPUTE_FOR_IOPS_ON_GP3.includes(watchedComputeSize) && watchedStorageType === 'gp3'
return (
<FormField_Shadcn_
control={control}
name="provisionedIOPS"
render={({ field }) => {
const reccomendedComputeSize = calculateComputeSizeRequiredForIops(watchedIOPS)
return (
<FormItemLayout
layout="horizontal"
label="IOPS"
id={field.name}
description={
<span className="flex flex-col gap-y-2">
<p>Use higher IOPS for high-throughput apps.</p>
<ComputeSizeRecommendationSection
form={form}
actions={
<Button
type="default"
onClick={() => {
setValue('computeSize', reccomendedComputeSize ?? 'ci_nano')
trigger('provisionedIOPS')
}}
>
Update to {mapAddOnVariantIdToComputeSize(reccomendedComputeSize)}
</Button>
}
/>
{!formState.errors.provisionedIOPS && (
<DiskManagementIOPSReadReplicas
isDirty={formState.dirtyFields.provisionedIOPS !== undefined}
oldIOPS={formState.defaultValues?.provisionedIOPS ?? 0}
newIOPS={field.value}
oldStorageType={formState.defaultValues?.storageType as DiskType}
newStorageType={getValues('storageType') as DiskType}
/>
)}
</span>
}
labelOptional={
<>
<BillingChangeBadge
show={
(watchedStorageType !== formState.defaultValues?.storageType ||
(watchedStorageType === 'gp3' &&
field.value !== formState.defaultValues?.provisionedIOPS)) &&
!formState.errors.provisionedIOPS &&
!disableIopsInput
}
beforePrice={Number(iopsPrice.oldPrice)}
afterPrice={Number(iopsPrice.newPrice)}
className="mb-2"
/>
<p className="text-foreground-lighter">Input/output operations per second.</p>
</>
}
>
<InputPostTab label="IOPS">
{isLoading ? (
<div
className={cn(InputVariants({ size: 'small' }), 'w-32 font-mono rounded-r-none')}
>
<Skeleton className="w-10 h-4" />
</div>
) : (
<FormControl_Shadcn_>
<Input_Shadcn_
type="number"
className="flex-grow font-mono rounded-r-none max-w-32"
{...field}
value={field.value}
disabled={disableInput || disableIopsInput || isError}
onChange={(e) => {
setValue('provisionedIOPS', e.target.valueAsNumber, {
shouldDirty: true,
shouldValidate: true,
})
}}
/>
</FormControl_Shadcn_>
)}
</InputPostTab>
{error && <FormMessage type="error" message={error.message} />}
</FormItemLayout>
)
}}
/>
)
}
Domain
Subdomains
Source
Frequently Asked Questions
What does IOPSField() do?
IOPSField() is a function in the supabase codebase.
What does IOPSField() call?
IOPSField() calls 3 function(s): calculateComputeSizeRequiredForIops, calculateIOPSPrice, mapAddOnVariantIdToComputeSize.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free