mirror of
https://github.com/supabase/supabase.git
synced 2026-07-10 17:10:56 -04:00
0747af0afe
## Context Original intention was to fix the PITR UI for smaller viewports, but realised that the layout of the UI could be improved as well. (Tbh this UI could do with a bit of revisiting, but just making patches for now to improve what's existing) Fixes also apply to the restore to new project page since they share the same component ## Changes involved - Am opting to change the layout of the UI a little such that date selection is on the left, and time selection is up top - Fits the user flow a bit better - you select the parameters you want, and the final message at the bottom is the summary <img width="1033" height="525" alt="image" src="https://github.com/user-attachments/assets/614c0327-f5db-4e1f-a2a1-ae8a9ea89978" /> - In the confirmation dialog, we were originally showing the top label as "Local time" which I feel is inaccurate especially if the user has selected a different timezone from where they're located at. - Opting to display the full name of the selected timezone instead <img width="546" height="261" alt="image" src="https://github.com/user-attachments/assets/cd8838a1-8476-4492-bc86-cac229685e5a" /> - RE mobile layout - am currently just opting to have them in a column fashion although I feel like this isn't ideal either (requires revisiting of the UI as a whole to adjust the layout on desktop too) - e.g the Date picker here could be a popover like Unified Logs to streamline what is essentially a form <img width="507" height="831" alt="image" src="https://github.com/user-attachments/assets/c8e055bd-49c3-4d0a-9d8c-e54f53e9fcb4" /> - Also fixed the CTA URL for read replicas, was still pointing to /settings/infrastructure, should point to database/replication <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Point-in-time recovery now includes the selected timezone throughout the restore workflow. * Restore confirmations display the chosen timezone and a clear summary of the target recovery date and time. * Recovery details now show the earliest and latest available backups for the selected date, including the two-minute matching window. * **Bug Fixes** * Updated the read-replica management link to direct users to database replication settings. * **Style** * Improved restore form layout, calendar presentation, and timezone selector alignment. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
93 lines
2.8 KiB
TypeScript
93 lines
2.8 KiB
TypeScript
import { CheckIcon, ChevronsUpDown, Globe } from 'lucide-react'
|
|
import { useId, useState } from 'react'
|
|
import {
|
|
Button,
|
|
cn,
|
|
Command,
|
|
CommandEmpty,
|
|
CommandGroup,
|
|
CommandInput,
|
|
CommandItem,
|
|
CommandList,
|
|
Popover,
|
|
PopoverContent,
|
|
PopoverTrigger,
|
|
ScrollArea,
|
|
} from 'ui'
|
|
|
|
import { ALL_TIMEZONES } from './PITR.constants'
|
|
import type { Timezone } from './PITR.types'
|
|
|
|
interface TimezoneSelectionProps {
|
|
selectedTimezone: Timezone
|
|
onSelectTimezone: (timezone: Timezone) => void
|
|
}
|
|
|
|
export const TimezoneSelection = ({
|
|
selectedTimezone,
|
|
onSelectTimezone,
|
|
}: TimezoneSelectionProps) => {
|
|
const [open, setOpen] = useState(false)
|
|
const listboxId = useId()
|
|
|
|
const timezoneOptions = ALL_TIMEZONES.map((option) => option.text)
|
|
|
|
return (
|
|
<div className="w-full">
|
|
<Popover open={open} onOpenChange={setOpen}>
|
|
<PopoverTrigger asChild>
|
|
<Button
|
|
role="combobox"
|
|
aria-expanded={open}
|
|
aria-controls={listboxId}
|
|
className="w-[350px] justify-start"
|
|
size="small"
|
|
variant="default"
|
|
icon={<Globe />}
|
|
iconRight={<ChevronsUpDown size={14} strokeWidth={1.5} className="ml-auto" />}
|
|
>
|
|
{selectedTimezone
|
|
? timezoneOptions.find((option) => option === selectedTimezone.text)
|
|
: 'Select timezone...'}
|
|
</Button>
|
|
</PopoverTrigger>
|
|
<PopoverContent id={listboxId} className="w-[350px] p-0">
|
|
<Command>
|
|
<CommandInput placeholder="Search timezone..." className="h-9" />
|
|
<CommandList>
|
|
<CommandEmpty>No timezones found...</CommandEmpty>
|
|
<CommandGroup>
|
|
<ScrollArea className="h-72">
|
|
{timezoneOptions.map((option) => (
|
|
<CommandItem
|
|
key={option}
|
|
value={option}
|
|
onSelect={(text) => {
|
|
const selectedTimezone = ALL_TIMEZONES.find(
|
|
(option) => option.text === text
|
|
)
|
|
if (selectedTimezone) {
|
|
onSelectTimezone(selectedTimezone)
|
|
setOpen(false)
|
|
}
|
|
}}
|
|
>
|
|
{option}
|
|
<CheckIcon
|
|
className={cn(
|
|
'ml-auto h-4 w-4',
|
|
selectedTimezone.text === option ? 'opacity-100' : 'opacity-0'
|
|
)}
|
|
/>
|
|
</CommandItem>
|
|
))}
|
|
</ScrollArea>
|
|
</CommandGroup>
|
|
</CommandList>
|
|
</Command>
|
|
</PopoverContent>
|
|
</Popover>
|
|
</div>
|
|
)
|
|
}
|