groupDetailsLayout.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import * as Layout from 'sentry/components/layouts/thirds';
  4. import {space} from 'sentry/styles/space';
  5. import type {Event} from 'sentry/types/event';
  6. import type {Group} from 'sentry/types/group';
  7. import type {Project} from 'sentry/types/project';
  8. import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig';
  9. import theme from 'sentry/utils/theme';
  10. import useMedia from 'sentry/utils/useMedia';
  11. import {useSyncedLocalStorageState} from 'sentry/utils/useSyncedLocalStorageState';
  12. import {EventDetailsHeader} from 'sentry/views/issueDetails/streamline/eventDetailsHeader';
  13. import {IssueEventNavigation} from 'sentry/views/issueDetails/streamline/eventNavigation';
  14. import {useEventQuery} from 'sentry/views/issueDetails/streamline/eventSearch';
  15. import StreamlinedGroupHeader from 'sentry/views/issueDetails/streamline/header/header';
  16. import StreamlinedSidebar from 'sentry/views/issueDetails/streamline/sidebar/sidebar';
  17. import {ToggleSidebar} from 'sentry/views/issueDetails/streamline/sidebar/toggleSidebar';
  18. import {getGroupReprocessingStatus} from 'sentry/views/issueDetails/utils';
  19. interface GroupDetailsLayoutProps {
  20. children: React.ReactNode;
  21. event: Event | undefined;
  22. group: Group;
  23. project: Project;
  24. }
  25. export function GroupDetailsLayout({
  26. group,
  27. event,
  28. project,
  29. children,
  30. }: GroupDetailsLayoutProps) {
  31. const searchQuery = useEventQuery({group});
  32. const [sidebarOpen] = useSyncedLocalStorageState('issue-details-sidebar-open', true);
  33. const isScreenSmall = useMedia(`(max-width: ${theme.breakpoints.large})`);
  34. const shouldDisplaySidebar = sidebarOpen || isScreenSmall;
  35. const issueTypeConfig = getConfigForIssueType(group, group.project);
  36. const groupReprocessingStatus = getGroupReprocessingStatus(group);
  37. return (
  38. <Fragment>
  39. <StreamlinedGroupHeader
  40. group={group}
  41. event={event ?? null}
  42. project={project}
  43. groupReprocessingStatus={groupReprocessingStatus}
  44. />
  45. <StyledLayoutBody data-test-id="group-event-details" sidebarOpen={sidebarOpen}>
  46. <div>
  47. <EventDetailsHeader event={event} group={group} project={project} />
  48. <GroupContent>
  49. <NavigationSidebarWrapper
  50. hasToggleSidebar={!issueTypeConfig.filterAndSearchHeader.enabled}
  51. >
  52. <IssueEventNavigation event={event} group={group} query={searchQuery} />
  53. {/* Since the event details header is disabled, display the sidebar toggle here */}
  54. {!issueTypeConfig.filterAndSearchHeader.enabled && (
  55. <ToggleSidebar size="sm" />
  56. )}
  57. </NavigationSidebarWrapper>
  58. <ContentPadding>{children}</ContentPadding>
  59. </GroupContent>
  60. </div>
  61. {shouldDisplaySidebar ? (
  62. <StreamlinedSidebar group={group} event={event} project={project} />
  63. ) : null}
  64. </StyledLayoutBody>
  65. </Fragment>
  66. );
  67. }
  68. const StyledLayoutBody = styled(Layout.Body)<{
  69. sidebarOpen: boolean;
  70. }>`
  71. padding: 0 !important;
  72. gap: 0 !important;
  73. @media (min-width: ${p => p.theme.breakpoints.large}) {
  74. align-content: stretch;
  75. grid-template-columns: minmax(100px, auto) ${p => (p.sidebarOpen ? '325px' : '0px')};
  76. }
  77. `;
  78. const GroupContent = styled('section')`
  79. background: ${p => p.theme.backgroundSecondary};
  80. display: flex;
  81. flex-direction: column;
  82. @media (min-width: ${p => p.theme.breakpoints.large}) {
  83. border-right: 1px solid ${p => p.theme.translucentBorder};
  84. }
  85. @media (max-width: ${p => p.theme.breakpoints.large}) {
  86. border-bottom-width: 1px solid ${p => p.theme.translucentBorder};
  87. }
  88. `;
  89. const NavigationSidebarWrapper = styled('div')<{
  90. hasToggleSidebar: boolean;
  91. }>`
  92. position: relative;
  93. display: flex;
  94. padding: ${p =>
  95. p.hasToggleSidebar
  96. ? `${space(1)} 0 ${space(0.5)} ${space(1.5)}`
  97. : `10px ${space(1.5)} ${space(0.25)} ${space(1.5)}`};
  98. `;
  99. const ContentPadding = styled('div')`
  100. min-height: 100vh;
  101. padding: 0 ${space(1.5)} ${space(1.5)} ${space(1.5)};
  102. `;