Skip to content

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

Adjust PITR UI (#47821)

Joshen Lim0747af0afec6
diff --git a/apps/studio/components/interfaces/Database/Backups/PITR/PITRForm.tsx b/apps/studio/components/interfaces/Database/Backups/PITR/PITRForm.tsx
index 7ec3086fc3d..fe4b5335070 100644
--- a/apps/studio/components/interfaces/Database/Backups/PITR/PITRForm.tsx
+++ b/apps/studio/components/interfaces/Database/Backups/PITR/PITRForm.tsx
@@ -3,7 +3,7 @@ import { HelpCircle } from 'lucide-react'
import { useMemo, useState } from 'react'
import { Calendar, cn } from 'ui'
-import { Timezone } from './PITR.types'
+import { type Timezone } from './PITR.types'
import {
constrainDateToRange,
formatNumberToTwoDigits,
@@ -18,6 +18,7 @@ import InformationBox from '@/components/ui/InformationBox'
type Props = {
onSubmit: (data: {
+ selectedTimezone: Timezone
recoveryTimeTargetUnix: number
recoveryTimeString: string
recoveryTimeStringUtc: string
@@ -93,6 +94,7 @@ export function PITRForm({
const handleSubmit = () => {
onSubmit({
+ selectedTimezone,
recoveryTimeTargetUnix,
recoveryTimeString,
recoveryTimeStringUtc,
@@ -124,8 +126,9 @@ export function PITRForm({
</div>
}
>
- <div className="flex justify-between px-4 md:px-10 py-6 space-x-10">
- <div className="w-1/3 space-y-2">
+ <div className="flex flex-col gap-y-6 lg:flex-row lg:gap-y-0 justify-between px-4 md:px-10 py-6 lg:space-x-10">
+ <div className="w-full lg:w-1/3 space-y-2 py-2">
+ <p className="text-sm text-foreground">Select a date to restore to</p>
<Calendar
mode="single"
required={true}
@@ -139,6 +142,7 @@ export function PITRForm({
{ after: latestAvailableBackupAsDate },
]}
classNames={{
+ root: 'w-min px-0',
day: cn(
'[&:not(:has(:disabled))]:border [&:not(:has(:disabled))]:border-stronger not-last:border-r-0 [&:not(:has(:disabled))]:bg-overlay-hover',
'rounded-none'
@@ -155,7 +159,7 @@ export function PITRForm({
)}
</div>
- <div className="w-2/3">
+ <div className="w-full lg:w-2/3">
{!selectedDate ? (
<div className="h-full flex items-center justify-center">
<div className="mx-2">
@@ -169,18 +173,8 @@ export function PITRForm({
</div>
) : (
<div className="space-y-8 py-2">
- <div className="space-y-1">
- <p className="text-sm text-foreground-light">Date to restore to</p>
- <p className="text-3xl">
- <span>{dayjs(selectedDate).format('DD MMM YYYY')}</span>
- <span>
- , {formatNumberToTwoDigits(selectedTime.h)}:
- {formatNumberToTwoDigits(selectedTime.m)}:
- {formatNumberToTwoDigits(selectedTime.s)}
- </span>
- </p>
- </div>
- <div className="space-y-2">
+ <div className="flex flex-col gap-y-4">
+ <p className="text-sm text-foreground">Enter a time to restore to</p>
<div className="space-y-1">
<p className="text-sm text-foreground-light">Time zone</p>
<div className="w-[350px]">
@@ -193,6 +187,18 @@ export function PITRForm({
<div>
<div className="space-y-1">
<p className="text-sm text-foreground-light">Recovery time</p>
+ {isSelectedOnEarliestDay && (
+ <p className="text-sm text-foreground-lighter">
+ <strong>Earliest backup available for this date</strong>:{' '}
+ {earliestAvailableBackup.format('HH:mm:ss')}
+ </p>
+ )}
+ {isSelectedOnLatestDay && (
+ <p className="text-sm text-foreground-lighter">
+ <strong>Latest backup available for this date</strong>:{' '}
+ {latestAvailableBackup.format('HH:mm:ss')}
+ </p>
+ )}
<TimeInput
defaultTime={selectedTime}
minimumTime={
@@ -209,30 +215,26 @@ export function PITRForm({
}}
/>
</div>
-
- <p className="text-sm text-foreground-light mt-8">
- Enter a time within the available range to restore from. <br /> Backups are
- captured every 2 minutes, allowing you to enter a time and restore your
- database to the closest backup point. We'll match the time you enter to the
- closest backup within the 2-minute window
- </p>
- </div>
- <div className="mt-4! space-y-1">
- <h3 className="text-sm text-foreground-light"></h3>
- {isSelectedOnEarliestDay && (
- <p className="text-sm text-foreground-light">
- <strong>Earliest backup available for this date</strong>:{' '}
- {earliestAvailableBackup.format('HH:mm:ss')}
- </p>
- )}
- {isSelectedOnLatestDay && (
- <p className="text-sm text-foreground-light">
- <strong>Latest backup available for this date</strong>:{' '}
- {latestAvailableBackup.format('HH:mm:ss')}
- </p>
- )}
</div>
</div>
+
+ <div className="space-y-1">
+ <p className="text-sm text-foreground-light">Database will be restored to:</p>
+ <p className="text-3xl">
+ <span>{dayjs(selectedDate).format('DD MMM YYYY')}</span>
+ <span>
+ , {formatNumberToTwoDigits(selectedTime.h)}:
+ {formatNumberToTwoDigits(selectedTime.m)}:
+ {formatNumberToTwoDigits(selectedTime.s)}
+ </span>
+ </p>
+
+ <p className="text-sm text-foreground-lighter mt-4 text-balance">
+ Backups are captured every 2 minutes, allowing you to enter a time and restore
+ your database to the closest backup point. We'll match the time you enter to the
+ closest backup within the 2-minute window
+ </p>
+ </div>
</div>
)}
</div>
diff --git a/apps/studio/components/interfaces/Database/Backups/PITR/PITRSelection.tsx b/apps/studio/components/interfaces/Database/Backups/PITR/PITRSelection.tsx
index 5cc56874bb2..13533dd1844 100644
--- a/apps/studio/components/interfaces/Database/Backups/PITR/PITRSelection.tsx
+++ b/apps/studio/components/interfaces/Database/Backups/PITR/PITRSelection.tsx
@@ -45,6 +45,7 @@ export const PITRSelection = () => {
const [showConfirmation, setShowConfirmation] = useState(false)
const [selectedTimezone, setSelectedTimezone] = useState<Timezone>(getClientTimezone())
const [selectedRecoveryPoint, setSelectedRecoveryPoint] = useState<{
+ selectedTimezone: Timezone
recoveryTimeTargetUnix: number
recoveryTimeString: string
recoveryTimeStringUtc: string
@@ -99,11 +100,8 @@ export const PITRSelection = () => {
settings prior to starting a PITR restore.
</AlertDescription>
<div className="flex items-center gap-x-2 mt-2">
- {/* [Joshen] Ideally we have some links to a docs to explain why so */}
- <Button variant="default">
- <Link href={`/project/${ref}/settings/infrastructure`}>
- Infrastructure settings
- </Link>
+ <Button asChild variant="default">
+ <Link href={`/project/${ref}/database/replication`}>Manage read replicas</Link>
</Button>
</div>
</Alert>
@@ -136,7 +134,9 @@ export const PITRSelection = () => {
<p className="text-sm text-foreground-light">Your database will be restored to:</p>
<div className="py-2 flex flex-col gap-3">
<div>
- <p className="text-sm font-mono text-foreground-lighter">Local Time</p>
+ <p className="text-sm font-mono text-foreground-lighter">
+ {selectedRecoveryPoint?.selectedTimezone.text}
+ </p>
<p className="text-2xl">{selectedRecoveryPoint?.recoveryTimeString}</p>
</div>
<div>
diff --git a/apps/studio/components/interfaces/Database/Backups/PITR/TimezoneSelection.tsx b/apps/studio/components/interfaces/Database/Backups/PITR/TimezoneSelection.tsx
index 028bd48a27c..6a40d086032 100644
--- a/apps/studio/components/interfaces/Database/Backups/PITR/TimezoneSelection.tsx
+++ b/apps/studio/components/interfaces/Database/Backups/PITR/TimezoneSelection.tsx
@@ -40,10 +40,11 @@ export const TimezoneSelection = ({
role="combobox"
aria-expanded={open}
aria-controls={listboxId}
- className="w-[350px] justify-between"
+ className="w-[350px] justify-start"
size="small"
+ variant="default"
icon={<Globe />}
- iconRight={<ChevronsUpDown size={14} strokeWidth={1.5} />}
+ iconRight={<ChevronsUpDown size={14} strokeWidth={1.5} className="ml-auto" />}
>
{selectedTimezone
? timezoneOptions.find((option) => option === selectedTimezone.text)