groupEventDetails.tsx 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. import {Fragment, useEffect} from 'react';
  2. import {browserHistory, RouteComponentProps} from 'react-router';
  3. import styled from '@emotion/styled';
  4. import isEqual from 'lodash/isEqual';
  5. import ArchivedBox from 'sentry/components/archivedBox';
  6. import GroupEventDetailsLoadingError from 'sentry/components/errors/groupEventDetailsLoadingError';
  7. import {withMeta} from 'sentry/components/events/meta/metaProxy';
  8. import HookOrDefault from 'sentry/components/hookOrDefault';
  9. import * as Layout from 'sentry/components/layouts/thirds';
  10. import LoadingIndicator from 'sentry/components/loadingIndicator';
  11. import {TransactionProfileIdProvider} from 'sentry/components/profiling/transactionProfileIdProvider';
  12. import ResolutionBox from 'sentry/components/resolutionBox';
  13. import useSentryAppComponentsData from 'sentry/stores/useSentryAppComponentsData';
  14. import {space} from 'sentry/styles/space';
  15. import {
  16. Group,
  17. GroupActivityReprocess,
  18. GroupReprocessing,
  19. Organization,
  20. Project,
  21. } from 'sentry/types';
  22. import {Event} from 'sentry/types/event';
  23. import {defined} from 'sentry/utils';
  24. import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig';
  25. import {QuickTraceContext} from 'sentry/utils/performance/quickTrace/quickTraceContext';
  26. import QuickTraceQuery from 'sentry/utils/performance/quickTrace/quickTraceQuery';
  27. import {VisuallyCompleteWithData} from 'sentry/utils/performanceForSentry';
  28. import usePrevious from 'sentry/utils/usePrevious';
  29. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  30. import GroupEventDetailsContent from 'sentry/views/issueDetails/groupEventDetails/groupEventDetailsContent';
  31. import GroupEventHeader from 'sentry/views/issueDetails/groupEventHeader';
  32. import GroupSidebar from 'sentry/views/issueDetails/groupSidebar';
  33. import ReprocessingProgress from '../reprocessingProgress';
  34. import {
  35. getEventEnvironment,
  36. getGroupMostRecentActivity,
  37. ReprocessingStatus,
  38. useEnvironmentsFromUrl,
  39. } from '../utils';
  40. const EscalatingIssuesFeedback = HookOrDefault({
  41. hookName: 'component:escalating-issues-banner-feedback',
  42. });
  43. export interface GroupEventDetailsProps
  44. extends RouteComponentProps<{groupId: string; eventId?: string}, {}> {
  45. eventError: boolean;
  46. group: Group;
  47. groupReprocessingStatus: ReprocessingStatus;
  48. loadingEvent: boolean;
  49. onRetry: () => void;
  50. organization: Organization;
  51. project: Project;
  52. event?: Event;
  53. }
  54. function GroupEventDetails(props: GroupEventDetailsProps) {
  55. const {
  56. group,
  57. project,
  58. organization,
  59. location,
  60. event,
  61. groupReprocessingStatus,
  62. loadingEvent,
  63. onRetry,
  64. eventError,
  65. params,
  66. } = props;
  67. const eventWithMeta = withMeta(event);
  68. // Reprocessing
  69. const hasReprocessingV2Feature = organization.features?.includes('reprocessing-v2');
  70. const {activity: activities} = group;
  71. const mostRecentActivity = getGroupMostRecentActivity(activities);
  72. const projectId = project.id;
  73. const environments = useEnvironmentsFromUrl();
  74. const prevEnvironment = usePrevious(environments);
  75. const prevEvent = usePrevious(event);
  76. // load the data
  77. useSentryAppComponentsData({projectId});
  78. // If environments are being actively changed and will no longer contain the
  79. // current event's environment, redirect to latest
  80. useEffect(() => {
  81. const environmentsHaveChanged = !isEqual(prevEnvironment, environments);
  82. // If environments are being actively changed and will no longer contain the
  83. // current event's environment, redirect to latest
  84. if (
  85. environmentsHaveChanged &&
  86. prevEvent &&
  87. params.eventId &&
  88. !['latest', 'oldest'].includes(params.eventId)
  89. ) {
  90. const shouldRedirect =
  91. environments.length > 0 &&
  92. !environments.find(env => env === getEventEnvironment(prevEvent as Event));
  93. if (shouldRedirect) {
  94. browserHistory.replace(
  95. normalizeUrl({
  96. pathname: `/organizations/${organization.slug}/issues/${params.groupId}/`,
  97. query: location.query,
  98. })
  99. );
  100. return;
  101. }
  102. }
  103. }, [
  104. prevEnvironment,
  105. environments,
  106. location.query,
  107. organization.slug,
  108. params,
  109. prevEvent,
  110. ]);
  111. const renderGroupStatusBanner = () => {
  112. if (group.status === 'ignored') {
  113. return (
  114. <GroupStatusBannerWrapper>
  115. <ArchivedBox
  116. substatus={group.substatus}
  117. statusDetails={group.statusDetails}
  118. organization={organization}
  119. />
  120. </GroupStatusBannerWrapper>
  121. );
  122. }
  123. if (group.status === 'resolved') {
  124. return (
  125. <GroupStatusBannerWrapper>
  126. <ResolutionBox
  127. statusDetails={group.statusDetails}
  128. activities={group.activity}
  129. projectId={project.id}
  130. />
  131. </GroupStatusBannerWrapper>
  132. );
  133. }
  134. return null;
  135. };
  136. const renderContent = () => {
  137. if (loadingEvent) {
  138. return <LoadingIndicator />;
  139. }
  140. if (eventError) {
  141. return (
  142. <GroupEventDetailsLoadingError environments={environments} onRetry={onRetry} />
  143. );
  144. }
  145. return (
  146. <GroupEventDetailsContent group={group} event={eventWithMeta} project={project} />
  147. );
  148. };
  149. const issueTypeConfig = getConfigForIssueType(group, project);
  150. return (
  151. <TransactionProfileIdProvider
  152. projectId={event?.projectID}
  153. transactionId={event?.type === 'transaction' ? event.id : undefined}
  154. timestamp={event?.dateReceived}
  155. >
  156. <VisuallyCompleteWithData
  157. id="IssueDetails-EventBody"
  158. hasData={!loadingEvent && !eventError && defined(eventWithMeta)}
  159. isLoading={loadingEvent}
  160. >
  161. <StyledLayoutBody data-test-id="group-event-details">
  162. {hasReprocessingV2Feature &&
  163. groupReprocessingStatus === ReprocessingStatus.REPROCESSING ? (
  164. <ReprocessingProgress
  165. totalEvents={(mostRecentActivity as GroupActivityReprocess).data.eventCount}
  166. pendingEvents={
  167. (group.statusDetails as GroupReprocessing['statusDetails']).pendingEvents
  168. }
  169. />
  170. ) : (
  171. <Fragment>
  172. <QuickTraceQuery
  173. event={eventWithMeta}
  174. location={location}
  175. orgSlug={organization.slug}
  176. >
  177. {results => {
  178. return (
  179. <StyledLayoutMain>
  180. {renderGroupStatusBanner()}
  181. <EscalatingIssuesFeedback
  182. organization={organization}
  183. group={group}
  184. />
  185. <QuickTraceContext.Provider value={results}>
  186. {eventWithMeta && issueTypeConfig.stats.enabled && (
  187. <GroupEventHeader
  188. group={group}
  189. event={eventWithMeta}
  190. project={project}
  191. />
  192. )}
  193. {renderContent()}
  194. </QuickTraceContext.Provider>
  195. </StyledLayoutMain>
  196. );
  197. }}
  198. </QuickTraceQuery>
  199. <StyledLayoutSide>
  200. <GroupSidebar
  201. organization={organization}
  202. project={project}
  203. group={group}
  204. event={eventWithMeta}
  205. environments={environments}
  206. />
  207. </StyledLayoutSide>
  208. </Fragment>
  209. )}
  210. </StyledLayoutBody>
  211. </VisuallyCompleteWithData>
  212. </TransactionProfileIdProvider>
  213. );
  214. }
  215. const StyledLayoutBody = styled(Layout.Body)`
  216. /* Makes the borders align correctly */
  217. padding: 0 !important;
  218. @media (min-width: ${p => p.theme.breakpoints.large}) {
  219. align-content: stretch;
  220. }
  221. `;
  222. const GroupStatusBannerWrapper = styled('div')`
  223. margin-bottom: ${space(2)};
  224. `;
  225. const StyledLayoutMain = styled(Layout.Main)`
  226. padding-top: ${space(2)};
  227. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  228. padding-top: ${space(1)};
  229. }
  230. @media (min-width: ${p => p.theme.breakpoints.large}) {
  231. border-right: 1px solid ${p => p.theme.border};
  232. padding-right: 0;
  233. }
  234. `;
  235. const StyledLayoutSide = styled(Layout.Side)`
  236. padding: ${space(3)} ${space(2)} ${space(3)};
  237. @media (min-width: ${p => p.theme.breakpoints.large}) {
  238. padding-right: ${space(4)};
  239. padding-left: 0;
  240. }
  241. `;
  242. export default GroupEventDetails;