groupEventDetails.tsx 8.6 KB

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