page.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import type {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 ConfigureReplayCard from 'sentry/components/replays/configureReplayCard';
  7. import DeleteButton from 'sentry/components/replays/header/deleteButton';
  8. import DetailsPageBreadcrumbs from 'sentry/components/replays/header/detailsPageBreadcrumbs';
  9. import FeedbackButton from 'sentry/components/replays/header/feedbackButton';
  10. import HeaderPlaceholder from 'sentry/components/replays/header/headerPlaceholder';
  11. import ReplayMetaData from 'sentry/components/replays/header/replayMetaData';
  12. import ShareButton from 'sentry/components/replays/shareButton';
  13. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  14. import {t} from 'sentry/locale';
  15. import {space} from 'sentry/styles/space';
  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. };
  24. function Page({children, orgSlug, replayRecord, projectSlug, replayErrors}: Props) {
  25. const title = replayRecord
  26. ? `${replayRecord.id} — Session Replay — ${orgSlug}`
  27. : `Session Replay — ${orgSlug}`;
  28. const header = replayRecord?.is_archived ? (
  29. <Header>
  30. <DetailsPageBreadcrumbs orgSlug={orgSlug} replayRecord={replayRecord} />
  31. </Header>
  32. ) : (
  33. <Header>
  34. <DetailsPageBreadcrumbs orgSlug={orgSlug} replayRecord={replayRecord} />
  35. <ButtonActionsWrapper>
  36. <ShareButton />
  37. <FeedbackButton />
  38. <ConfigureReplayCard />
  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. hideEmail
  59. />
  60. ) : (
  61. <HeaderPlaceholder width="100%" height="58px" />
  62. )}
  63. <ReplayMetaData replayRecord={replayRecord} replayErrors={replayErrors} />
  64. </Header>
  65. );
  66. return (
  67. <SentryDocumentTitle title={title}>
  68. <FullViewport>
  69. {header}
  70. {children}
  71. </FullViewport>
  72. </SentryDocumentTitle>
  73. );
  74. }
  75. const Header = styled(Layout.Header)`
  76. gap: ${space(1)};
  77. padding-bottom: ${space(1.5)};
  78. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  79. gap: ${space(1)} ${space(3)};
  80. padding: ${space(2)} ${space(2)} ${space(1.5)} ${space(2)};
  81. }
  82. `;
  83. // TODO(replay); This could make a lot of sense to put inside HeaderActions by default
  84. const ButtonActionsWrapper = styled(Layout.HeaderActions)`
  85. flex-direction: row;
  86. justify-content: flex-end;
  87. gap: ${space(1)};
  88. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  89. margin-bottom: 0;
  90. }
  91. `;
  92. export default Page;