replayDiffSection.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {lazy} from 'react';
  2. import ReactLazyLoad from 'react-lazyload';
  3. import styled from '@emotion/styled';
  4. import NegativeSpaceContainer from 'sentry/components/container/negativeSpaceContainer';
  5. import ErrorBoundary from 'sentry/components/errorBoundary';
  6. import {REPLAY_LOADING_HEIGHT} from 'sentry/components/events/eventReplay/constants';
  7. import LazyLoad from 'sentry/components/lazyLoad';
  8. import LoadingIndicator from 'sentry/components/loadingIndicator';
  9. import {t} from 'sentry/locale';
  10. import {space} from 'sentry/styles/space';
  11. import type {Event} from 'sentry/types/event';
  12. import type {Group} from 'sentry/types/group';
  13. import useOrganization from 'sentry/utils/useOrganization';
  14. import {SectionKey} from 'sentry/views/issueDetails/streamline/context';
  15. import {InterimSection} from 'sentry/views/issueDetails/streamline/interimSection';
  16. interface Props {
  17. event: Event;
  18. group: Group | undefined;
  19. replayId: string;
  20. }
  21. const ReplayDiffContent = lazy(() => import('./replayDiffContent'));
  22. export function ReplayDiffSection({event, group, replayId}: Props) {
  23. const organization = useOrganization();
  24. return (
  25. <ErrorBoundary mini>
  26. <ReactLazyLoad debounce={50} height={448} offset={0} once>
  27. <LazyLoad
  28. event={event}
  29. group={group}
  30. orgSlug={organization.slug}
  31. replaySlug={replayId}
  32. LazyComponent={ReplayDiffContent}
  33. loadingFallback={
  34. <InterimSection
  35. type={SectionKey.HYDRATION_DIFF}
  36. title={t('Hydration Error Diff')}
  37. >
  38. <StyledNegativeSpaceContainer data-test-id="replay-diff-loading-placeholder">
  39. <LoadingIndicator />
  40. </StyledNegativeSpaceContainer>
  41. </InterimSection>
  42. }
  43. />
  44. </ReactLazyLoad>
  45. </ErrorBoundary>
  46. );
  47. }
  48. export const StyledNegativeSpaceContainer = styled(NegativeSpaceContainer)`
  49. height: ${REPLAY_LOADING_HEIGHT}px;
  50. margin-bottom: ${space(2)};
  51. `;