AdvisorsMenu.utils.tsx 1.5 KB

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