page.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import {ReactNode} from 'react';
  2. import styled from '@emotion/styled';
  3. import {FeatureFeedback} from 'sentry/components/featureFeedback';
  4. import * as Layout from 'sentry/components/layouts/thirds';
  5. import DeleteButton from 'sentry/components/replays/deleteButton';
  6. import DetailsPageBreadcrumbs from 'sentry/components/replays/header/detailsPageBreadcrumbs';
  7. import {CrumbWalker} from 'sentry/components/replays/walker/urlWalker';
  8. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  9. import space from 'sentry/styles/space';
  10. import type {Crumb} from 'sentry/types/breadcrumbs';
  11. import ChooseLayout from 'sentry/views/replays/detail/layout/chooseLayout';
  12. import ReplayMetaData, {
  13. HeaderPlaceholder,
  14. } from 'sentry/views/replays/detail/replayMetaData';
  15. import type {ReplayRecord} from 'sentry/views/replays/types';
  16. type Props = {
  17. children: ReactNode;
  18. orgSlug: string;
  19. crumbs?: Crumb[];
  20. replayRecord?: ReplayRecord;
  21. };
  22. function Page({children, crumbs, orgSlug, replayRecord}: Props) {
  23. const title = replayRecord
  24. ? `${replayRecord.id} - Replays - ${orgSlug}`
  25. : `Replays - ${orgSlug}`;
  26. const header = (
  27. <Header>
  28. <HeaderContent>
  29. <DetailsPageBreadcrumbs orgSlug={orgSlug} replayRecord={replayRecord} />
  30. </HeaderContent>
  31. <ButtonActionsWrapper>
  32. <DeleteButton />
  33. <ChooseLayout />
  34. <FeatureFeedback featureName="replay" buttonProps={{size: 'xs'}} />
  35. </ButtonActionsWrapper>
  36. {replayRecord && crumbs ? (
  37. <CrumbWalker replayRecord={replayRecord} crumbs={crumbs} />
  38. ) : (
  39. <HeaderPlaceholder />
  40. )}
  41. <MetaDataColumn>
  42. <ReplayMetaData replayRecord={replayRecord} />
  43. </MetaDataColumn>
  44. </Header>
  45. );
  46. return (
  47. <SentryDocumentTitle title={title}>
  48. <FullViewport>
  49. {header}
  50. {children}
  51. </FullViewport>
  52. </SentryDocumentTitle>
  53. );
  54. }
  55. const Header = styled(Layout.Header)`
  56. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  57. padding: ${space(2)} ${space(2)} ${space(1.5)} ${space(2)};
  58. }
  59. `;
  60. const HeaderContent = styled(Layout.HeaderContent)`
  61. margin-bottom: 0;
  62. `;
  63. // TODO(replay); This could make a lot of sense to put inside HeaderActions by default
  64. const ButtonActionsWrapper = styled(Layout.HeaderActions)`
  65. display: grid;
  66. grid-template-columns: repeat(3, max-content);
  67. justify-content: flex-end;
  68. gap: ${space(1)};
  69. `;
  70. const MetaDataColumn = styled(Layout.HeaderActions)`
  71. padding-left: ${space(3)};
  72. align-self: end;
  73. `;
  74. const FullViewport = styled('div')`
  75. height: 100vh;
  76. width: 100%;
  77. display: grid;
  78. grid-template-rows: auto 1fr;
  79. overflow: hidden;
  80. /*
  81. * The footer component is a sibling of this div.
  82. * Remove it so the replay can take up the
  83. * entire screen.
  84. */
  85. ~ footer {
  86. display: none;
  87. }
  88. /*
  89. TODO: Set \`body { overflow: hidden; }\` so that the body doesn't wiggle
  90. when you try to scroll something that is non-scrollable.
  91. */
  92. `;
  93. export default Page;