Files
supabase/apps/studio/components/interfaces/Database/Backups/PITR/TimezoneSelection.tsx
Gildas Garcia d0fd4478c0 chore: migrate Popover usages to Shadcn components (#45980)
## Problem

We have multiple Popover components

## Solution

- [x] migrate Popover usages to Shadcn components
- Migrated JSON and text editor in the `TableEditor` (inline row
edition)
  - Migrated the template popover in the logs explorer templates page
- [x] remove `_Shadcn_` suffix from Popover components (renaming +
prettier)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Refactor**
* Unified popover implementation across the app and design system;
dropdowns, calendars, menus and tooltips now use a consistent popover
API with no visual or interaction changes.

* **Chores**
* Minor prop typing update for the logs date-picker to align with the
consolidated popover content type.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/45980)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-15 15:20:28 +02:00

92 lines
2.9 KiB
TypeScript

import { CheckIcon, ChevronsUpDown, Globe } from 'lucide-react'
import { useId, useState } from 'react'
import {
Button,
cn,
Command_Shadcn_,
CommandEmpty_Shadcn_,
CommandGroup_Shadcn_,
CommandInput_Shadcn_,
CommandItem_Shadcn_,
CommandList_Shadcn_,
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-between"
size="small"
icon={<Globe />}
iconRight={<ChevronsUpDown size={14} strokeWidth={1.5} />}
>
{selectedTimezone
? timezoneOptions.find((option) => option === selectedTimezone.text)
: 'Select timezone...'}
</Button>
</PopoverTrigger>
<PopoverContent id={listboxId} className="w-[350px] p-0">
<Command_Shadcn_>
<CommandInput_Shadcn_ placeholder="Search timezone..." className="h-9" />
<CommandList_Shadcn_>
<CommandEmpty_Shadcn_>No timezones found...</CommandEmpty_Shadcn_>
<CommandGroup_Shadcn_>
<ScrollArea className="h-72">
{timezoneOptions.map((option) => (
<CommandItem_Shadcn_
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_Shadcn_>
))}
</ScrollArea>
</CommandGroup_Shadcn_>
</CommandList_Shadcn_>
</Command_Shadcn_>
</PopoverContent>
</Popover>
</div>
)
}