page.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 {t} from 'sentry/locale';
  14. import {space} from 'sentry/styles/space';
  15. import type {ReplayError, ReplayRecord} from 'sentry/views/replays/types';
  16. type Props = {
  17. children: ReactNode;
  18. orgSlug: string;
  19. projectSlug: string | null;
  20. replayErrors: ReplayError[];
  21. replayRecord: undefined | ReplayRecord;
  22. };
  23. function Page({children, orgSlug, replayRecord, projectSlug, replayErrors}: Props) {
  24. const title = replayRecord
  25. ? `${replayRecord.id} — Session Replay — ${orgSlug}`
  26. : `Session Replay — ${orgSlug}`;
  27. const header = replayRecord?.is_archived ? (
  28. <Header>
  29. <DetailsPageBreadcrumbs orgSlug={orgSlug} replayRecord={replayRecord} />
  30. </Header>
  31. ) : (
  32. <Header>
  33. <DetailsPageBreadcrumbs orgSlug={orgSlug} replayRecord={replayRecord} />
  34. <ButtonActionsWrapper>
  35. <ShareButton />
  36. <FeedbackButton />
  37. {replayRecord?.id && projectSlug && (
  38. <DeleteButton replayId={replayRecord.id} projectSlug={projectSlug} />
  39. )}
  40. </ButtonActionsWrapper>
  41. {replayRecord ? (
  42. <UserBadge
  43. avatarSize={32}
  44. displayName={
  45. <Layout.Title>
  46. {replayRecord.user.display_name || t('Anonymous User')}
  47. </Layout.Title>
  48. }
  49. user={{
  50. name: replayRecord.user.display_name || '',
  51. email: replayRecord.user.email || '',
  52. username: replayRecord.user.username || '',
  53. ip_address: replayRecord.user.ip || '',
  54. id: replayRecord.user.id || '',
  55. }}
  56. hideEmail
  57. />
  58. ) : (
  59. <HeaderPlaceholder width="100%" height="58px" />
  60. )}
  61. <ReplayMetaData replayRecord={replayRecord} replayErrors={replayErrors} />
  62. </Header>
  63. );
  64. return (
  65. <SentryDocumentTitle title={title}>
  66. <FullViewport>
  67. {header}
  68. {children}
  69. </FullViewport>
  70. </SentryDocumentTitle>
  71. );
  72. }
  73. const Header = styled(Layout.Header)`
  74. gap: ${space(1)};
  75. padding-bottom: ${space(1.5)};
  76. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  77. gap: ${space(1)} ${space(3)};
  78. padding: ${space(2)} ${space(2)} ${space(1.5)} ${space(2)};
  79. }
  80. `;
  81. // TODO(replay); This could make a lot of sense to put inside HeaderActions by default
  82. const ButtonActionsWrapper = styled(Layout.HeaderActions)`
  83. flex-direction: row;
  84. justify-content: flex-end;
  85. gap: ${space(1)};
  86. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  87. margin-bottom: 0;
  88. }
  89. `;
  90. export default Page;