diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.tsx b/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.tsx index dce69381646..8e9a8b8b05b 100644 --- a/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.tsx +++ b/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.tsx @@ -39,6 +39,7 @@ export const EdgeFunctionOverview = () => { const { isEnabled: isUnifiedLogsEnabled } = useUnifiedLogsPreview() const [interval, setInterval] = useState('15min') + const [showIntervalDropdown, setShowIntervalDropdown] = useState(false) const selectedInterval = EDGE_FUNCTION_CHART_INTERVALS.find((item) => item.key === interval) || EDGE_FUNCTION_CHART_INTERVALS[1] @@ -153,6 +154,9 @@ export const EdgeFunctionOverview = () => { useEdgeFunctionOverviewShortcuts({ onSetInterval: setInterval, + onToggleIntervalPicker: () => { + setShowIntervalDropdown((open) => !open) + }, onRefresh: () => { combinedStatsResults.refetch() }, @@ -186,7 +190,12 @@ export const EdgeFunctionOverview = () => { return ( <> - + void + showIntervalDropdown?: boolean + onIntervalDropdownOpenChange?: (open: boolean) => void } export const EdgeFunctionOverviewHeader = ({ interval, onIntervalChange, + showIntervalDropdown, + onIntervalDropdownOpenChange, }: EdgeFunctionOverviewHeaderProps) => { const { ref: projectRef, functionSlug } = useParams() const [isTimestampHoverCardOpen, setIsTimestampHoverCardOpen] = useState(false) + const { data: organization } = useSelectedOrganizationQuery() const { data: selectedFunction } = useEdgeFunctionQuery({ projectRef, @@ -123,18 +126,16 @@ export const EdgeFunctionOverviewHeader = ({ -
- {EDGE_FUNCTION_CHART_INTERVALS.map((item, index) => ( - - ))} -
+
diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/useEdgeFunctionOverviewShortcuts.ts b/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/useEdgeFunctionOverviewShortcuts.ts index 87d3709b6ff..f888cdf7d55 100644 --- a/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/useEdgeFunctionOverviewShortcuts.ts +++ b/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/useEdgeFunctionOverviewShortcuts.ts @@ -3,6 +3,7 @@ import { useShortcut } from '@/state/shortcuts/useShortcut' interface UseEdgeFunctionOverviewShortcutsParams { onSetInterval: (key: string) => void + onToggleIntervalPicker: () => void onRefresh: () => void onOpenLogs: () => void } @@ -18,6 +19,7 @@ interface UseEdgeFunctionOverviewShortcutsParams { */ export function useEdgeFunctionOverviewShortcuts({ onSetInterval, + onToggleIntervalPicker, onRefresh, onOpenLogs, }: UseEdgeFunctionOverviewShortcutsParams) { @@ -25,6 +27,7 @@ export function useEdgeFunctionOverviewShortcuts({ useShortcut(SHORTCUT_IDS.FUNCTION_OVERVIEW_INTERVAL_1HR, () => onSetInterval('1hr')) useShortcut(SHORTCUT_IDS.FUNCTION_OVERVIEW_INTERVAL_3HR, () => onSetInterval('3hr')) useShortcut(SHORTCUT_IDS.FUNCTION_OVERVIEW_INTERVAL_1DAY, () => onSetInterval('1day')) + useShortcut(SHORTCUT_IDS.FUNCTION_OVERVIEW_TOGGLE_INTERVAL_PICKER, onToggleIntervalPicker) useShortcut(SHORTCUT_IDS.FUNCTION_OVERVIEW_REFRESH, onRefresh) useShortcut(SHORTCUT_IDS.FUNCTION_OVERVIEW_OPEN_LOGS, onOpenLogs) } diff --git a/apps/studio/components/ui/Logs/ChartIntervalDropdown.tsx b/apps/studio/components/ui/Logs/ChartIntervalDropdown.tsx index 10baeacf701..7f589921fdb 100644 --- a/apps/studio/components/ui/Logs/ChartIntervalDropdown.tsx +++ b/apps/studio/components/ui/Logs/ChartIntervalDropdown.tsx @@ -14,6 +14,7 @@ import { import { CHART_INTERVALS } from './logs.utils' import { InlineLink } from '@/components/ui/InlineLink' import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements' +import type { ChartIntervals } from '@/types' function getDaysRequired(startValue: number, startUnit: string): number { if (startUnit === 'day') return startValue @@ -24,6 +25,7 @@ function getDaysRequired(startValue: number, startUnit: string): number { interface ChartIntervalDropdownProps { value: string onChange: (value: string) => void + intervals?: ChartIntervals[] organizationSlug?: string dropdownAlign?: 'start' | 'center' | 'end' tooltipSide?: 'left' | 'right' | 'top' | 'bottom' @@ -34,13 +36,14 @@ interface ChartIntervalDropdownProps { export const ChartIntervalDropdown = ({ value, onChange, + intervals = CHART_INTERVALS, organizationSlug, dropdownAlign = 'start', tooltipSide = 'right', open, onOpenChange, }: ChartIntervalDropdownProps) => { - const selectedInterval = CHART_INTERVALS.find((i) => i.key === value) || CHART_INTERVALS[1] + const selectedInterval = intervals.find((i) => i.key === value) || intervals[1] const { getEntitlementMax } = useCheckEntitlements('log.retention_days') const retentionDays = getEntitlementMax() @@ -54,7 +57,7 @@ export const ChartIntervalDropdown = ({ - {CHART_INTERVALS.map((i) => { + {intervals.map((i) => { const daysRequired = getDaysRequired(i.startValue, i.startUnit) const disabled = retentionDays !== undefined && daysRequired > retentionDays diff --git a/apps/studio/state/shortcuts/registry/functions-overview.ts b/apps/studio/state/shortcuts/registry/functions-overview.ts index fee6dce1a41..601ed113bed 100644 --- a/apps/studio/state/shortcuts/registry/functions-overview.ts +++ b/apps/studio/state/shortcuts/registry/functions-overview.ts @@ -11,6 +11,7 @@ export const FUNCTIONS_OVERVIEW_SHORTCUT_IDS = { FUNCTION_OVERVIEW_INTERVAL_1HR: 'functions-overview.interval-1hr', FUNCTION_OVERVIEW_INTERVAL_3HR: 'functions-overview.interval-3hr', FUNCTION_OVERVIEW_INTERVAL_1DAY: 'functions-overview.interval-1day', + FUNCTION_OVERVIEW_TOGGLE_INTERVAL_PICKER: 'functions-overview.toggle-interval-picker', FUNCTION_OVERVIEW_REFRESH: 'functions-overview.refresh', FUNCTION_OVERVIEW_OPEN_LOGS: 'functions-overview.open-logs', } @@ -47,6 +48,13 @@ export const functionsOverviewRegistry: RegistryDefinations