page.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 DetailsPageBreadcrumbs from 'sentry/components/replays/header/detailsPageBreadcrumbs';
  6. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  7. import space from 'sentry/styles/space';
  8. import type {Crumb} from 'sentry/types/breadcrumbs';
  9. import type {EventTransaction} from 'sentry/types/event';
  10. import getUrlPathname from 'sentry/utils/getUrlPathname';
  11. import EventMetaData from './eventMetaData';
  12. type Props = {
  13. children: ReactNode;
  14. orgId: string;
  15. crumbs?: Crumb[];
  16. duration?: number;
  17. event?: EventTransaction;
  18. };
  19. function Page({children, crumbs, duration, event, orgId}: Props) {
  20. const title = event ? `${event.id} - Replays - ${orgId}` : `Replays - ${orgId}`;
  21. const urlTag = event?.tags?.find(({key}) => key === 'url');
  22. const pathname = getUrlPathname(urlTag?.value ?? '') ?? '';
  23. const header = (
  24. <Header>
  25. <HeaderContent>
  26. <DetailsPageBreadcrumbs orgId={orgId} event={event} />
  27. </HeaderContent>
  28. <ButtonActionsWrapper>
  29. <FeatureFeedback featureName="replay" buttonProps={{size: 'sm'}} />
  30. </ButtonActionsWrapper>
  31. <SubHeading>{pathname}</SubHeading>
  32. <MetaDataColumn>
  33. <EventMetaData crumbs={crumbs} duration={duration} event={event} />
  34. </MetaDataColumn>
  35. </Header>
  36. );
  37. return (
  38. <SentryDocumentTitle title={title}>
  39. <FullViewport>
  40. {header}
  41. {children}
  42. </FullViewport>
  43. </SentryDocumentTitle>
  44. );
  45. }
  46. const Header = styled(Layout.Header)`
  47. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  48. padding-bottom: ${space(1.5)};
  49. }
  50. `;
  51. const HeaderContent = styled(Layout.HeaderContent)`
  52. margin-bottom: 0;
  53. `;
  54. // TODO(replay); This could make a lot of sense to put inside HeaderActions by default
  55. const ButtonActionsWrapper = styled(Layout.HeaderActions)`
  56. display: grid;
  57. grid-template-columns: repeat(2, max-content);
  58. justify-content: flex-end;
  59. `;
  60. const SubHeading = styled('div')`
  61. font-size: ${p => p.theme.fontSizeMedium};
  62. line-height: ${p => p.theme.text.lineHeightBody};
  63. color: ${p => p.theme.subText};
  64. align-self: end;
  65. ${p => p.theme.overflowEllipsis};
  66. `;
  67. const MetaDataColumn = styled(Layout.HeaderActions)`
  68. padding-left: ${space(3)};
  69. align-self: end;
  70. `;
  71. const FullViewport = styled('div')`
  72. height: 100vh;
  73. width: 100%;
  74. display: grid;
  75. grid-template-rows: auto 1fr;
  76. overflow: hidden;
  77. /*
  78. * The footer component is a sibling of this div.
  79. * Remove it so the replay can take up the
  80. * entire screen.
  81. */
  82. ~ footer {
  83. display: none;
  84. }
  85. /*
  86. TODO: Set \`body { overflow: hidden; }\` so that the body doesn't wiggle
  87. when you try to scroll something that is non-scrollable.
  88. */
  89. `;
  90. export default Page;