1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import type {ComponentProps} from 'react';
- import Feature from 'sentry/components/acl/feature';
- import * as Layout from 'sentry/components/layouts/thirds';
- import NoProjectMessage from 'sentry/components/noProjectMessage';
- import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
- import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
- import useOrganization from 'sentry/utils/useOrganization';
- import {NoAccess} from 'sentry/views/insights/common/components/noAccess';
- import {INSIGHTS_TITLE, MODULE_TITLES} from 'sentry/views/insights/settings';
- import type {ModuleName} from 'sentry/views/insights/types';
- type ModuleNameStrings = `${ModuleName}`;
- type TitleableModuleNames = Exclude<ModuleNameStrings, '' | 'other'>;
- interface Props {
- children: React.ReactNode;
- features: ComponentProps<typeof Feature>['features'];
- moduleName: TitleableModuleNames;
- pageTitle?: string;
- }
- export function ModulePageProviders({moduleName, pageTitle, children, features}: Props) {
- const organization = useOrganization();
- const moduleTitle = MODULE_TITLES[moduleName];
- const fullPageTitle = [pageTitle, moduleTitle, INSIGHTS_TITLE]
- .filter(Boolean)
- .join(' — ');
- return (
- <PageFiltersContainer>
- <SentryDocumentTitle title={fullPageTitle} orgSlug={organization.slug}>
- <Layout.Page>
- <Feature
- features={features}
- organization={organization}
- renderDisabled={NoAccess}
- >
- <NoProjectMessage organization={organization}>{children}</NoProjectMessage>
- </Feature>
- </Layout.Page>
- </SentryDocumentTitle>
- </PageFiltersContainer>
- );
- }
|