Skip to content

Commit 26286fd

Browse files
authored
chore: compute Instances entitlements (supabase#39848)
chore: Compute Instances entitlements
1 parent 406ada7 commit 26286fd

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import {
6464
} from './ui/DiskManagement.constants'
6565
import { NoticeBar } from './ui/NoticeBar'
6666
import { SpendCapDisabledSection } from './ui/SpendCapDisabledSection'
67+
import { useCheckEntitlements } from 'hooks/misc/useCheckEntitlements'
6768

6869
export function DiskManagementForm() {
6970
const { ref: projectRef } = useParams()
@@ -88,6 +89,8 @@ export function DiskManagementForm() {
8889
},
8990
})
9091

92+
const { hasAccess, entitlementConfig } = useCheckEntitlements('instances.compute_update')
93+
9194
const [isDialogOpen, setIsDialogOpen] = useState<boolean>(false)
9295
const [refetchInterval, setRefetchInterval] = useState<number | false>(false)
9396
const [message, setMessageState] = useState<DiskManagementMessage | null>(null)
@@ -192,16 +195,15 @@ export function DiskManagementForm() {
192195

193196
const isRequestingChanges = data?.requested_modification !== undefined
194197
const readReplicas = (databases ?? []).filter((db) => db.identifier !== projectRef)
195-
const isPlanUpgradeRequired = org?.plan.id === 'free'
198+
const isPlanUpgradeRequired = !hasAccess
196199

197200
const { formState } = form
198201
const usedSize = Math.round(((diskUtil?.metrics.fs_used_bytes ?? 0) / GB) * 100) / 100
199202
const totalSize = formState.defaultValues?.totalSize || 0
200203
const usedPercentage = (usedSize / totalSize) * 100
201204

202205
const disableIopsThroughputConfig =
203-
RESTRICTED_COMPUTE_FOR_THROUGHPUT_ON_GP3.includes(form.watch('computeSize')) &&
204-
org?.plan.id !== 'free'
206+
RESTRICTED_COMPUTE_FOR_THROUGHPUT_ON_GP3.includes(form.watch('computeSize')) && !hasAccess
205207

206208
const isBranch = project?.parent_project_ref !== undefined
207209

@@ -316,7 +318,7 @@ export function DiskManagementForm() {
316318
<ScaffoldContainer className="relative flex flex-col gap-10" bottomPadding>
317319
<NoticeBar
318320
type="default"
319-
visible={isPlanUpgradeRequired}
321+
visible={!hasAccess}
320322
title="Compute and Disk configuration is not available on the Free Plan"
321323
actions={<UpgradePlanButton source="diskManagementConfigure" plan="Pro" />}
322324
description="You will need to upgrade to at least the Pro Plan to configure compute and disk"

0 commit comments

Comments
 (0)