shareButton.tsx 933 B

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