moduleUpsellHookWrapper.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import Feature from 'sentry/components/acl/feature';
  2. import {NoAccess} from 'sentry/components/noAccess';
  3. import useOrganization from 'sentry/utils/useOrganization';
  4. import {
  5. type TitleableModuleNames,
  6. UpsellPageHook,
  7. } from 'sentry/views/insights/common/components/modulePageProviders';
  8. import {useDomainViewFilters} from 'sentry/views/insights/pages/useFilters';
  9. import {MODULE_FEATURE_MAP} from 'sentry/views/insights/settings';
  10. // TODO - remove, This is only necessary for domain views, where we don't want to show the full upsell page.
  11. export function ModuleBodyUpsellHook({
  12. moduleName,
  13. children,
  14. }: {
  15. children: React.ReactNode;
  16. moduleName: TitleableModuleNames;
  17. }) {
  18. const {isInDomainView: shouldDisplayUpsell} = useDomainViewFilters();
  19. const organization = useOrganization();
  20. if (shouldDisplayUpsell) {
  21. return (
  22. <UpsellPageHook moduleName={moduleName} fullPage={false}>
  23. <Feature
  24. features={MODULE_FEATURE_MAP[moduleName]}
  25. organization={organization}
  26. renderDisabled={NoAccess}
  27. >
  28. {children}
  29. </Feature>
  30. </UpsellPageHook>
  31. );
  32. }
  33. return children;
  34. }