discoverFeature.tsx 1.1 KB

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