discoverFeature.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import * as React from 'react';
  2. import Feature from 'sentry/components/acl/feature';
  3. import FeatureDisabled from 'sentry/components/acl/featureDisabled';
  4. import {Hovercard} from 'sentry/components/hovercard';
  5. import {t} from 'sentry/locale';
  6. type Props = {
  7. children: ({hasFeature: boolean}) => React.ReactNode;
  8. };
  9. /**
  10. * Provide a component that passes a prop to indicate if the current
  11. * organization doesn't have access to discover results.
  12. */
  13. function DiscoverFeature({children}: Props) {
  14. const noFeatureMessage = t('Requires discover feature.');
  15. const renderDisabled = p => (
  16. <Hovercard
  17. body={
  18. <FeatureDisabled
  19. features={p.features}
  20. hideHelpToggle
  21. message={noFeatureMessage}
  22. featureName={noFeatureMessage}
  23. />
  24. }
  25. >
  26. {p.children(p)}
  27. </Hovercard>
  28. );
  29. return (
  30. <Feature
  31. hookName="feature-disabled:open-discover"
  32. features={['organizations:discover-basic']}
  33. renderDisabled={renderDisabled}
  34. >
  35. {({hasFeature}) => children({hasFeature})}
  36. </Feature>
  37. );
  38. }
  39. export default DiscoverFeature;