discoverButton.tsx 665 B

123456789101112131415161718192021222324252627
  1. import * as React from 'react';
  2. import Button from 'app/components/button';
  3. import DiscoverFeature from 'app/components/discover/discoverFeature';
  4. type Props = React.PropsWithChildren<{
  5. className?: string;
  6. }> &
  7. React.ComponentProps<typeof Button>;
  8. /**
  9. * Provide a button that turns itself off if the current organization
  10. * doesn't have access to discover results.
  11. */
  12. function DiscoverButton({children, ...buttonProps}: Props) {
  13. return (
  14. <DiscoverFeature>
  15. {({hasFeature}) => (
  16. <Button disabled={!hasFeature} {...buttonProps}>
  17. {children}
  18. </Button>
  19. )}
  20. </DiscoverFeature>
  21. );
  22. }
  23. export default DiscoverButton;