modulePageProviders.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import type {ComponentProps} from 'react';
  2. import Feature from 'sentry/components/acl/feature';
  3. import * as Layout from 'sentry/components/layouts/thirds';
  4. import NoProjectMessage from 'sentry/components/noProjectMessage';
  5. import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
  6. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  7. import useOrganization from 'sentry/utils/useOrganization';
  8. import {NoAccess} from 'sentry/views/insights/common/components/noAccess';
  9. import {INSIGHTS_TITLE, MODULE_TITLES} from 'sentry/views/insights/settings';
  10. import type {ModuleName} from 'sentry/views/insights/types';
  11. type ModuleNameStrings = `${ModuleName}`;
  12. type TitleableModuleNames = Exclude<ModuleNameStrings, '' | 'other'>;
  13. interface Props {
  14. children: React.ReactNode;
  15. features: ComponentProps<typeof Feature>['features'];
  16. moduleName: TitleableModuleNames;
  17. pageTitle?: string;
  18. }
  19. export function ModulePageProviders({moduleName, pageTitle, children, features}: Props) {
  20. const organization = useOrganization();
  21. const moduleTitle = MODULE_TITLES[moduleName];
  22. const fullPageTitle = [pageTitle, moduleTitle, INSIGHTS_TITLE]
  23. .filter(Boolean)
  24. .join(' — ');
  25. return (
  26. <PageFiltersContainer>
  27. <SentryDocumentTitle title={fullPageTitle} orgSlug={organization.slug}>
  28. <Layout.Page>
  29. <Feature
  30. features={features}
  31. organization={organization}
  32. renderDisabled={NoAccess}
  33. >
  34. <NoProjectMessage organization={organization}>{children}</NoProjectMessage>
  35. </Feature>
  36. </Layout.Page>
  37. </SentryDocumentTitle>
  38. </PageFiltersContainer>
  39. );
  40. }