page.tsx 3.7 KB

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