page.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import {ReactNode} from 'react';
  2. import styled from '@emotion/styled';
  3. import UserBadge from 'sentry/components/idBadge/userBadge';
  4. import FullViewport from 'sentry/components/layouts/fullViewport';
  5. import * as Layout from 'sentry/components/layouts/thirds';
  6. import DeleteButton from 'sentry/components/replays/header/deleteButton';
  7. import DetailsPageBreadcrumbs from 'sentry/components/replays/header/detailsPageBreadcrumbs';
  8. import FeedbackButton from 'sentry/components/replays/header/feedbackButton';
  9. import HeaderPlaceholder from 'sentry/components/replays/header/headerPlaceholder';
  10. import ReplayMetaData from 'sentry/components/replays/header/replayMetaData';
  11. import ShareButton from 'sentry/components/replays/shareButton';
  12. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  13. import TimeSince from 'sentry/components/timeSince';
  14. import {IconCalendar} from 'sentry/icons';
  15. import {t} from 'sentry/locale';
  16. import {space} from 'sentry/styles/space';
  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. };
  25. function Page({children, orgSlug, replayRecord, projectSlug, replayErrors}: Props) {
  26. const title = replayRecord
  27. ? `${replayRecord.id} — Session Replay — ${orgSlug}`
  28. : `Session Replay — ${orgSlug}`;
  29. const header = replayRecord?.is_archived ? (
  30. <Header>
  31. <DetailsPageBreadcrumbs orgSlug={orgSlug} replayRecord={replayRecord} />
  32. </Header>
  33. ) : (
  34. <Header>
  35. <DetailsPageBreadcrumbs orgSlug={orgSlug} replayRecord={replayRecord} />
  36. <ButtonActionsWrapper>
  37. <ShareButton />
  38. <FeedbackButton />
  39. {replayRecord?.id && projectSlug && (
  40. <DeleteButton replayId={replayRecord.id} projectSlug={projectSlug} />
  41. )}
  42. </ButtonActionsWrapper>
  43. {replayRecord ? (
  44. <UserBadge
  45. avatarSize={32}
  46. displayName={
  47. <Layout.Title>
  48. {replayRecord.user.display_name || t('Anonymous User')}
  49. </Layout.Title>
  50. }
  51. user={{
  52. name: replayRecord.user.display_name || '',
  53. email: replayRecord.user.email || '',
  54. username: replayRecord.user.username || '',
  55. ip_address: replayRecord.user.ip || '',
  56. id: replayRecord.user.id || '',
  57. }}
  58. // this is the subheading for the avatar, so displayEmail in this case is a misnomer
  59. displayEmail={
  60. <div>
  61. {replayRecord ? (
  62. <TimeContainer>
  63. <IconCalendar color="gray300" size="xs" />
  64. <StyledTimeSince
  65. date={replayRecord.started_at}
  66. isTooltipHoverable
  67. unitStyle="regular"
  68. />
  69. </TimeContainer>
  70. ) : (
  71. <HeaderPlaceholder width="80px" height="16px" />
  72. )}
  73. </div>
  74. }
  75. />
  76. ) : (
  77. <HeaderPlaceholder width="100%" height="58px" />
  78. )}
  79. <ReplayMetaData replayRecord={replayRecord} replayErrors={replayErrors} />
  80. </Header>
  81. );
  82. return (
  83. <SentryDocumentTitle title={title}>
  84. <FullViewport>
  85. {header}
  86. {children}
  87. </FullViewport>
  88. </SentryDocumentTitle>
  89. );
  90. }
  91. const Header = styled(Layout.Header)`
  92. gap: ${space(1)};
  93. padding-bottom: ${space(1.5)};
  94. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  95. gap: ${space(1)} ${space(3)};
  96. padding: ${space(2)} ${space(2)} ${space(1.5)} ${space(2)};
  97. }
  98. `;
  99. // TODO(replay); This could make a lot of sense to put inside HeaderActions by default
  100. const ButtonActionsWrapper = styled(Layout.HeaderActions)`
  101. flex-direction: row;
  102. justify-content: flex-end;
  103. gap: ${space(1)};
  104. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  105. margin-bottom: 0;
  106. }
  107. `;
  108. const TimeContainer = styled('div')`
  109. display: flex;
  110. gap: ${space(0.5)};
  111. align-items: center;
  112. `;
  113. const StyledTimeSince = styled(TimeSince)`
  114. font-size: ${p => p.theme.fontSizeMedium};
  115. `;
  116. export default Page;