RealtimeMenu.utils.ts47 lines · main
| 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 | |
| 6 | export const generateRealtimeMenu = (project: Project | undefined): ProductMenuGroup[] => { |
| 7 | const ref = project?.ref ?? 'default' |
| 8 | const showRealtimeSettings = IS_PLATFORM |
| 9 | |
| 10 | return [ |
| 11 | { |
| 12 | title: 'Tools', |
| 13 | items: [ |
| 14 | { |
| 15 | name: 'Inspector', |
| 16 | key: 'inspector', |
| 17 | url: `/project/${ref}/realtime/inspector`, |
| 18 | items: [], |
| 19 | shortcutId: SHORTCUT_IDS.NAV_REALTIME_INSPECTOR, |
| 20 | }, |
| 21 | ], |
| 22 | }, |
| 23 | { |
| 24 | title: 'Configuration', |
| 25 | items: [ |
| 26 | { |
| 27 | name: 'Policies', |
| 28 | key: 'policies', |
| 29 | url: `/project/${ref}/realtime/policies`, |
| 30 | items: [], |
| 31 | shortcutId: SHORTCUT_IDS.NAV_REALTIME_POLICIES, |
| 32 | }, |
| 33 | ...(showRealtimeSettings |
| 34 | ? [ |
| 35 | { |
| 36 | name: 'Settings', |
| 37 | key: 'settings', |
| 38 | url: `/project/${ref}/realtime/settings`, |
| 39 | items: [], |
| 40 | shortcutId: SHORTCUT_IDS.NAV_REALTIME_SETTINGS, |
| 41 | }, |
| 42 | ] |
| 43 | : []), |
| 44 | ], |
| 45 | }, |
| 46 | ] |
| 47 | } |