openReplayComparisonButton.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import {Fragment, lazy, Suspense} from 'react';
  2. import {css} from '@emotion/react';
  3. import {openModal} from 'sentry/actionCreators/modal';
  4. import {Button} from 'sentry/components/button';
  5. import LoadingIndicator from 'sentry/components/loadingIndicator';
  6. import {t} from 'sentry/locale';
  7. import ReplayReader from 'sentry/utils/replays/replayReader';
  8. import useOrganization from 'sentry/utils/useOrganization';
  9. const LazyComparisonModal = lazy(
  10. () => import('sentry/components/replays/breadcrumbs/replayComparisonModal')
  11. );
  12. interface Props {
  13. leftTimestamp: number;
  14. replay: null | ReplayReader;
  15. rightTimestamp: number;
  16. }
  17. export function OpenReplayComparisonButton({
  18. leftTimestamp,
  19. replay,
  20. rightTimestamp,
  21. }: Props) {
  22. const organization = useOrganization();
  23. return (
  24. <Button
  25. role="button"
  26. size="xs"
  27. onClick={() => {
  28. openModal(
  29. deps => (
  30. <Suspense
  31. fallback={
  32. <Fragment>
  33. <deps.Header closeButton>
  34. <deps.Header>{t('Hydration Error')}</deps.Header>
  35. </deps.Header>
  36. <deps.Body>
  37. <LoadingIndicator />
  38. </deps.Body>
  39. </Fragment>
  40. }
  41. >
  42. <LazyComparisonModal
  43. replay={replay}
  44. organization={organization}
  45. leftTimestamp={leftTimestamp}
  46. rightTimestamp={rightTimestamp}
  47. {...deps}
  48. />
  49. </Suspense>
  50. ),
  51. {modalCss}
  52. );
  53. }}
  54. >
  55. {t('Open Hydration Diff')}
  56. </Button>
  57. );
  58. }
  59. const modalCss = css`
  60. width: 95vw;
  61. min-height: 80vh;
  62. max-height: 95vh;
  63. `;