index.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. import ErrorBoundary from 'sentry/components/errorBoundary';
  2. import ReplayTimeline from 'sentry/components/replays/breadcrumbs/replayTimeline';
  3. import ReplayView from 'sentry/components/replays/replayView';
  4. import useFullscreen from 'sentry/utils/replays/hooks/useFullscreen';
  5. import Breadcrumbs from 'sentry/views/replays/detail/breadcrumbs';
  6. import FocusArea from 'sentry/views/replays/detail/focusArea';
  7. import FocusTabs from 'sentry/views/replays/detail/focusTabs';
  8. import AsideTabsV2 from './asideTabs_v2';
  9. import Container from './container';
  10. import {
  11. BreadcrumbSection,
  12. ContentSection,
  13. PageRow,
  14. SIDEBAR_MIN_WIDTH,
  15. SidebarSection,
  16. TimelineSection,
  17. TOPBAR_MIN_HEIGHT,
  18. TopbarSection,
  19. VideoSection,
  20. } from './pageSections';
  21. import ResizePanel from './resizePanel';
  22. type Layout =
  23. /**
  24. * ### Sidebar
  25. * ┌───────────────────┐
  26. * │ Timeline │
  27. * ├──────────┬────────┤
  28. * │ Details > Video │
  29. * │ > │
  30. * │ >^^^^^^^^┤
  31. * │ > Crumbs │
  32. * │ > │
  33. * └──────────┴────────┘
  34. */
  35. | 'sidebar'
  36. /**
  37. * ### Topbar
  38. *┌────────────────────┐
  39. *│ Timeline │
  40. *├───────────┬────────┤
  41. *│ Video │ Crumbs │
  42. *│ │ │
  43. *├^^^^^^^^^^^^^^^^^^^^┤
  44. *│ Details │
  45. *│ │
  46. *└────────────────────┘
  47. */
  48. | 'topbar'
  49. /**
  50. * ### Sidebar Left
  51. * ┌───────────────────┐
  52. * │ Timeline │
  53. * ├────────┬──────────┤
  54. * │ Video > Details │
  55. * │ > │
  56. * │^^^^^^^ > |
  57. * │ Crumbs > │
  58. * │ > │
  59. * └────────┴──────────┘
  60. */
  61. | 'sidebar_left';
  62. type Props = {
  63. layout?: Layout;
  64. showCrumbs?: boolean;
  65. showTimeline?: boolean;
  66. showVideo?: boolean;
  67. };
  68. function ReplayLayout({
  69. layout = 'topbar',
  70. showCrumbs = true,
  71. showTimeline = true,
  72. showVideo = true,
  73. }: Props) {
  74. const {ref: fullscreenRef, isFullscreen, toggle: toggleFullscreen} = useFullscreen();
  75. const timeline = showTimeline ? (
  76. <TimelineSection>
  77. <ErrorBoundary mini>
  78. <ReplayTimeline />
  79. </ErrorBoundary>
  80. </TimelineSection>
  81. ) : null;
  82. const video = showVideo ? (
  83. <VideoSection ref={fullscreenRef}>
  84. <ErrorBoundary mini>
  85. <ReplayView toggleFullscreen={toggleFullscreen} isFullscreen={isFullscreen} />
  86. </ErrorBoundary>
  87. </VideoSection>
  88. ) : null;
  89. const crumbs = showCrumbs ? (
  90. <BreadcrumbSection>
  91. <ErrorBoundary mini>
  92. <Breadcrumbs />
  93. </ErrorBoundary>
  94. </BreadcrumbSection>
  95. ) : null;
  96. const content = (
  97. <ContentSection>
  98. <ErrorBoundary mini>
  99. <FocusTabs />
  100. <FocusArea />
  101. </ErrorBoundary>
  102. </ContentSection>
  103. );
  104. if (layout === 'sidebar') {
  105. return (
  106. <Container>
  107. {timeline}
  108. <PageRow>
  109. {content}
  110. <ResizePanel direction="w" minWidth={SIDEBAR_MIN_WIDTH}>
  111. <SidebarSection>
  112. <AsideTabsV2 showCrumbs={showCrumbs} showVideo={showVideo} />
  113. </SidebarSection>
  114. </ResizePanel>
  115. </PageRow>
  116. </Container>
  117. );
  118. }
  119. if (layout === 'sidebar_left') {
  120. return (
  121. <Container>
  122. {timeline}
  123. <PageRow>
  124. <ResizePanel direction="e" minWidth={SIDEBAR_MIN_WIDTH}>
  125. <SidebarSection>
  126. <AsideTabsV2 showCrumbs={showCrumbs} showVideo={showVideo} />
  127. </SidebarSection>
  128. </ResizePanel>
  129. {content}
  130. </PageRow>
  131. </Container>
  132. );
  133. }
  134. // layout === 'topbar' or default
  135. return (
  136. <Container>
  137. {timeline}
  138. <ResizePanel
  139. direction="s"
  140. minHeight={TOPBAR_MIN_HEIGHT}
  141. modifierClass="overlapDown"
  142. >
  143. <TopbarSection>
  144. {video}
  145. {crumbs}
  146. </TopbarSection>
  147. </ResizePanel>
  148. {content}
  149. </Container>
  150. );
  151. }
  152. export default ReplayLayout;