navigation.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import {Fragment} from 'react';
  2. import {SecondaryNav} from 'sentry/components/nav/secondary';
  3. import {PrimaryNavGroup} from 'sentry/components/nav/types';
  4. import {t} from 'sentry/locale';
  5. import useOrganization from 'sentry/utils/useOrganization';
  6. import {
  7. AI_LANDING_SUB_PATH,
  8. AI_SIDEBAR_LABEL,
  9. } from 'sentry/views/insights/pages/ai/settings';
  10. import {
  11. BACKEND_LANDING_SUB_PATH,
  12. BACKEND_SIDEBAR_LABEL,
  13. } from 'sentry/views/insights/pages/backend/settings';
  14. import {
  15. FRONTEND_LANDING_SUB_PATH,
  16. FRONTEND_SIDEBAR_LABEL,
  17. } from 'sentry/views/insights/pages/frontend/settings';
  18. import {
  19. MOBILE_LANDING_SUB_PATH,
  20. MOBILE_SIDEBAR_LABEL,
  21. } from 'sentry/views/insights/pages/mobile/settings';
  22. import {DOMAIN_VIEW_BASE_URL} from 'sentry/views/insights/pages/settings';
  23. type InsightsNavigationProps = {
  24. children: React.ReactNode;
  25. };
  26. export default function InsightsNavigation({children}: InsightsNavigationProps) {
  27. const organization = useOrganization();
  28. const hasNavigationV2 = organization?.features.includes('navigation-sidebar-v2');
  29. if (!hasNavigationV2) {
  30. return children;
  31. }
  32. const baseUrl = `/organizations/${organization.slug}/${DOMAIN_VIEW_BASE_URL}`;
  33. return (
  34. <Fragment>
  35. <SecondaryNav group={PrimaryNavGroup.INSIGHTS}>
  36. <SecondaryNav.Body>
  37. <SecondaryNav.Section>
  38. <SecondaryNav.Item to={`${baseUrl}/projects/`}>
  39. {t('All Projects')}
  40. </SecondaryNav.Item>
  41. </SecondaryNav.Section>
  42. <SecondaryNav.Section>
  43. <SecondaryNav.Item to={`${baseUrl}/${FRONTEND_LANDING_SUB_PATH}/`}>
  44. {FRONTEND_SIDEBAR_LABEL}
  45. </SecondaryNav.Item>
  46. <SecondaryNav.Item to={`${baseUrl}/${BACKEND_LANDING_SUB_PATH}/`}>
  47. {BACKEND_SIDEBAR_LABEL}
  48. </SecondaryNav.Item>
  49. <SecondaryNav.Item to={`${baseUrl}/${MOBILE_LANDING_SUB_PATH}/`}>
  50. {MOBILE_SIDEBAR_LABEL}
  51. </SecondaryNav.Item>
  52. <SecondaryNav.Item to={`${baseUrl}/${AI_LANDING_SUB_PATH}/`}>
  53. {AI_SIDEBAR_LABEL}
  54. </SecondaryNav.Item>
  55. </SecondaryNav.Section>
  56. </SecondaryNav.Body>
  57. </SecondaryNav>
  58. {children}
  59. </Fragment>
  60. );
  61. }