replayCurrentUrl.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import styled from '@emotion/styled';
  2. import {useReplayContext} from 'sentry/components/replays/replayContext';
  3. import TextCopyInput, {
  4. StyledCopyButton,
  5. StyledInput,
  6. } from 'sentry/components/textCopyInput';
  7. import space from 'sentry/styles/space';
  8. import getCurrentUrl from 'sentry/utils/replays/getCurrentUrl';
  9. function ReplayCurrentUrl() {
  10. const {currentTime, replay} = useReplayContext();
  11. if (!replay) {
  12. return (
  13. <UrlCopyInput size="sm" disabled>
  14. {''}
  15. </UrlCopyInput>
  16. );
  17. }
  18. const replayRecord = replay.getReplay();
  19. const crumbs = replay.getRawCrumbs();
  20. return (
  21. <UrlCopyInput size="sm">
  22. {getCurrentUrl(replayRecord, crumbs, currentTime)}
  23. </UrlCopyInput>
  24. );
  25. }
  26. const UrlCopyInput = styled(TextCopyInput)`
  27. font-size: ${p => p.theme.fontSizeMedium};
  28. column-gap: ${space(1)};
  29. ${StyledInput} {
  30. border-right-width: 1px;
  31. border-radius: 0.25em;
  32. background-color: ${p => p.theme.background};
  33. border-right-color: ${p => p.theme.border};
  34. &:hover,
  35. &:focus {
  36. border-right-width: 1px;
  37. background-color: ${p => p.theme.background};
  38. }
  39. }
  40. ${StyledCopyButton} {
  41. border-radius: 0.25em;
  42. }
  43. `;
  44. export default ReplayCurrentUrl;