replayCurrentUrl.tsx 1.2 KB

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