page.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. import {ReactNode} from 'react';
  2. import styled from '@emotion/styled';
  3. import UserBadge from 'sentry/components/idBadge/userBadge';
  4. import * as Layout from 'sentry/components/layouts/thirds';
  5. import DeleteButton from 'sentry/components/replays/header/deleteButton';
  6. import DetailsPageBreadcrumbs from 'sentry/components/replays/header/detailsPageBreadcrumbs';
  7. import FeedbackButton from 'sentry/components/replays/header/feedbackButton';
  8. import HeaderPlaceholder from 'sentry/components/replays/header/headerPlaceholder';
  9. import ReplayMetaData from 'sentry/components/replays/header/replayMetaData';
  10. import ShareButton from 'sentry/components/replays/shareButton';
  11. import FrameWalker from 'sentry/components/replays/walker/frameWalker';
  12. import StringWalker from 'sentry/components/replays/walker/stringWalker';
  13. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  14. import {t} from 'sentry/locale';
  15. import {space} from 'sentry/styles/space';
  16. import type {ReplayFrame} from 'sentry/utils/replays/types';
  17. import type {ReplayError, ReplayRecord} from 'sentry/views/replays/types';
  18. type Props = {
  19. children: ReactNode;
  20. orgSlug: string;
  21. projectSlug: string | null;
  22. replayErrors: ReplayError[];
  23. replayRecord: undefined | ReplayRecord;
  24. frames?: ReplayFrame[];
  25. };
  26. function Page({
  27. children,
  28. frames,
  29. orgSlug,
  30. replayRecord,
  31. projectSlug,
  32. replayErrors,
  33. }: Props) {
  34. const title = replayRecord
  35. ? `${replayRecord.id} — Session Replay — ${orgSlug}`
  36. : `Session Replay — ${orgSlug}`;
  37. const header = (
  38. <Header>
  39. <DetailsPageBreadcrumbs orgSlug={orgSlug} replayRecord={replayRecord} />
  40. <ButtonActionsWrapper>
  41. <ShareButton />
  42. <FeedbackButton />
  43. {replayRecord?.id && projectSlug && (
  44. <DeleteButton replayId={replayRecord.id} projectSlug={projectSlug} />
  45. )}
  46. </ButtonActionsWrapper>
  47. {replayRecord ? (
  48. <UserBadge
  49. avatarSize={32}
  50. displayName={
  51. <Layout.Title>
  52. {replayRecord.user.display_name || t('Unknown User')}
  53. </Layout.Title>
  54. }
  55. user={{
  56. name: replayRecord.user.display_name || '',
  57. email: replayRecord.user.email || '',
  58. username: replayRecord.user.username || '',
  59. ip_address: replayRecord.user.ip || '',
  60. id: replayRecord.user.id || '',
  61. }}
  62. // this is the subheading for the avatar, so displayEmail in this case is a misnomer
  63. displayEmail={
  64. <Cols>
  65. {frames?.length ? (
  66. <FrameWalker replayRecord={replayRecord} frames={frames} />
  67. ) : (
  68. <StringWalker urls={replayRecord.urls} />
  69. )}
  70. </Cols>
  71. }
  72. />
  73. ) : (
  74. <HeaderPlaceholder width="100%" height="58px" />
  75. )}
  76. <ReplayMetaData replayRecord={replayRecord} replayErrors={replayErrors} />
  77. </Header>
  78. );
  79. return (
  80. <SentryDocumentTitle title={title}>
  81. <FullViewport>
  82. {header}
  83. {children}
  84. </FullViewport>
  85. </SentryDocumentTitle>
  86. );
  87. }
  88. const Header = styled(Layout.Header)`
  89. gap: ${space(1)};
  90. padding-bottom: ${space(1.5)};
  91. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  92. gap: ${space(1)} ${space(3)};
  93. padding: ${space(2)} ${space(2)} ${space(1.5)} ${space(2)};
  94. }
  95. `;
  96. const Cols = styled('div')`
  97. display: flex;
  98. flex-direction: column;
  99. gap: ${space(0.25)};
  100. `;
  101. // TODO(replay); This could make a lot of sense to put inside HeaderActions by default
  102. const ButtonActionsWrapper = styled(Layout.HeaderActions)`
  103. flex-direction: row;
  104. justify-content: flex-end;
  105. gap: ${space(1)};
  106. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  107. margin-bottom: 0;
  108. }
  109. `;
  110. const FullViewport = styled('div')`
  111. height: 100vh;
  112. width: 100%;
  113. display: grid;
  114. grid-template-rows: auto 1fr;
  115. overflow: hidden;
  116. /*
  117. * The footer component is a sibling of this div.
  118. * Remove it so the replay can take up the
  119. * entire screen.
  120. */
  121. ~ footer {
  122. display: none;
  123. }
  124. /*
  125. TODO: Set \`body { overflow: hidden; }\` so that the body doesn't wiggle
  126. when you try to scroll something that is non-scrollable.
  127. */
  128. `;
  129. export default Page;