shareButton.tsx 825 B

123456789101112131415161718192021222324252627282930313233343536
  1. import {openModal} from 'sentry/actionCreators/modal';
  2. import {Button} from 'sentry/components/button';
  3. import TextCopyInput from 'sentry/components/textCopyInput';
  4. import {IconUpload} from 'sentry/icons';
  5. import {t} from 'sentry/locale';
  6. function ShareModal({Header, Body}) {
  7. const url = new URL(window.location.href);
  8. return (
  9. <div>
  10. <Header>
  11. <h3>{t('Share View')}</h3>
  12. </Header>
  13. <Body>
  14. <TextCopyInput aria-label={t('Link to current view')} size="sm">
  15. {url.toString()}
  16. </TextCopyInput>
  17. </Body>
  18. </div>
  19. );
  20. }
  21. function ShareButton() {
  22. return (
  23. <Button
  24. size="sm"
  25. icon={<IconUpload size="sm" />}
  26. onClick={() => openModal(deps => <ShareModal {...deps} />)}
  27. >
  28. {t('Share')}
  29. </Button>
  30. );
  31. }
  32. export default ShareButton;