RealtimeMenu.utils.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import type { ProductMenuGroup } from '@/components/ui/ProductMenu/ProductMenu.types'
  2. import type { Project } from '@/data/projects/project-detail-query'
  3. import { IS_PLATFORM } from '@/lib/constants'
  4. import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
  5. export const generateRealtimeMenu = (project: Project | undefined): ProductMenuGroup[] => {
  6. const ref = project?.ref ?? 'default'
  7. const showRealtimeSettings = IS_PLATFORM
  8. return [
  9. {
  10. title: 'Tools',
  11. items: [
  12. {
  13. name: 'Inspector',
  14. key: 'inspector',
  15. url: `/project/${ref}/realtime/inspector`,
  16. items: [],
  17. shortcutId: SHORTCUT_IDS.NAV_REALTIME_INSPECTOR,
  18. },
  19. ],
  20. },
  21. {
  22. title: 'Configuration',
  23. items: [
  24. {
  25. name: 'Policies',
  26. key: 'policies',
  27. url: `/project/${ref}/realtime/policies`,
  28. items: [],
  29. shortcutId: SHORTCUT_IDS.NAV_REALTIME_POLICIES,
  30. },
  31. ...(showRealtimeSettings
  32. ? [
  33. {
  34. name: 'Settings',
  35. key: 'settings',
  36. url: `/project/${ref}/realtime/settings`,
  37. items: [],
  38. shortcutId: SHORTCUT_IDS.NAV_REALTIME_SETTINGS,
  39. },
  40. ]
  41. : []),
  42. ],
  43. },
  44. ]
  45. }