index.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import Footer from 'sentry/components/footer';
  2. import HookOrDefault from 'sentry/components/hookOrDefault';
  3. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  4. import Sidebar from 'sentry/components/sidebar';
  5. import useRouteAnalyticsHookSetup from 'sentry/utils/routeAnalytics/useRouteAnalyticsHookSetup';
  6. import useDevToolbar from 'sentry/utils/useDevToolbar';
  7. import {useIsSentryEmployee} from 'sentry/utils/useIsSentryEmployee';
  8. import useOrganization from 'sentry/utils/useOrganization';
  9. import OrganizationContainer from 'sentry/views/organizationContainer';
  10. import Body from './body';
  11. interface Props {
  12. children: React.ReactNode;
  13. }
  14. const OrganizationHeader = HookOrDefault({
  15. hookName: 'component:organization-header',
  16. });
  17. function DevToolInit() {
  18. const isEmployee = useIsSentryEmployee();
  19. const organization = useOrganization();
  20. const showDevToolbar = organization.features.includes('devtoolbar');
  21. useDevToolbar({enabled: showDevToolbar && isEmployee});
  22. return null;
  23. }
  24. function OrganizationLayout({children}: Props) {
  25. useRouteAnalyticsHookSetup();
  26. // XXX(epurkhiser): The OrganizationContainer is responsible for ensuring the
  27. // oganization is loaded before rendering children. Organization may not be
  28. // loaded yet when this first renders.
  29. const organization = useOrganization({allowNull: true});
  30. return (
  31. <SentryDocumentTitle noSuffix title={organization?.name ?? 'Sentry'}>
  32. <OrganizationContainer>
  33. <div className="app">
  34. {organization && <OrganizationHeader organization={organization} />}
  35. {organization && <DevToolInit />}
  36. <Sidebar />
  37. <Body>{children}</Body>
  38. <Footer />
  39. </div>
  40. </OrganizationContainer>
  41. </SentryDocumentTitle>
  42. );
  43. }
  44. export default OrganizationLayout;