discoverButton.tsx 729 B

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