useEdgeFunctionOverviewShortcuts.ts 1.2 KB

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