Skip to content

Commit 35387c6

Browse files
authored
chore: compute entitlement set (supabase#40352)
* chore: compute entitlement set * Clean up * Clean up * Format
1 parent 23c7c8c commit 35387c6

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ export function DiskManagementForm() {
8989
},
9090
})
9191

92-
const { hasAccess } = useCheckEntitlements('instances.compute_update')
92+
const { hasAccess, isSuccess: isEntitlementsLoaded } = useCheckEntitlements(
93+
'instances.compute_update_available_sizes'
94+
)
9395

9496
const [isDialogOpen, setIsDialogOpen] = useState<boolean>(false)
9597
const [refetchInterval, setRefetchInterval] = useState<number | false>(false)
@@ -318,7 +320,7 @@ export function DiskManagementForm() {
318320
<ScaffoldContainer className="relative flex flex-col gap-10" bottomPadding>
319321
<NoticeBar
320322
type="default"
321-
visible={!hasAccess}
323+
visible={isEntitlementsLoaded && !hasAccess}
322324
title="Compute and Disk configuration is not available on the Free Plan"
323325
actions={<UpgradePlanButton source="diskManagementConfigure" plan="Pro" />}
324326
description="You will need to upgrade to at least the Pro Plan to configure compute and disk"

apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
import { BillingChangeBadge } from '../ui/BillingChangeBadge'
3636
import FormMessage from '../ui/FormMessage'
3737
import { NoticeBar } from '../ui/NoticeBar'
38+
import { useCheckEntitlements } from 'hooks/misc/useCheckEntitlements'
3839

3940
/**
4041
* to do: this could be a type from api-types
@@ -57,6 +58,9 @@ export function ComputeSizeField({ form, disabled }: ComputeSizeFieldProps) {
5758
const { data: org } = useSelectedOrganizationQuery()
5859
const { data: project, isLoading: isProjectLoading } = useSelectedProjectQuery()
5960

61+
const { hasAccess: entitledUpdateCompute, isLoading: isEntitlementLoading } =
62+
useCheckEntitlements('instances.compute_update_available_sizes')
63+
6064
const showComputePrice = useIsFeatureEnabled('project_addons:show_compute_price')
6165

6266
const { computeSize, storageType } = form.watch()
@@ -67,7 +71,7 @@ export function ComputeSizeField({ form, disabled }: ComputeSizeFieldProps) {
6771
error: addonsError,
6872
} = useProjectAddonsQuery({ projectRef: ref })
6973

70-
const isLoading = isProjectLoading || isAddonsLoading
74+
const isLoading = isProjectLoading || isAddonsLoading || isEntitlementLoading
7175

7276
const { control, formState, setValue, trigger } = form
7377

@@ -92,10 +96,8 @@ export function ComputeSizeField({ form, disabled }: ComputeSizeFieldProps) {
9296
plan: org?.plan.id ?? 'free',
9397
})
9498

95-
const showUpgradeBadge = showMicroUpgrade(
96-
org?.plan.id ?? 'free',
97-
project?.infra_compute_size ?? 'nano'
98-
)
99+
const projectComputeSize = project?.infra_compute_size ?? 'nano'
100+
const showUpgradeBadge = entitledUpdateCompute && projectComputeSize === 'nano'
99101

100102
return (
101103
<FormField_Shadcn_

0 commit comments

Comments
 (0)