discoverButton.tsx 743 B

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