useEdgeFunctionOverviewShortcuts.ts30 lines · main
| 1 | import { SHORTCUT_IDS } from '@/state/shortcuts/registry' |
| 2 | import { useShortcut } from '@/state/shortcuts/useShortcut' |
| 3 | |
| 4 | interface UseEdgeFunctionOverviewShortcutsParams { |
| 5 | onSetInterval: (key: string) => void |
| 6 | onRefresh: () => void |
| 7 | onOpenLogs: () => void |
| 8 | } |
| 9 | |
| 10 | /** |
| 11 | * Shortcuts scoped to the per-function Overview tab (the new flag-gated UI). |
| 12 | * |
| 13 | * - I+M / I+H / I+T / I+D: select chart interval |
| 14 | * - Shift+R: refresh the combined stats query |
| 15 | * - O+L: jump to the Logs (or Invocations) sub-page |
| 16 | * |
| 17 | * Should be mounted once inside `EdgeFunctionOverview`. |
| 18 | */ |
| 19 | export function useEdgeFunctionOverviewShortcuts({ |
| 20 | onSetInterval, |
| 21 | onRefresh, |
| 22 | onOpenLogs, |
| 23 | }: UseEdgeFunctionOverviewShortcutsParams) { |
| 24 | useShortcut(SHORTCUT_IDS.FUNCTION_OVERVIEW_INTERVAL_15MIN, () => onSetInterval('15min')) |
| 25 | useShortcut(SHORTCUT_IDS.FUNCTION_OVERVIEW_INTERVAL_1HR, () => onSetInterval('1hr')) |
| 26 | useShortcut(SHORTCUT_IDS.FUNCTION_OVERVIEW_INTERVAL_3HR, () => onSetInterval('3hr')) |
| 27 | useShortcut(SHORTCUT_IDS.FUNCTION_OVERVIEW_INTERVAL_1DAY, () => onSetInterval('1day')) |
| 28 | useShortcut(SHORTCUT_IDS.FUNCTION_OVERVIEW_REFRESH, onRefresh) |
| 29 | useShortcut(SHORTCUT_IDS.FUNCTION_OVERVIEW_OPEN_LOGS, onOpenLogs) |
| 30 | } |