index.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import {Location} from 'history';
  2. import Feature from 'sentry/components/acl/feature';
  3. import {Alert} from 'sentry/components/alert';
  4. import * as Layout from 'sentry/components/layouts/thirds';
  5. import NoProjectMessage from 'sentry/components/noProjectMessage';
  6. import {t} from 'sentry/locale';
  7. import {Organization} from 'sentry/types';
  8. import {MetricsCardinalityProvider} from 'sentry/utils/performance/contexts/metricsCardinality';
  9. import {MEPSettingProvider} from 'sentry/utils/performance/contexts/metricsEnhancedSetting';
  10. import {QueryClient, QueryClientProvider} from 'sentry/utils/queryClient';
  11. import withOrganization from 'sentry/utils/withOrganization';
  12. type Props = {
  13. children: React.ReactNode;
  14. location: Location;
  15. organization: Organization;
  16. };
  17. const queryClient = new QueryClient();
  18. function PerformanceContainer({organization, location, children}: Props) {
  19. function renderNoAccess() {
  20. return (
  21. <Layout.Page withPadding>
  22. <Alert type="warning">{t("You don't have access to this feature")}</Alert>
  23. </Layout.Page>
  24. );
  25. }
  26. return (
  27. <Feature
  28. hookName="feature-disabled:performance-page"
  29. features={['performance-view']}
  30. organization={organization}
  31. renderDisabled={renderNoAccess}
  32. >
  33. <NoProjectMessage organization={organization}>
  34. <QueryClientProvider client={queryClient}>
  35. <MetricsCardinalityProvider location={location} organization={organization}>
  36. <MEPSettingProvider>{children}</MEPSettingProvider>
  37. </MetricsCardinalityProvider>
  38. </QueryClientProvider>
  39. </NoProjectMessage>
  40. </Feature>
  41. );
  42. }
  43. export default withOrganization(PerformanceContainer);