mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
## Context We've been seeing many `NotFoundError: Failed to execute 'removeChild' on 'Node'` and `NotFoundError: Failed to execute 'insertBefore' on 'Node'` events on Sentry which are historically known to be caused by Google Translate in the browser. There's technically no _right way_ to address this unfortunately, but one of the solutions which should address most of these issues is to wrap any dynamic text within a span - we've considered that quite a while back tbh but never took the time to do this until today with the help of Claude. Although just a heads up that it might not necessarily completely eradicate those issues. Also added an eslint rule which should prevent future occurences of this <img width="1264" height="192" alt="image" src="https://github.com/user-attachments/assets/b2c32ea0-45a2-4ccd-82fe-1a859905fc29" />
101 lines
3.5 KiB
TypeScript
101 lines
3.5 KiB
TypeScript
import { ChevronDownIcon } from 'lucide-react'
|
|
import {
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuRadioGroup,
|
|
DropdownMenuRadioItem,
|
|
DropdownMenuTrigger,
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipTrigger,
|
|
} from 'ui'
|
|
|
|
import { CHART_INTERVALS, getDaysRequired } from './logs.utils'
|
|
import { InlineLink } from '@/components/ui/InlineLink'
|
|
import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
|
|
|
|
interface ChartIntervalDropdownProps {
|
|
value: string
|
|
onChange: (value: string) => void
|
|
organizationSlug?: string
|
|
dropdownAlign?: 'start' | 'center' | 'end'
|
|
tooltipSide?: 'left' | 'right' | 'top' | 'bottom'
|
|
open?: boolean
|
|
onOpenChange?: (open: boolean) => void
|
|
}
|
|
|
|
export const ChartIntervalDropdown = ({
|
|
value,
|
|
onChange,
|
|
organizationSlug,
|
|
dropdownAlign = 'start',
|
|
tooltipSide = 'right',
|
|
open,
|
|
onOpenChange,
|
|
}: ChartIntervalDropdownProps) => {
|
|
const selectedInterval = CHART_INTERVALS.find((i) => i.key === value) || CHART_INTERVALS[1]
|
|
|
|
const { getEntitlementMax } = useCheckEntitlements('log.retention_days')
|
|
const retentionDays = getEntitlementMax()
|
|
|
|
return (
|
|
<DropdownMenu open={open} onOpenChange={onOpenChange}>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button iconRight={<ChevronDownIcon size={14} />}>
|
|
<span>{selectedInterval.label}</span>
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent side="bottom" align={dropdownAlign} className="w-40">
|
|
<DropdownMenuRadioGroup value={value} onValueChange={onChange}>
|
|
{CHART_INTERVALS.map((i) => {
|
|
const daysRequired = getDaysRequired(i.startValue, i.startUnit)
|
|
const disabled = retentionDays !== undefined && daysRequired > retentionDays
|
|
|
|
if (disabled) {
|
|
return (
|
|
<Tooltip key={i.key}>
|
|
<TooltipTrigger asChild>
|
|
<DropdownMenuRadioItem disabled value={i.key} className="pointer-events-auto!">
|
|
{i.label}
|
|
</DropdownMenuRadioItem>
|
|
</TooltipTrigger>
|
|
<TooltipContent side={tooltipSide}>
|
|
<p>
|
|
Your plan only includes up to {retentionDays} day
|
|
{retentionDays !== undefined && retentionDays > 1 ? <span>s</span> : ''}{' '}
|
|
<span>of log retention</span>
|
|
</p>
|
|
<p className="text-foreground-light">
|
|
{organizationSlug ? (
|
|
<>
|
|
<InlineLink
|
|
className="text-foreground-light hover:text-foreground"
|
|
href={`/org/${organizationSlug}/billing?panel=subscriptionPlan`}
|
|
>
|
|
Upgrade your plan
|
|
</InlineLink>{' '}
|
|
to increase log retention and view statistics for the{' '}
|
|
{i.label.toLowerCase()}
|
|
</>
|
|
) : (
|
|
`Upgrade your plan to increase log retention and view statistics for the ${i.label.toLowerCase()}`
|
|
)}
|
|
</p>
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
)
|
|
} else {
|
|
return (
|
|
<DropdownMenuRadioItem key={i.key} value={i.key}>
|
|
{i.label}
|
|
</DropdownMenuRadioItem>
|
|
)
|
|
}
|
|
})}
|
|
</DropdownMenuRadioGroup>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)
|
|
}
|