The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Midway hooking up actual BE implementation for PITR
Joshen Lim367ac9e20a4f
diff --git a/studio/components/interfaces/Database/Backups/BackupsEmpty.tsx b/studio/components/interfaces/Database/Backups/BackupsEmpty.tsxnew file mode 100644index 00000000000..8d89f0abec5--- /dev/null+++ b/studio/components/interfaces/Database/Backups/BackupsEmpty.tsx@@ -0,0 +1,14 @@+import { IconInfo } from '@supabase/ui'++const BackupsEmpty = () => {+ 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">No backups created yet. Check again tomorrow.</p>+ </div>+ </div>+ )+}++export default BackupsEmptydiff --git a/studio/components/interfaces/Database/Backups/BackupsError.tsx b/studio/components/interfaces/Database/Backups/BackupsError.tsxnew file mode 100644index 00000000000..bc39eee1628--- /dev/null+++ b/studio/components/interfaces/Database/Backups/BackupsError.tsx@@ -0,0 +1,14 @@+import { IconInfo } from '@supabase/ui'++const BackupsError = () => {+ 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">Failed to retrieve backups for project. Please contact support.</p>+ </div>+ </div>+ )+}++export default BackupsErrordiff --git a/studio/components/interfaces/Database/Backups/BackupsList.tsx b/studio/components/interfaces/Database/Backups/BackupsList.tsxindex 0e0f95b7a18..74917eb790b 100644--- a/studio/components/interfaces/Database/Backups/BackupsList.tsx+++ b/studio/components/interfaces/Database/Backups/BackupsList.tsx@@ -1,14 +1,15 @@import { FC } from 'react'import { observer } from 'mobx-react-lite'-import { IconInfo } from '@supabase/ui'import { useStore } from 'hooks'-import { STRIPE_PRODUCT_IDS } from 'lib/constants'-import BackupItem from './BackupItem'import Loading from 'components/ui/Loading'import UpgradeToPro from 'components/ui/UpgradeToPro'import Panel from 'components/to-be-cleaned/Panel'+import BackupItem from './BackupItem'+import BackupsError from './BackupsError'+import BackupsEmpty from './BackupsEmpty'+interface Props {}const BackupsList: FC<Props> = ({}) => {@@ -16,11 +17,12 @@ const BackupsList: FC<Props> = ({}) => {const projectRef = ui.selectedProject?.ref || 'default'if (backups.isLoading) return <Loading />+ if (backups.error) return <BackupsError />- const { tierId } = backups.configuration+ const { tierKey } = backups.configurationconst sortedBackups = backups.list()- if (tierId === STRIPE_PRODUCT_IDS.FREE) {+ if (tierKey === 'FREE') {return (<UpgradeToProprimaryText="Free Plan does not include project backups."@@ -32,13 +34,8 @@ const BackupsList: FC<Props> = ({}) => {return (<div className="space-y-6">- {!sortedBackups?.length && tierId !== STRIPE_PRODUCT_IDS.FREE ? (- <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">No backups created yet. Check again tomorrow.</p>- </div>- </div>+ {!sortedBackups?.length && tierKey !== 'FREE' ? (+ <BackupsEmpty />) : (<Panel>{sortedBackups?.map((x: any, i: number) => {diff --git a/studio/components/interfaces/Database/Backups/PITRBackupSelection/index.tsx b/studio/components/interfaces/Database/Backups/PITRBackupSelection/index.tsxindex c6cbe97bf8f..9f4e59121e8 100644--- a/studio/components/interfaces/Database/Backups/PITRBackupSelection/index.tsx+++ b/studio/components/interfaces/Database/Backups/PITRBackupSelection/index.tsx@@ -1,10 +1,14 @@import dayjs from 'dayjs'import { FC, FormEvent, useState } from 'react'-import { IconInfo, IconSearch, Input, Listbox, Popover, Button, Modal } from '@supabase/ui'+import { IconSearch, Input, Listbox, Popover, Button, Modal } from '@supabase/ui'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,@@ -26,22 +30,19 @@ const PITRBackupSelection: FC<Props> = () => {const [recoveryPoint, setRecoveryPoint] = useState<string>()// Mock new properties, to delete after BE is fully ready- const configuration = {- ...backups.configuration,- region: 'ap-southeast-1',- walg_enabled: true,- physicalBackupData: {- earliestPhysicalBackupDateUnix: 1654054628338,- latestPhysicalBackupDateUnix: 1654065771390,- },- }+ const { configuration } = backups+ console.log('Configuration', configuration)const projectRef = ui.selectedProject?.ref ?? 'default'const hasPhysicalBackups =configuration.physicalBackupData.earliestPhysicalBackupDateUnix !== null &&configuration.physicalBackupData.latestPhysicalBackupDateUnix !== null- if (!isAvailable) {+ if (backups.isLoading) {+ return <Loading />+ } else if (backups.error) {+ return <BackupsError />+ } else if (!isAvailable) {return (<div className="flex items-center justify-center rounded border border-gray-500 bg-gray-300 py-8"><p className="text-scale-1000 text-sm">Coming soon</p>@@ -57,14 +58,7 @@ const PITRBackupSelection: FC<Props> = () => {/>)} else if (!hasPhysicalBackups) {- 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">No backups created yet. Check again tomorrow.</p>- </div>- </div>- )+ return <BackupsEmpty />}const timezoneOptions =diff --git a/studio/pages/api/database/[ref]/backups.ts b/studio/pages/api/database/[ref]/backups.tsindex bc4d6b8db43..32e883b78d4 100644--- a/studio/pages/api/database/[ref]/backups.ts+++ b/studio/pages/api/database/[ref]/backups.ts@@ -16,5 +16,5 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {}const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {- return res.status(200).json({ tierId: undefined, backups: [] })+ return res.status(200).json({ tierKey: 'FREE', backups: [] })}diff --git a/studio/stores/app/DatabaseStore.ts b/studio/stores/app/DatabaseStore.tsindex 22f5672e817..9204961d007 100644--- a/studio/stores/app/DatabaseStore.ts+++ b/studio/stores/app/DatabaseStore.ts@@ -6,9 +6,6 @@ import { constructHeaders } from 'lib/api/apiHelpers'import PostgresMetaInterface, { IPostgresMetaInterface } from '../common/PostgresMetaInterface'export interface IDatabaseStore extends IPostgresMetaInterface<any> {- getBackups: (- projectRef: string- ) => Promise<{ tierId: any; backups: any[] } | { error: ResponseError }>getPoolingConfiguration: (projectRef: string) => Promise<any | { error: ResponseError }>}@@ -24,18 +21,6 @@ export default class DatabaseStore extends PostgresMetaInterface<any> {super(rootStore, dataUrl, headers, options)}- async getBackups(projectRef: string) {- try {- const url = `${this.url}/${projectRef}/backups`- const headers = constructHeaders(this.headers)- const response = await get(url, { headers })- if (response.error) throw response.error- return response- } catch (error: any) {- return { error }- }- }-async getPoolingConfiguration(projectRef: string) {try {// Need to use project ref -> shouldn;t need to pass it in via argument