Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: block PITR addon changes with HIPAA addon (#20416)

Kevin Grünebergaa36e78c6fea
diff --git a/apps/studio/components/interfaces/Settings/Addons/Addons.tsx b/apps/studio/components/interfaces/Settings/Addons/Addons.tsx
index 2f9a974311b..9e29adb3aa5 100644
--- a/apps/studio/components/interfaces/Settings/Addons/Addons.tsx
+++ b/apps/studio/components/interfaces/Settings/Addons/Addons.tsx
@@ -4,7 +4,10 @@ import { useMemo } from 'react'
import { useParams } from 'common'
import { useTheme } from 'next-themes'
-import { getAddons } from 'components/interfaces/Billing/Subscription/Subscription.utils'
+import {
+ getAddons,
+ subscriptionHasHipaaAddon,
+} from 'components/interfaces/Billing/Subscription/Subscription.utils'
import ProjectUpdateDisabledTooltip from 'components/interfaces/Organization/BillingSettings/ProjectUpdateDisabledTooltip'
import {
useIsProjectActive,
@@ -21,7 +24,7 @@ import AlertError from 'components/ui/AlertError'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
import { useInfraMonitoringQuery } from 'data/analytics/infra-monitoring-query'
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
-import { useFlag, useProjectByRef } from 'hooks'
+import { useFlag, useProjectByRef, useSelectedOrganization } from 'hooks'
import { getCloudProviderArchitecture } from 'lib/cloudprovider-utils'
import { BASE_PATH } from 'lib/constants'
import { getDatabaseMajorVersion, getSemanticVersion } from 'lib/helpers'
@@ -41,6 +44,7 @@ import ComputeInstanceSidePanel from './ComputeInstanceSidePanel'
import PITRSidePanel from './PITRSidePanel'
import CustomDomainSidePanel from './CustomDomainSidePanel'
import { ProjectAddonVariantMeta } from 'data/subscriptions/types'
+import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
const Addons = () => {
const { resolvedTheme } = useTheme()
@@ -48,6 +52,8 @@ const Addons = () => {
const snap = useSubscriptionPageStateSnapshot()
const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate')
const { project: selectedProject } = useProjectContext()
+ const selectedOrg = useSelectedOrganization()
+ const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: selectedOrg?.slug })
const parentProject = useProjectByRef(selectedProject?.parent_project_ref)
const isBranch = parentProject !== undefined
@@ -57,6 +63,8 @@ const Addons = () => {
snap.setPanelKey(panel as SUBSCRIPTION_PANEL_KEYS)
}
+ const hasHipaaAddon = subscriptionHasHipaaAddon(subscription)
+
const cpuArchitecture = getCloudProviderArchitecture(selectedProject?.cloud_provider)
// Only projects of version greater than supabase-postgrest-14.1.0.44 can use PITR
const sufficientPgVersion =
@@ -358,6 +366,20 @@ const Addons = () => {
</div>
</ScaffoldSectionDetail>
<ScaffoldSectionContent>
+ {hasHipaaAddon && (
+ <Alert_Shadcn_>
+ <AlertTitle_Shadcn_>PITR cannot be changed with HIPAA</AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ All projects should have PITR enabled by default and cannot be changed with
+ HIPAA enabled. Contact support for further assistance.
+ </AlertDescription_Shadcn_>
+ <div className="mt-4">
+ <Button type="default" asChild>
+ <Link href="/support/new">Contact support</Link>
+ </Button>
+ </div>
+ </Alert_Shadcn_>
+ )}
<div className="flex space-x-6">
<div>
<div className="rounded-md bg-surface-200 w-[160px] h-[96px] shadow">
@@ -415,7 +437,8 @@ const Addons = () => {
isBranch ||
!isProjectActive ||
projectUpdateDisabled ||
- !sufficientPgVersion
+ !sufficientPgVersion ||
+ hasHipaaAddon
}
>
Change point in time recovery
diff --git a/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx b/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx
index dbeb42c322d..a9160b74585 100644
--- a/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx
+++ b/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx
@@ -28,6 +28,7 @@ import {
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
import { AlertTriangleIcon } from 'lucide-react'
import { AddonVariantId } from 'data/subscriptions/types'
+import { subscriptionHasHipaaAddon } from 'components/interfaces/Billing/Subscription/Subscription.utils'
const PITR_CATEGORY_OPTIONS: {
id: 'off' | 'on'
@@ -76,6 +77,8 @@ const PITRSidePanel = () => {
const { data: addons, isLoading } = useProjectAddonsQuery({ projectRef })
const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: organization?.slug })
+ const hasHipaaAddon = subscriptionHasHipaaAddon(subscription)
+
const { mutate: updateAddon, isLoading: isUpdating } = useProjectAddonUpdateMutation({
onSuccess: () => {
ui.setNotification({
@@ -162,9 +165,13 @@ const PITRSidePanel = () => {
onCancel={onClose}
onConfirm={onConfirm}
loading={isLoading || isSubmitting}
- disabled={isFreePlan || isLoading || !hasChanges || isSubmitting || !canUpdatePitr}
+ disabled={
+ isFreePlan || isLoading || !hasChanges || isSubmitting || !canUpdatePitr || hasHipaaAddon
+ }
tooltip={
- isFreePlan
+ hasHipaaAddon
+ ? 'Unable to change PITR with HIPAA add-on'
+ : isFreePlan
? 'Unable to enable point in time recovery on a free plan'
: !canUpdatePitr
? 'You do not have permission to update PITR'
@@ -186,6 +193,20 @@ const PITRSidePanel = () => {
}
>
<SidePanel.Content>
+ {hasHipaaAddon && (
+ <Alert_Shadcn_>
+ <AlertTitle_Shadcn_>PITR cannot be changed with HIPAA</AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ All projects should have PITR enabled by default and cannot be changed with HIPAA
+ enabled. Contact support for further assistance.
+ </AlertDescription_Shadcn_>
+ <div className="mt-4">
+ <Button type="default" asChild>
+ <Link href="/support/new">Contact support</Link>
+ </Button>
+ </div>
+ </Alert_Shadcn_>
+ )}
<div className="py-6 space-y-4">
<p className="text-sm">
Point-in-Time Recovery (PITR) allows a project to be backed up at much shorter