AdvisorsMenu.utils.tsx53 lines · main
| 1 | import { useParams } from 'common' |
| 2 | import { ArrowUpRight } from 'lucide-react' |
| 3 | |
| 4 | import { useIsAdvisorRulesEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext' |
| 5 | import type { ProductMenuGroup } from '@/components/ui/ProductMenu/ProductMenu.types' |
| 6 | import { IS_PLATFORM } from '@/lib/constants' |
| 7 | |
| 8 | export const useGenerateAdvisorsMenu = (): ProductMenuGroup[] => { |
| 9 | const { ref } = useParams() |
| 10 | const isAdvisorRulesEnabled = useIsAdvisorRulesEnabled() |
| 11 | |
| 12 | return [ |
| 13 | { |
| 14 | title: 'Advisors', |
| 15 | items: [ |
| 16 | { |
| 17 | name: 'Security Advisor', |
| 18 | key: 'security', |
| 19 | url: `/project/${ref}/advisors/security`, |
| 20 | items: [], |
| 21 | }, |
| 22 | { |
| 23 | name: 'Performance Advisor', |
| 24 | key: 'performance', |
| 25 | url: `/project/${ref}/advisors/performance`, |
| 26 | items: [], |
| 27 | }, |
| 28 | { |
| 29 | name: 'Query Performance', |
| 30 | key: 'query-performance', |
| 31 | url: `/project/${ref}/observability/query-performance`, |
| 32 | items: [], |
| 33 | rightIcon: <ArrowUpRight size={14} strokeWidth={1.5} className="h-4 w-4" />, |
| 34 | }, |
| 35 | ], |
| 36 | }, |
| 37 | ...(IS_PLATFORM && isAdvisorRulesEnabled |
| 38 | ? [ |
| 39 | { |
| 40 | title: 'Configuration', |
| 41 | items: [ |
| 42 | { |
| 43 | name: 'Settings', |
| 44 | key: 'rules', |
| 45 | url: `/project/${ref}/advisors/rules/security`, |
| 46 | items: [], |
| 47 | }, |
| 48 | ], |
| 49 | }, |
| 50 | ] |
| 51 | : []), |
| 52 | ] |
| 53 | } |