navigation.tsx 2.4 KB

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