mirror of
https://github.com/supabase/supabase.git
synced 2026-10-16 22:59:11 +03:00
* test client connections charts * add granularity to database dashboard * add range selection * add selection to area charts * refactor ChartHeader * fix default * fix time preset selected label and add tooltip actions * client connections stacked chart * polish all new chartts * change attribute * fix * add real queries * memory stack * cleanup * precision 1 * update charts * add endpoints * tooltip * format * improve charts * toggle max value * show limit * cleanup * cleanup * update api schema * fix ram_usage_max_available * remove pgbouncer and comments * show total with percentage in chart header * pretty * hide * update reports database * remove client_connections * revert * fix connectionStrings error * restore correct queries and conditions * vertically zoom in to percentage data * add feature flag logic on charts * add feature flag logic to date picker * chore: remove comment * add tooltip to charts metrics * chore: comment new pg endpoints * feat: lazy load ComposedChartHandler queries * feat: dim non-hovered chart values when hovering chart label item * feat: improve dim styling * chore: improve light mode stacked chart colors * chore: remove 15s interval * chore: sync types * chore: remove type * chore: restore type * fix hook error * show chart type toggle * remove console log * temp * keep connections charts as before * restore DateRangePicker * show last aggregate value when not hovering * clean up imports * disk IOps read and write * restore flag * refactor queries * clean up grafana promo banner * Update database-charts.ts | updated language * fix hook error * fix hook error * fix hook error * attempt fix hook error --------- Co-authored-by: TheOtherBrian1 <91111415+TheOtherBrian1@users.noreply.github.com>
76 lines
2.6 KiB
TypeScript
76 lines
2.6 KiB
TypeScript
import React, { useEffect, useState } from 'react'
|
|
import dayjs from 'dayjs'
|
|
import { ArrowRight, SearchIcon } from 'lucide-react'
|
|
import {
|
|
cn,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuLabel,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
} from 'ui'
|
|
import { ChartHighlight } from './useChartHighlight'
|
|
import { UpdateDateRange } from 'pages/project/[ref]/reports/database'
|
|
|
|
const ChartHighlightActions = ({
|
|
chartHighlight,
|
|
updateDateRange,
|
|
}: {
|
|
chartHighlight?: ChartHighlight
|
|
updateDateRange: UpdateDateRange
|
|
}) => {
|
|
const { left: selectedRangeStart, right: selectedRangeEnd, clearHighlight } = chartHighlight ?? {}
|
|
const [isOpen, setIsOpen] = useState(!!chartHighlight?.popoverPosition)
|
|
|
|
useEffect(() => {
|
|
setIsOpen(!!chartHighlight?.popoverPosition && selectedRangeStart !== selectedRangeEnd)
|
|
}, [chartHighlight?.popoverPosition])
|
|
|
|
const disableZoomIn = dayjs(selectedRangeEnd).diff(dayjs(selectedRangeStart), 'minutes') < 10
|
|
const handleZoomIn = () => {
|
|
if (disableZoomIn) return
|
|
updateDateRange(selectedRangeStart!, selectedRangeEnd!)
|
|
clearHighlight && clearHighlight()
|
|
}
|
|
|
|
return (
|
|
<DropdownMenu open={isOpen} onOpenChange={setIsOpen}>
|
|
<DropdownMenuTrigger
|
|
className="w-auto p-0"
|
|
style={{
|
|
position: 'absolute',
|
|
left: chartHighlight?.popoverPosition?.x + 'px' || 0,
|
|
top: chartHighlight?.popoverPosition?.y + 'px' || 0,
|
|
}}
|
|
/>
|
|
<DropdownMenuContent className="flex flex-col gap-1 p-1 w-fit text-left">
|
|
<DropdownMenuLabel className="flex items-center justify-center text-foreground-lighter font-mono gap-1 text-xs">
|
|
<span>{dayjs(selectedRangeStart).format('MMM D, H:mm')}</span>
|
|
<ArrowRight size={10} />
|
|
<span>{dayjs(selectedRangeEnd).format('MMM D, H:mm')}</span>
|
|
</DropdownMenuLabel>
|
|
<DropdownMenuSeparator className="my-0" />
|
|
<DropdownMenuItem
|
|
disabled={disableZoomIn}
|
|
className={cn('group', disableZoomIn && '!bg-transparent')}
|
|
>
|
|
<button
|
|
disabled={disableZoomIn}
|
|
onClick={handleZoomIn}
|
|
className="w-full flex items-center gap-1.5"
|
|
>
|
|
<SearchIcon className="text-foreground-lighter" size={12} />
|
|
<span className="flex-grow text-left text-foreground-light">Zoom in</span>
|
|
{disableZoomIn && (
|
|
<span className="text-foreground-muted text-xs">10 minutes min.</span>
|
|
)}
|
|
</button>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)
|
|
}
|
|
|
|
export default ChartHighlightActions
|