navigation.tsx 2.2 KB

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