Skip to content

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

Add info box if project is too old for pitr

Joshen Limf0ba18ad07ae
diff --git a/studio/components/interfaces/Billing/AddOns/AddOns.utils.ts b/studio/components/interfaces/Billing/AddOns/AddOns.utils.ts
index 4ba28364bf9..4feb43e98dc 100644
--- a/studio/components/interfaces/Billing/AddOns/AddOns.utils.ts
+++ b/studio/components/interfaces/Billing/AddOns/AddOns.utils.ts
@@ -1,5 +1,14 @@
import { DatabaseAddon } from './AddOns.types'
+// e.g supabase-postgres-14.1.0.88 (There's 4 segments instead, so we can't use semver)
+export const getSemanticVersion = (version: string) => {
+ if (!version) return 0
+
+ const segments = version.split('-')
+ const semver = segments[segments.length - 1]
+ return Number(semver.split('.').join(''))
+}
+
export const formatComputeSizes = (addons: DatabaseAddon[]) => {
const addonsOrder = [
'addon_instance_small',
diff --git a/studio/components/interfaces/Billing/AddOns/PITRDurationSelection.tsx b/studio/components/interfaces/Billing/AddOns/PITRDurationSelection.tsx
index 6bb2efcaa12..ae760d4fb46 100644
--- a/studio/components/interfaces/Billing/AddOns/PITRDurationSelection.tsx
+++ b/studio/components/interfaces/Billing/AddOns/PITRDurationSelection.tsx
@@ -1,11 +1,14 @@
import { FC } from 'react'
-import { Badge, IconAlertCircle, Radio } from 'ui'
+import { useRouter } from 'next/router'
+import { Badge, IconAlertCircle, Radio, Button } from 'ui'
-import { useFlag } from 'hooks'
+import { useFlag, useStore } from 'hooks'
import { DatabaseAddon } from './AddOns.types'
import { getProductPrice } from '../Billing.utils'
import DisabledWarningDueToIncident from 'components/ui/DisabledWarningDueToIncident'
import InformationBox from 'components/ui/InformationBox'
+import { getSemanticVersion } from './AddOns.utils'
+import Link from 'next/link'
interface Props {
pitrDurationOptions: DatabaseAddon[]
@@ -20,28 +23,56 @@ const PITRDurationSelection: FC<Props> = ({
selectedPitrDuration,
onSelectOption,
}) => {
+ const { ui } = useStore()
+ const router = useRouter()
+ const { ref } = router.query
const addonUpdateDisabled = useFlag('disableProjectCreationAndUpdate')
+ // Only projects of version greater than supabase-postgrest-14.1.0.44 can use PITR
+ // const canUsePITR = getSemanticVersion(ui.selectedProject?.kpsVersion ?? '') > 141044
+ const canUsePITR = false
+
return (
<div className="space-y-4">
<div>
<div className="flex items-center space-x-2">
- <h4 className="text-lg">Point in time recovery</h4>
+ <h4 className="text-lg">Point in time recovery (PITR)</h4>
<Badge color="green">Optional</Badge>
</div>
<p className="text-sm text-scale-1100">
Restore your database from a specific point in time
</p>
- <div className="mt-2">
- <InformationBox
- icon={<IconAlertCircle strokeWidth={2} />}
- title="Your project is required to minimally be on a Small Add-on to enable PITR"
- description="This is to ensure that your project has enough resources to execute PITR successfully"
- />
- </div>
+ {canUsePITR && (
+ <div className="mt-2">
+ <InformationBox
+ icon={<IconAlertCircle strokeWidth={2} />}
+ title="Your project is required to minimally be on a Small Add-on to enable PITR"
+ description="This is to ensure that your project has enough resources to execute PITR successfully"
+ />
+ </div>
+ )}
</div>
{addonUpdateDisabled ? (
<DisabledWarningDueToIncident title="Updating database add-ons is currently disabled" />
+ ) : !canUsePITR ? (
+ <InformationBox
+ hideCollapse
+ defaultVisibility
+ title="Your project is too old to be able to enable PITR for"
+ description={
+ <div className="flex items-center justify-between m-1">
+ <p className="text-sm leading-normal">Reach out to us if you're interested!</p>
+ <Link
+ href={`/support/new?ref=${ref}&category=sales&subject=Project%20too%20old%20old%20for%20PITR`}
+ >
+ <a>
+ <Button type="default">Contact support</Button>
+ </a>
+ </Link>
+ </div>
+ }
+ icon={<IconAlertCircle strokeWidth={2} />}
+ />
) : (
<Radio.Group type="cards" className="billing-compute-radio">
{pitrDurationOptions.map((option: any) => {