page.tsx 4.1 KB

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