The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add abac for db backups
Joshen Lim72145018b70a
diff --git a/studio/components/interfaces/Database/Backups/BackupItem.tsx b/studio/components/interfaces/Database/Backups/BackupItem.tsxindex ae530eb0972..09462c19e8e 100644--- a/studio/components/interfaces/Database/Backups/BackupItem.tsx+++ b/studio/components/interfaces/Database/Backups/BackupItem.tsx@@ -3,8 +3,9 @@ import { FC, useState } from 'react'import { useRouter } from 'next/router'import { observer } from 'mobx-react-lite'import { Badge, Button, IconDownload } from '@supabase/ui'+import { PermissionAction } from '@supabase/shared-types/out/constants'-import { useStore } from 'hooks'+import { useStore, checkPermissions } from 'hooks'import { API_URL, PROJECT_STATUS } from 'lib/constants'import { post } from 'lib/common/fetch'import { confirmAlert } from 'components/to-be-cleaned/ModalsDeprecated/ConfirmModal'@@ -23,6 +24,10 @@ const BackupItem: FC<Props> = ({ projectRef, backup, index }) => {const [isRestoring, setRestoring] = useState<boolean>(false)const projectId = ui.selectedProject?.id ?? -1+ const canTriggerScheduledBackups = checkPermissions(+ PermissionAction.INFRA_EXECUTE,+ 'queue_job.restore.prepare'+ )async function restore(backup: any) {setRestoring(true)@@ -90,14 +95,18 @@ const BackupItem: FC<Props> = ({ projectRef, backup, index }) => {return (<div className="flex space-x-4">{backup.data.canRestore && (- <Button type="default" disabled={isRestoring || isDownloading} onClick={onRestoreClick}>+ <Button+ type="default"+ disabled={!canTriggerScheduledBackups || isRestoring || isDownloading}+ onClick={onRestoreClick}+ >Restore</Button>)}<Buttontype="default"- disabled={isRestoring || isDownloading}+ disabled={!canTriggerScheduledBackups || isRestoring || isDownloading}onClick={() => download(backup)}loading={isDownloading}icon={<IconDownload />}diff --git a/studio/components/interfaces/Database/Backups/BackupsList.tsx b/studio/components/interfaces/Database/Backups/BackupsList.tsxindex fad655435fc..6ee1a329e3c 100644--- a/studio/components/interfaces/Database/Backups/BackupsList.tsx+++ b/studio/components/interfaces/Database/Backups/BackupsList.tsx@@ -1,7 +1,7 @@import { FC } from 'react'import { observer } from 'mobx-react-lite'-import { useStore } from 'hooks'+import { useStore, checkPermissions } from 'hooks'import Loading from 'components/ui/Loading'import UpgradeToPro from 'components/ui/UpgradeToPro'import Panel from 'components/ui/Panel'@@ -9,12 +9,19 @@ import Panel from 'components/ui/Panel'import BackupItem from './BackupItem'import BackupsError from './BackupsError'import BackupsEmpty from './BackupsEmpty'+import { PermissionAction } from '@supabase/shared-types/out/constants'+import InformationBox from 'components/ui/InformationBox'+import { IconAlertCircle } from '@supabase/ui'interface Props {}const BackupsList: FC<Props> = ({}) => {const { ui, backups } = useStore()const projectRef = ui.selectedProject?.ref || 'default'+ const canTriggerScheduledBackups = checkPermissions(+ PermissionAction.INFRA_EXECUTE,+ 'queue_job.restore.prepare'+ )if (backups.isLoading) return <Loading />if (backups.error) return <BackupsError />@@ -37,11 +44,19 @@ const BackupsList: FC<Props> = ({}) => {{!sortedBackups?.length && tierKey !== 'FREE' ? (<BackupsEmpty />) : (- <Panel>- {sortedBackups?.map((x: any, i: number) => {- return <BackupItem key={x.id} projectRef={projectRef} backup={x} index={i} />- })}- </Panel>+ <>+ {!canTriggerScheduledBackups && (+ <InformationBox+ icon={<IconAlertCircle className="text-scale-1100" strokeWidth={2} />}+ title="You need additional permissions to trigger a scheduled backup"+ />+ )}+ <Panel>+ {sortedBackups?.map((x: any, i: number) => {+ return <BackupItem key={x.id} projectRef={projectRef} backup={x} index={i} />+ })}+ </Panel>+ </>)}</div>)diff --git a/studio/components/interfaces/Database/Backups/PITRBackupSelection/PITRBackupSelection.tsx b/studio/components/interfaces/Database/Backups/PITRBackupSelection/PITRBackupSelection.tsxnew file mode 100644index 00000000000..b906f47d6ac--- /dev/null+++ b/studio/components/interfaces/Database/Backups/PITRBackupSelection/PITRBackupSelection.tsx@@ -0,0 +1,330 @@+import dayjs from 'dayjs'+import Link from 'next/link'+import { FC, FormEvent, useState } from 'react'+import { useRouter } from 'next/router'+import { PermissionAction } from '@supabase/shared-types/out/constants'+import {+ IconSearch,+ IconInfo,+ Input,+ Listbox,+ Popover,+ Button,+ Modal,+ IconAlertCircle,+} from '@supabase/ui'++import { post } from 'lib/common/fetch'+import { API_URL, PROJECT_STATUS } from 'lib/constants'+import { useStore, useFlag, checkPermissions } from 'hooks'+import Loading from 'components/ui/Loading'+import ConfirmationModal from 'components/ui/ConfirmationModal'++import BackupsError from '../BackupsError'+import BackupsEmpty from '../BackupsEmpty'+import { ALL_TIMEZONES } from './PITRBackupSelection.constants'+import {+ getClientTimezone,+ getTimezoneOffsetText,+ convertTimeStringtoUnixS,+} from './PITRBackupSelection.utils'+import InformationBox from 'components/ui/InformationBox'++interface Props {}++const PITRBackupSelection: FC<Props> = () => {+ const router = useRouter()+ const { app, ui, backups } = useStore()+ const isAvailable = useFlag('pitrBackups')++ const projectId = ui.selectedProject?.id ?? -1+ const projectRef = ui.selectedProject?.ref ?? 'default'++ const canTriggerPhysicalBackups = checkPermissions(+ PermissionAction.INFRA_EXECUTE,+ 'queue_job.restore.prepare'+ )++ if (!isAvailable) {+ return (+ <div className="block w-full rounded border border-gray-400 border-opacity-50 bg-gray-300 p-3">+ <div className="flex space-x-3">+ <IconInfo size={20} strokeWidth={1.5} />+ <p className="text-scale-1100 text-sm">+ Coming soon - Point in time backups is an Enterprise feature. Reach out to us{' '}+ <Link href={`/support/new?ref=${projectRef}&category=sales`}>+ <a className="text-brand-900">here</a>+ </Link>{' '}+ if you're interested!+ </p>+ </div>+ </div>+ )+ }++ const [searchString, setSearchString] = useState<string>('')+ const [selectedTimezone, setSelectedTimezone] = useState<any>(getClientTimezone())+ const [showConfirmation, setShowConfirmation] = useState<boolean>(false)++ const [errors, setErrors] = useState<any>()+ const [recoveryPoint, setRecoveryPoint] = useState<string>()++ const { configuration } = backups++ if (backups.isLoading) {+ return <Loading />+ } else if (backups.error) {+ return <BackupsError />+ }++ const hasPhysicalBackups =+ configuration.physicalBackupData.earliestPhysicalBackupDateUnix !== null &&+ configuration.physicalBackupData.latestPhysicalBackupDateUnix !== null &&+ configuration.physicalBackupData.earliestPhysicalBackupDateUnix !==+ configuration.physicalBackupData.latestPhysicalBackupDateUnix++ if (!configuration.walg_enabled) {+ return (+ <div className="block w-full rounded border border-gray-400 border-opacity-50 bg-gray-300 p-3">+ <div className="flex space-x-3">+ <IconInfo size={20} strokeWidth={1.5} />+ <p className="text-sm">+ Point in time backups is an Enterprise feature. Reach out to us{' '}+ <Link href={`/support/new?ref=${projectRef}&category=sales`}>+ <a className="text-brand-900">here</a>+ </Link>{' '}+ if you're interested!+ </p>+ </div>+ </div>+ )+ } else if (!hasPhysicalBackups) {+ return <BackupsEmpty />+ }++ const timezoneOptions =+ searchString.length > 0+ ? ALL_TIMEZONES.map((option) => option.text).filter((option) =>+ option.toLowerCase().includes(searchString.toLowerCase())+ )+ : ALL_TIMEZONES.map((option) => option.text)++ const earliestAvailableBackup = dayjs+ .unix(configuration.physicalBackupData.earliestPhysicalBackupDateUnix)+ .tz(selectedTimezone.utc[0])+ .format('YYYY-MM-DDTHH:mm:ss')++ const latestAvailableBackup = dayjs+ .unix(configuration.physicalBackupData.latestPhysicalBackupDateUnix)+ .tz(selectedTimezone.utc[0])+ .format('YYYY-MM-DDTHH:mm:ss')++ const onSubmit = (e: FormEvent<HTMLFormElement>) => {+ e.preventDefault()++ // Validation+ if (!recoveryPoint) {+ setErrors({ recoveryPoint: 'Please enter a date to recover your project from' })+ } else {+ const recoveryTimeTargetUnix = convertTimeStringtoUnixS(recoveryPoint, selectedTimezone)+ const { earliestPhysicalBackupDateUnix, latestPhysicalBackupDateUnix } =+ configuration.physicalBackupData++ const isOutOfRange =+ recoveryTimeTargetUnix < earliestPhysicalBackupDateUnix ||+ recoveryTimeTargetUnix > latestPhysicalBackupDateUnix++ if (isOutOfRange) {+ setErrors({+ recoveryPoint: 'Selected date is out of range for available points of recovery',+ })+ } else {+ setErrors(undefined)+ setShowConfirmation(true)+ }+ }+ }++ const onConfirmRestore = async () => {+ if (!recoveryPoint) return++ const recoveryTimeTargetUnix = convertTimeStringtoUnixS(recoveryPoint, selectedTimezone)+ const { error } = await post(`${API_URL}/database/${projectRef}/backups/pitr`, {+ recovery_time_target_unix: recoveryTimeTargetUnix,+ })++ if (error) {+ ui.setNotification({+ error,+ category: 'error',+ message: `Point in time recovery for project failed`,+ })+ setShowConfirmation(false)+ } else {+ setTimeout(() => {+ setShowConfirmation(false)+ app.onProjectStatusUpdated(projectId, PROJECT_STATUS.RESTORING)+ ui.setNotification({+ category: 'success',+ message: `Restoring database back to ${dayjs(recoveryPoint).format(+ 'DD MMM YYYY, HH:mm:ss'+ )} (+ ${getTimezoneOffsetText(selectedTimezone)})`,+ })+ router.push(`/project/${projectRef}`)+ }, 3000)+ }+ }++ return (+ <div className="space-y-6">+ {!canTriggerPhysicalBackups && (+ <InformationBox+ icon={<IconAlertCircle className="text-scale-1100" strokeWidth={2} />}+ title="You need additional permissions to trigger a scheduled backup"+ />+ )}+ <form onSubmit={onSubmit}>+ <div className="space-y-4">+ <div className="space-y-4 rounded border border-gray-400 border-opacity-50 bg-gray-300 py-3">+ <div className="space-y-4 py-2">+ <div className="flex justify-between space-x-8">+ <p className="w-2/5 pl-4 text-sm">Select timezone</p>+ <div className="w-3/5 px-4">+ <Listbox+ value={selectedTimezone.text}+ onChange={(text) => {+ const selectedTimezone = ALL_TIMEZONES.find((option) => option.text === text)+ setSelectedTimezone(selectedTimezone)+ }}+ onBlur={() => setSearchString('')}+ >+ <div+ className={[+ 'fixed top-0 flex w-full items-center',+ 'rounded-t-md border-b border-gray-600 bg-gray-500',+ 'mb-4 space-x-2 px-4 py-2',+ ].join(' ')}+ style={{ zIndex: 1 }}+ >+ <IconSearch size={14} />+ <input+ autoFocus+ className="placeholder-scale-1000 w-72 bg-transparent text-sm outline-none"+ value={searchString}+ placeholder={''}+ onChange={(e: FormEvent<HTMLInputElement>) =>+ setSearchString(e.currentTarget.value)+ }+ />+ </div>+ {/* Whitespace to shift listbox options down for searchfield */}+ <div className="h-8" />+ {timezoneOptions.map((option) => {+ return (+ <Listbox.Option key={option} label={option} value={option}>+ <div>{option}</div>+ </Listbox.Option>+ )+ })}+ {timezoneOptions.length === 0 && (+ <Listbox.Option disabled key="no-results" label="" value="">+ No timezones found+ </Listbox.Option>+ )}+ </Listbox>+ </div>+ </div>+ <div className="flex justify-between space-x-8">+ <div className="w-2/5 space-y-2 pl-4">+ <p className="text-sm">Earliest point of recovery</p>+ </div>+ <div className="w-3/5">+ <Input+ readOnly+ disabled+ step={1}+ type="datetime-local"+ className="px-4"+ value={earliestAvailableBackup}+ />+ </div>+ </div>+ <div className="flex justify-between space-x-8">+ <div className="w-2/5 space-y-2 pl-4">+ <p className="text-sm">Latest point of recovery</p>+ </div>+ <div className="w-3/5">+ <Input+ readOnly+ disabled+ step={1}+ type="datetime-local"+ className="px-4"+ value={latestAvailableBackup}+ />+ </div>+ </div>+ </div>+ <Popover.Seperator />+ <div className="flex justify-between space-x-8 py-2">+ <div className="w-2/5 space-y-2 pl-4">+ <p className="text-sm">Recovery point</p>+ <p className="text-scale-1100 text-sm">+ Select a date and time that you would like to restore your project to+ </p>+ </div>+ <div className="w-3/5">+ <Input+ step={1}+ type="datetime-local"+ error={errors?.recoveryPoint}+ className="px-4"+ onChange={(e) => {+ setErrors(undefined)+ setRecoveryPoint(e.target.value)+ }}+ />+ </div>+ </div>+ <Popover.Seperator />+ <div className="flex items-center justify-end px-4">+ <Button type="default" htmlType="submit">+ Restore+ </Button>+ </div>+ </div>+ </div>+ </form>+ <ConfirmationModal+ visible={showConfirmation}+ size="medium"+ header="Confirm to restore"+ children={+ <Modal.Content>+ <div className="space-y-2 py-4">+ <div className="space-y-1">+ <p className="text-scale-1100 text-sm">+ Are you sure you want to restore your database from:+ </p>+ <p className="text-scale-1200 text-sm">+ {dayjs(recoveryPoint).format('DD MMM YYYY, HH:mm:ss')} (+ {getTimezoneOffsetText(selectedTimezone)})?+ </p>+ </div>+ <p className="text-scale-1100 text-sm">+ This will destroy any new data written since this backup was made.+ </p>+ </div>+ </Modal.Content>+ }+ buttonLabel="Restore"+ buttonLoadingLabel="Restoring"+ onSelectCancel={() => setShowConfirmation(false)}+ onSelectConfirm={onConfirmRestore}+ />+ </div>+ )+}++export default PITRBackupSelectiondiff --git a/studio/components/interfaces/Database/Backups/PITRBackupSelection/index.tsx b/studio/components/interfaces/Database/Backups/PITRBackupSelection/index.tsxindex 416cfce7beb..ff7fdd9db78 100644--- a/studio/components/interfaces/Database/Backups/PITRBackupSelection/index.tsx+++ b/studio/components/interfaces/Database/Backups/PITRBackupSelection/index.tsx@@ -1,309 +1,2 @@-import dayjs from 'dayjs'-import Link from 'next/link'-import { FC, FormEvent, useState } from 'react'-import { useRouter } from 'next/router'-import { IconSearch, IconInfo, Input, Listbox, Popover, Button, Modal } from '@supabase/ui'--import { post } from 'lib/common/fetch'-import { API_URL, PROJECT_STATUS } from 'lib/constants'-import { useStore, useFlag } from 'hooks'-import Loading from 'components/ui/Loading'-import UpgradeToPro from 'components/ui/UpgradeToPro'-import ConfirmationModal from 'components/ui/ConfirmationModal'--import BackupsError from '../BackupsError'-import BackupsEmpty from '../BackupsEmpty'-import { ALL_TIMEZONES } from './PITRBackupSelection.constants'-import {- getClientTimezone,- getTimezoneOffsetText,- convertTimeStringtoUnixS,-} from './PITRBackupSelection.utils'--interface Props {}--const PITRBackupSelection: FC<Props> = () => {- const router = useRouter()- const { app, ui, backups } = useStore()- const isAvailable = useFlag('pitrBackups')-- const projectId = ui.selectedProject?.id ?? -1- const projectRef = ui.selectedProject?.ref ?? 'default'-- if (!isAvailable) {- return (- <div className="block w-full rounded border border-gray-400 border-opacity-50 bg-gray-300 p-3">- <div className="flex space-x-3">- <IconInfo size={20} strokeWidth={1.5} />- <p className="text-scale-1100 text-sm">- Coming soon - Point in time backups is an Enterprise feature. Reach out to us{' '}- <Link href={`/support/new?ref=${projectRef}&category=sales`}>- <a className="text-brand-900">here</a>- </Link>{' '}- if you're interested!- </p>- </div>- </div>- )- }-- const [searchString, setSearchString] = useState<string>('')- const [selectedTimezone, setSelectedTimezone] = useState<any>(getClientTimezone())- const [showConfirmation, setShowConfirmation] = useState<boolean>(false)-- const [errors, setErrors] = useState<any>()- const [recoveryPoint, setRecoveryPoint] = useState<string>()-- const { configuration } = backups-- if (backups.isLoading) {- return <Loading />- } else if (backups.error) {- return <BackupsError />- }-- const hasPhysicalBackups =- configuration.physicalBackupData.earliestPhysicalBackupDateUnix !== null &&- configuration.physicalBackupData.latestPhysicalBackupDateUnix !== null &&- configuration.physicalBackupData.earliestPhysicalBackupDateUnix !==- configuration.physicalBackupData.latestPhysicalBackupDateUnix-- if (!configuration.walg_enabled) {- return (- <div className="block w-full rounded border border-gray-400 border-opacity-50 bg-gray-300 p-3">- <div className="flex space-x-3">- <IconInfo size={20} strokeWidth={1.5} />- <p className="text-sm">- Point in time backups is an Enterprise feature. Reach out to us{' '}- <Link href={`/support/new?ref=${projectRef}&category=sales`}>- <a className="text-brand-900">here</a>- </Link>{' '}- if you're interested!- </p>- </div>- </div>- )- } else if (!hasPhysicalBackups) {- return <BackupsEmpty />- }-- const timezoneOptions =- searchString.length > 0- ? ALL_TIMEZONES.map((option) => option.text).filter((option) =>- option.toLowerCase().includes(searchString.toLowerCase())- )- : ALL_TIMEZONES.map((option) => option.text)-- const earliestAvailableBackup = dayjs- .unix(configuration.physicalBackupData.earliestPhysicalBackupDateUnix)- .tz(selectedTimezone.utc[0])- .format('YYYY-MM-DDTHH:mm:ss')-- const latestAvailableBackup = dayjs- .unix(configuration.physicalBackupData.latestPhysicalBackupDateUnix)- .tz(selectedTimezone.utc[0])- .format('YYYY-MM-DDTHH:mm:ss')-- const onSubmit = (e: FormEvent<HTMLFormElement>) => {- e.preventDefault()-- // Validation- if (!recoveryPoint) {- setErrors({ recoveryPoint: 'Please enter a date to recover your project from' })- } else {- const recoveryTimeTargetUnix = convertTimeStringtoUnixS(recoveryPoint, selectedTimezone)- const { earliestPhysicalBackupDateUnix, latestPhysicalBackupDateUnix } =- configuration.physicalBackupData-- const isOutOfRange =- recoveryTimeTargetUnix < earliestPhysicalBackupDateUnix ||- recoveryTimeTargetUnix > latestPhysicalBackupDateUnix-- if (isOutOfRange) {- setErrors({- recoveryPoint: 'Selected date is out of range for available points of recovery',- })- } else {- setErrors(undefined)- setShowConfirmation(true)- }- }- }-- const onConfirmRestore = async () => {- if (!recoveryPoint) return-- const recoveryTimeTargetUnix = convertTimeStringtoUnixS(recoveryPoint, selectedTimezone)- const { error } = await post(`${API_URL}/database/${projectRef}/backups/pitr`, {- recovery_time_target_unix: recoveryTimeTargetUnix,- })-- if (error) {- ui.setNotification({- error,- category: 'error',- message: `Point in time recovery for project failed`,- })- setShowConfirmation(false)- } else {- setTimeout(() => {- setShowConfirmation(false)- app.onProjectStatusUpdated(projectId, PROJECT_STATUS.RESTORING)- ui.setNotification({- category: 'success',- message: `Restoring database back to ${dayjs(recoveryPoint).format(- 'DD MMM YYYY, HH:mm:ss'- )} (- ${getTimezoneOffsetText(selectedTimezone)})`,- })- router.push(`/project/${projectRef}`)- }, 3000)- }- }-- return (- <>- <form onSubmit={onSubmit}>- <div className="space-y-4">- <div className="space-y-4 rounded border border-gray-400 border-opacity-50 bg-gray-300 py-3">- <div className="space-y-4 py-2">- <div className="flex justify-between space-x-8">- <p className="w-2/5 pl-4 text-sm">Select timezone</p>- <div className="w-3/5 px-4">- <Listbox- value={selectedTimezone.text}- onChange={(text) => {- const selectedTimezone = ALL_TIMEZONES.find((option) => option.text === text)- setSelectedTimezone(selectedTimezone)- }}- onBlur={() => setSearchString('')}- >- <div- className={[- 'fixed top-0 flex w-full items-center',- 'rounded-t-md border-b border-gray-600 bg-gray-500',- 'mb-4 space-x-2 px-4 py-2',- ].join(' ')}- style={{ zIndex: 1 }}- >- <IconSearch size={14} />- <input- autoFocus- className="placeholder-scale-1000 w-72 bg-transparent text-sm outline-none"- value={searchString}- placeholder={''}- onChange={(e: FormEvent<HTMLInputElement>) =>- setSearchString(e.currentTarget.value)- }- />- </div>- {/* Whitespace to shift listbox options down for searchfield */}- <div className="h-8" />- {timezoneOptions.map((option) => {- return (- <Listbox.Option key={option} label={option} value={option}>- <div>{option}</div>- </Listbox.Option>- )- })}- {timezoneOptions.length === 0 && (- <Listbox.Option disabled key="no-results" label="" value="">- No timezones found- </Listbox.Option>- )}- </Listbox>- </div>- </div>- <div className="flex justify-between space-x-8">- <div className="w-2/5 space-y-2 pl-4">- <p className="text-sm">Earliest point of recovery</p>- </div>- <div className="w-3/5">- <Input- readOnly- disabled- step={1}- type="datetime-local"- className="px-4"- value={earliestAvailableBackup}- />- </div>- </div>- <div className="flex justify-between space-x-8">- <div className="w-2/5 space-y-2 pl-4">- <p className="text-sm">Latest point of recovery</p>- </div>- <div className="w-3/5">- <Input- readOnly- disabled- step={1}- type="datetime-local"- className="px-4"- value={latestAvailableBackup}- />- </div>- </div>- </div>- <Popover.Seperator />- <div className="flex justify-between space-x-8 py-2">- <div className="w-2/5 space-y-2 pl-4">- <p className="text-sm">Recovery point</p>- <p className="text-scale-1100 text-sm">- Select a date and time that you would like to restore your project to- </p>- </div>- <div className="w-3/5">- <Input- step={1}- type="datetime-local"- error={errors?.recoveryPoint}- className="px-4"- onChange={(e) => {- setErrors(undefined)- setRecoveryPoint(e.target.value)- }}- />- </div>- </div>- <Popover.Seperator />- <div className="flex items-center justify-end px-4">- <Button type="default" htmlType="submit">- Restore- </Button>- </div>- </div>- </div>- </form>- <ConfirmationModal- visible={showConfirmation}- size="medium"- header="Confirm to restore"- children={- <Modal.Content>- <div className="space-y-2 py-4">- <div className="space-y-1">- <p className="text-scale-1100 text-sm">- Are you sure you want to restore your database from:- </p>- <p className="text-scale-1200 text-sm">- {dayjs(recoveryPoint).format('DD MMM YYYY, HH:mm:ss')} (- {getTimezoneOffsetText(selectedTimezone)})?- </p>- </div>- <p className="text-scale-1100 text-sm">- This will destroy any new data written since this backup was made.- </p>- </div>- </Modal.Content>- }- buttonLabel="Restore"- buttonLoadingLabel="Restoring"- onSelectCancel={() => setShowConfirmation(false)}- onSelectConfirm={onConfirmRestore}- />- </>- )-}-+import PITRBackupSelection from './PITRBackupSelection'export default PITRBackupSelectiondiff --git a/studio/pages/project/[ref]/database/backups/pitr.tsx b/studio/pages/project/[ref]/database/backups/pitr.tsxindex 65985343f81..75991a421ae 100644--- a/studio/pages/project/[ref]/database/backups/pitr.tsx+++ b/studio/pages/project/[ref]/database/backups/pitr.tsx@@ -1,11 +1,13 @@import { useRouter } from 'next/router'import { observer } from 'mobx-react-lite'import { Tabs } from '@supabase/ui'+import { PermissionAction } from '@supabase/shared-types/out/constants'-import { useStore } from 'hooks'+import { useStore, checkPermissions } from 'hooks'import { DatabaseLayout } from 'components/layouts'import { PITRBackupSelection } from 'components/interfaces/Database'import { NextPageWithLayout } from 'types'+import NoPermission from 'components/ui/NoPermission'const DatabaseScheduledBackups: NextPageWithLayout = () => {const { ui } = useStore()@@ -13,6 +15,8 @@ const DatabaseScheduledBackups: NextPageWithLayout = () => {const ref = ui.selectedProject?.ref ?? 'default'+ const canReadPhysicalBackups = checkPermissions(PermissionAction.READ, 'physical_backups')+return (<div className="mx-auto max-w-4xl space-y-6 px-5 pt-12 pb-20"><h3 className="text-scale-1200 text-xl">Backups</h3>@@ -32,7 +36,11 @@ const DatabaseScheduledBackups: NextPageWithLayout = () => {<p className="text-scale-1100 text-sm">Restore your project from a specific date and time.</p>- <PITRBackupSelection />+ {canReadPhysicalBackups ? (+ <PITRBackupSelection />+ ) : (+ <NoPermission resourceText="view PITR backups" />+ )}</div></div>)diff --git a/studio/pages/project/[ref]/database/backups/scheduled.tsx b/studio/pages/project/[ref]/database/backups/scheduled.tsxindex 2b8cfefd74d..07b30249b2a 100644--- a/studio/pages/project/[ref]/database/backups/scheduled.tsx+++ b/studio/pages/project/[ref]/database/backups/scheduled.tsx@@ -1,17 +1,21 @@import { useRouter } from 'next/router'import { observer } from 'mobx-react-lite'import { Tabs } from '@supabase/ui'+import { PermissionAction } from '@supabase/shared-types/out/constants'-import { useStore } from 'hooks'+import { NextPageWithLayout } from 'types'+import { checkPermissions, useStore } from 'hooks'import { DatabaseLayout } from 'components/layouts'import { BackupsList } from 'components/interfaces/Database'-import { NextPageWithLayout } from 'types'+import NoPermission from 'components/ui/NoPermission'const DatabaseScheduledBackups: NextPageWithLayout = () => {const { ui } = useStore()const router = useRouter()const ref = ui.selectedProject?.ref+ const canReadScheduledBackups = checkPermissions(PermissionAction.READ, 'back_ups')+return (<div className="mx-auto max-w-4xl space-y-6 px-5 pt-12 pb-20"><h3 className="text-scale-1200 text-xl">Backups</h3>@@ -32,7 +36,11 @@ const DatabaseScheduledBackups: NextPageWithLayout = () => {Projects are backed up daily around midnight of your project's region and can be restoredat any time.</p>- <BackupsList />+ {canReadScheduledBackups ? (+ <BackupsList />+ ) : (+ <NoPermission resourceText="view scheduled backups" />+ )}</div></div>)