page.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 {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 ? (
  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. {crumbs?.length ? (
  54. <CrumbWalker replayRecord={replayRecord} crumbs={crumbs} />
  55. ) : (
  56. <StringWalker urls={replayRecord.urls} />
  57. )}
  58. </Cols>
  59. }
  60. />
  61. ) : (
  62. <HeaderPlaceholder width="100%" height="58px" />
  63. )}
  64. <ReplayMetaData replayRecord={replayRecord} />
  65. </Header>
  66. );
  67. return (
  68. <SentryDocumentTitle title={title}>
  69. <FullViewport>
  70. {header}
  71. {children}
  72. </FullViewport>
  73. </SentryDocumentTitle>
  74. );
  75. }
  76. const Header = styled(Layout.Header)`
  77. gap: ${space(1)};
  78. padding-bottom: ${space(1.5)};
  79. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  80. gap: ${space(1)} ${space(3)};
  81. padding: ${space(2)} ${space(2)} ${space(1.5)} ${space(2)};
  82. }
  83. `;
  84. const Cols = styled('div')`
  85. display: flex;
  86. flex-direction: column;
  87. gap: ${space(0.25)};
  88. `;
  89. // TODO(replay); This could make a lot of sense to put inside HeaderActions by default
  90. const ButtonActionsWrapper = styled(Layout.HeaderActions)`
  91. flex-direction: row;
  92. justify-content: flex-end;
  93. gap: ${space(1)};
  94. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  95. margin-bottom: 0;
  96. }
  97. `;
  98. const FullViewport = styled('div')`
  99. height: 100vh;
  100. width: 100%;
  101. display: grid;
  102. grid-template-rows: auto 1fr;
  103. overflow: hidden;
  104. /*
  105. * The footer component is a sibling of this div.
  106. * Remove it so the replay can take up the
  107. * entire screen.
  108. */
  109. ~ footer {
  110. display: none;
  111. }
  112. /*
  113. TODO: Set \`body { overflow: hidden; }\` so that the body doesn't wiggle
  114. when you try to scroll something that is non-scrollable.
  115. */
  116. `;
  117. export default Page;