groupDetails.tsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. import {cloneElement, Component, Fragment, isValidElement} from 'react';
  2. import {browserHistory, RouteComponentProps} from 'react-router';
  3. import styled from '@emotion/styled';
  4. import * as Sentry from '@sentry/react';
  5. import omit from 'lodash/omit';
  6. import * as PropTypes from 'prop-types';
  7. import {fetchOrganizationEnvironments} from 'sentry/actionCreators/environments';
  8. import {Client} from 'sentry/api';
  9. import LoadingError from 'sentry/components/loadingError';
  10. import LoadingIndicator from 'sentry/components/loadingIndicator';
  11. import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
  12. import MissingProjectMembership from 'sentry/components/projects/missingProjectMembership';
  13. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  14. import {Item, TabPanels, Tabs} from 'sentry/components/tabs';
  15. import {t} from 'sentry/locale';
  16. import SentryTypes from 'sentry/sentryTypes';
  17. import GroupStore from 'sentry/stores/groupStore';
  18. import space from 'sentry/styles/space';
  19. import {
  20. AvatarProject,
  21. Group,
  22. GroupActivityAssigned,
  23. GroupActivityType,
  24. IssueCategory,
  25. Organization,
  26. Project,
  27. } from 'sentry/types';
  28. import {Event} from 'sentry/types/event';
  29. import trackAdvancedAnalyticsEvent from 'sentry/utils/analytics/trackAdvancedAnalyticsEvent';
  30. import {getUtcDateString} from 'sentry/utils/dates';
  31. import {TableData} from 'sentry/utils/discover/discoverQuery';
  32. import EventView from 'sentry/utils/discover/eventView';
  33. import {doDiscoverQuery} from 'sentry/utils/discover/genericDiscoverQuery';
  34. import {getAnalyicsDataForEvent, getMessage, getTitle} from 'sentry/utils/events';
  35. import getDaysSinceDate from 'sentry/utils/getDaysSinceDate';
  36. import Projects from 'sentry/utils/projects';
  37. import recreateRoute from 'sentry/utils/recreateRoute';
  38. import withRouteAnalytics, {
  39. WithRouteAnalyticsProps,
  40. } from 'sentry/utils/routeAnalytics/withRouteAnalytics';
  41. import withApi from 'sentry/utils/withApi';
  42. import {ERROR_TYPES} from './constants';
  43. import GroupHeader from './header';
  44. import SampleEventAlert from './sampleEventAlert';
  45. import {Tab, TabPaths} from './types';
  46. import {
  47. fetchGroupEvent,
  48. getGroupReprocessingStatus,
  49. markEventSeen,
  50. ReprocessingStatus,
  51. } from './utils';
  52. /**
  53. * Return the integration type for the first assignment via integration
  54. */
  55. function getAssignmentIntegration(group: Group) {
  56. if (!group.activity) {
  57. return '';
  58. }
  59. const assignmentAcitivies = group.activity.filter(
  60. activity => activity.type === GroupActivityType.ASSIGNED
  61. ) as GroupActivityAssigned[];
  62. const integrationAssignments = assignmentAcitivies.find(
  63. activity => !!activity.data.integration
  64. );
  65. return integrationAssignments?.data.integration || '';
  66. }
  67. type Error = typeof ERROR_TYPES[keyof typeof ERROR_TYPES] | null;
  68. type Props = {
  69. api: Client;
  70. children: React.ReactNode;
  71. environments: string[];
  72. isGlobalSelectionReady: boolean;
  73. organization: Organization;
  74. projects: Project[];
  75. } & WithRouteAnalyticsProps &
  76. RouteComponentProps<{groupId: string; orgId: string; eventId?: string}, {}>;
  77. type State = {
  78. error: boolean;
  79. errorType: Error;
  80. eventError: boolean;
  81. group: Group | null;
  82. loading: boolean;
  83. loadingEvent: boolean;
  84. loadingGroup: boolean;
  85. loadingReplayIds: boolean;
  86. project: null | (Pick<Project, 'id' | 'slug'> & Partial<Pick<Project, 'platform'>>);
  87. replayIds: null | string[];
  88. event?: Event;
  89. };
  90. class GroupDetails extends Component<Props, State> {
  91. static childContextTypes = {
  92. group: SentryTypes.Group,
  93. location: PropTypes.object,
  94. };
  95. state = this.initialState;
  96. getChildContext() {
  97. return {
  98. group: this.state.group,
  99. location: this.props.location,
  100. };
  101. }
  102. componentDidMount() {
  103. // prevent duplicate analytics
  104. this.props.setDisableRouteAnalytics();
  105. // only track the view if we are loading the event early
  106. this.fetchData(this.canLoadEventEarly(this.props));
  107. if (this.props.organization.features.includes('session-replay-ui')) {
  108. this.fetchReplayIds();
  109. }
  110. this.updateReprocessingProgress();
  111. // Fetch environments early - used in GroupEventDetailsContainer
  112. fetchOrganizationEnvironments(this.props.api, this.props.organization.slug);
  113. }
  114. componentDidUpdate(prevProps: Props, prevState: State) {
  115. const globalSelectionReadyChanged =
  116. prevProps.isGlobalSelectionReady !== this.props.isGlobalSelectionReady;
  117. if (
  118. globalSelectionReadyChanged ||
  119. prevProps.location.pathname !== this.props.location.pathname
  120. ) {
  121. // Skip tracking for other navigation events like switching events
  122. this.fetchData(globalSelectionReadyChanged && this.canLoadEventEarly(this.props));
  123. }
  124. if (
  125. (!this.canLoadEventEarly(prevProps) && !prevState?.group && this.state.group) ||
  126. (prevProps.params?.eventId !== this.props.params?.eventId && this.state.group)
  127. ) {
  128. // if we are loading events we should record analytics after it's loaded
  129. this.getEvent(this.state.group).then(
  130. () => this.state.group?.project && this.trackView(this.state.group?.project)
  131. );
  132. }
  133. }
  134. componentWillUnmount() {
  135. GroupStore.reset();
  136. this.listener?.();
  137. if (this.refetchInterval) {
  138. window.clearInterval(this.refetchInterval);
  139. }
  140. }
  141. refetchInterval: number | null = null;
  142. get initialState(): State {
  143. return {
  144. group: null,
  145. loading: true,
  146. loadingReplayIds: true,
  147. loadingEvent: true,
  148. loadingGroup: true,
  149. error: false,
  150. eventError: false,
  151. errorType: null,
  152. project: null,
  153. replayIds: null,
  154. };
  155. }
  156. trackView(project: Project) {
  157. const {group, event} = this.state;
  158. const {organization, params, location} = this.props;
  159. const {alert_date, alert_rule_id, alert_type} = location.query;
  160. trackAdvancedAnalyticsEvent('issue_details.viewed', {
  161. organization,
  162. project_id: parseInt(project.id, 10),
  163. group_id: parseInt(params.groupId, 10),
  164. // group properties
  165. issue_category: group?.issueCategory ?? IssueCategory.ERROR,
  166. issue_status: group?.status,
  167. issue_age: group?.firstSeen ? getDaysSinceDate(group.firstSeen) : -1,
  168. issue_level: group?.level,
  169. is_assigned: !!group?.assignedTo,
  170. error_count: Number(group?.count || -1),
  171. error_has_replay: Boolean(event?.tags?.find(({key}) => key === 'replayId')),
  172. group_has_replay: Boolean(group?.tags?.find(({key}) => key === 'replayId')),
  173. num_comments: group ? group.numComments : -1,
  174. project_platform: group?.project.platform,
  175. has_external_issue: group?.annotations ? group?.annotations.length > 0 : false,
  176. has_owner: group?.owners ? group?.owners.length > 0 : false,
  177. integration_assignment_source: group ? getAssignmentIntegration(group) : '',
  178. // event properties
  179. ...getAnalyicsDataForEvent(event),
  180. // Alert properties track if the user came from email/slack alerts
  181. alert_date:
  182. typeof alert_date === 'string' ? getUtcDateString(Number(alert_date)) : undefined,
  183. alert_rule_id: typeof alert_rule_id === 'string' ? alert_rule_id : undefined,
  184. alert_type: typeof alert_type === 'string' ? alert_type : undefined,
  185. });
  186. }
  187. remountComponent = () => {
  188. this.setState(this.initialState);
  189. this.fetchData();
  190. };
  191. canLoadEventEarly(props: Props) {
  192. return !props.params.eventId || ['oldest', 'latest'].includes(props.params.eventId);
  193. }
  194. get groupDetailsEndpoint() {
  195. return `/issues/${this.props.params.groupId}/`;
  196. }
  197. get groupReleaseEndpoint() {
  198. return `/issues/${this.props.params.groupId}/first-last-release/`;
  199. }
  200. async getEvent(group?: Group) {
  201. if (group) {
  202. this.setState({loadingEvent: true, eventError: false});
  203. }
  204. const {params, environments, api} = this.props;
  205. const orgSlug = params.orgId;
  206. const groupId = params.groupId;
  207. const eventId = params.eventId ?? 'latest';
  208. const projectId = group?.project?.slug;
  209. try {
  210. const event = await fetchGroupEvent(
  211. api,
  212. orgSlug,
  213. groupId,
  214. eventId,
  215. environments,
  216. projectId
  217. );
  218. this.setState({event, loading: false, eventError: false, loadingEvent: false});
  219. } catch (err) {
  220. // This is an expected error, capture to Sentry so that it is not considered as an unhandled error
  221. Sentry.captureException(err);
  222. this.setState({eventError: true, loading: false, loadingEvent: false});
  223. }
  224. }
  225. getCurrentRouteInfo(group: Group): {baseUrl: string; currentTab: Tab} {
  226. const {organization, router, routes} = this.props;
  227. const {event} = this.state;
  228. const currentRoute = routes[routes.length - 1];
  229. let currentTab: Tab;
  230. // If we're in the tag details page ("/tags/:tagKey/")
  231. if (router.params.tagKey) {
  232. currentTab = Tab.TAGS;
  233. } else {
  234. currentTab =
  235. Object.values(Tab).find(tab => currentRoute.path === TabPaths[tab]) ??
  236. Tab.DETAILS;
  237. }
  238. const baseUrl = `/organizations/${organization.slug}/issues/${group.id}/${
  239. router.params.eventId && event ? `events/${event.id}/` : ''
  240. }`;
  241. return {baseUrl, currentTab};
  242. }
  243. updateReprocessingProgress() {
  244. const hasReprocessingV2Feature = this.hasReprocessingV2Feature();
  245. if (!hasReprocessingV2Feature) {
  246. return;
  247. }
  248. if (this.refetchInterval) {
  249. window.clearInterval(this.refetchInterval);
  250. }
  251. this.refetchInterval = window.setInterval(this.refetchGroup, 30000);
  252. }
  253. hasReprocessingV2Feature() {
  254. const {organization} = this.props;
  255. return organization.features?.includes('reprocessing-v2');
  256. }
  257. getReprocessingNewRoute(data: Group) {
  258. const {routes, location, params} = this.props;
  259. const {groupId} = params;
  260. const {id: nextGroupId} = data;
  261. const hasReprocessingV2Feature = this.hasReprocessingV2Feature();
  262. const reprocessingStatus = getGroupReprocessingStatus(data);
  263. const {currentTab, baseUrl} = this.getCurrentRouteInfo(data);
  264. if (groupId !== nextGroupId) {
  265. if (hasReprocessingV2Feature) {
  266. // Redirects to the Activities tab
  267. if (
  268. reprocessingStatus === ReprocessingStatus.REPROCESSED_AND_HASNT_EVENT &&
  269. currentTab !== Tab.ACTIVITY
  270. ) {
  271. return {
  272. pathname: `${baseUrl}${Tab.ACTIVITY}/`,
  273. query: {...params, groupId: nextGroupId},
  274. };
  275. }
  276. }
  277. return recreateRoute('', {
  278. routes,
  279. location,
  280. params: {...params, groupId: nextGroupId},
  281. });
  282. }
  283. if (hasReprocessingV2Feature) {
  284. if (
  285. reprocessingStatus === ReprocessingStatus.REPROCESSING &&
  286. currentTab !== Tab.DETAILS
  287. ) {
  288. return {
  289. pathname: baseUrl,
  290. query: params,
  291. };
  292. }
  293. if (
  294. reprocessingStatus === ReprocessingStatus.REPROCESSED_AND_HASNT_EVENT &&
  295. currentTab !== Tab.ACTIVITY &&
  296. currentTab !== Tab.USER_FEEDBACK
  297. ) {
  298. return {
  299. pathname: `${baseUrl}${Tab.ACTIVITY}/`,
  300. query: params,
  301. };
  302. }
  303. }
  304. return undefined;
  305. }
  306. getGroupQuery(): Record<string, string | string[]> {
  307. const {environments} = this.props;
  308. // Note, we do not want to include the environment key at all if there are no environments
  309. const query: Record<string, string | string[]> = {
  310. ...(environments ? {environment: environments} : {}),
  311. expand: ['inbox', 'owners'],
  312. collapse: 'release',
  313. };
  314. return query;
  315. }
  316. getFetchDataRequestErrorType(status: any): Error {
  317. if (!status) {
  318. return null;
  319. }
  320. if (status === 404) {
  321. return ERROR_TYPES.GROUP_NOT_FOUND;
  322. }
  323. if (status === 403) {
  324. return ERROR_TYPES.MISSING_MEMBERSHIP;
  325. }
  326. return null;
  327. }
  328. handleRequestError(error: any) {
  329. Sentry.captureException(error);
  330. const errorType = this.getFetchDataRequestErrorType(error?.status);
  331. this.setState({
  332. loadingGroup: false,
  333. loading: false,
  334. error: true,
  335. errorType,
  336. });
  337. }
  338. refetchGroup = async () => {
  339. const {loadingGroup, loading, loadingEvent, group} = this.state;
  340. if (
  341. group?.status !== ReprocessingStatus.REPROCESSING ||
  342. loadingGroup ||
  343. loading ||
  344. loadingEvent
  345. ) {
  346. return;
  347. }
  348. const {api} = this.props;
  349. this.setState({loadingGroup: true});
  350. try {
  351. const updatedGroup = await api.requestPromise(this.groupDetailsEndpoint, {
  352. query: this.getGroupQuery(),
  353. });
  354. const reprocessingNewRoute = this.getReprocessingNewRoute(updatedGroup);
  355. if (reprocessingNewRoute) {
  356. browserHistory.push(reprocessingNewRoute);
  357. return;
  358. }
  359. this.setState({group: updatedGroup, loadingGroup: false});
  360. } catch (error) {
  361. this.handleRequestError(error);
  362. }
  363. };
  364. async fetchGroupReleases() {
  365. const {api} = this.props;
  366. const releases = await api.requestPromise(this.groupReleaseEndpoint);
  367. GroupStore.onPopulateReleases(this.props.params.groupId, releases);
  368. }
  369. async fetchReplayIds() {
  370. const {api, location, organization, params} = this.props;
  371. const {groupId} = params;
  372. this.setState({loadingReplayIds: true});
  373. const eventView = EventView.fromNewQueryWithLocation(
  374. {
  375. id: '',
  376. name: `Errors within replay`,
  377. version: 2,
  378. fields: ['replayId', 'count()'],
  379. query: `issue.id:${groupId} !replayId:""`,
  380. projects: [],
  381. },
  382. location
  383. );
  384. try {
  385. const [data] = await doDiscoverQuery<TableData>(
  386. api,
  387. `/organizations/${organization.slug}/events/`,
  388. eventView.getEventsAPIPayload(location)
  389. );
  390. const replayIds = data.data.map(record => String(record.replayId));
  391. this.setState({
  392. replayIds,
  393. loadingReplayIds: false,
  394. });
  395. } catch (err) {
  396. this.setState({loadingReplayIds: false});
  397. }
  398. }
  399. async fetchData(trackView = false) {
  400. const {api, isGlobalSelectionReady, params} = this.props;
  401. // Need to wait for global selection store to be ready before making request
  402. if (!isGlobalSelectionReady) {
  403. return;
  404. }
  405. try {
  406. const eventPromise = this.canLoadEventEarly(this.props)
  407. ? this.getEvent()
  408. : undefined;
  409. const groupPromise = await api.requestPromise(this.groupDetailsEndpoint, {
  410. query: this.getGroupQuery(),
  411. });
  412. const [data] = await Promise.all([groupPromise, eventPromise]);
  413. const groupReleasePromise = this.fetchGroupReleases();
  414. const reprocessingNewRoute = this.getReprocessingNewRoute(data);
  415. if (reprocessingNewRoute) {
  416. browserHistory.push(reprocessingNewRoute);
  417. return;
  418. }
  419. const project = data.project;
  420. markEventSeen(api, params.orgId, project.slug, params.groupId);
  421. if (!project) {
  422. Sentry.withScope(() => {
  423. Sentry.captureException(new Error('Project not found'));
  424. });
  425. } else {
  426. const locationWithProject = {...this.props.location};
  427. if (
  428. locationWithProject.query.project === undefined &&
  429. locationWithProject.query._allp === undefined
  430. ) {
  431. // We use _allp as a temporary measure to know they came from the
  432. // issue list page with no project selected (all projects included in
  433. // filter).
  434. //
  435. // If it is not defined, we add the locked project id to the URL
  436. // (this is because if someone navigates directly to an issue on
  437. // single-project priveleges, then goes back - they were getting
  438. // assigned to the first project).
  439. //
  440. // If it is defined, we do not so that our back button will bring us
  441. // to the issue list page with no project selected instead of the
  442. // locked project.
  443. locationWithProject.query = {...locationWithProject.query, project: project.id};
  444. }
  445. // We delete _allp from the URL to keep the hack a bit cleaner, but
  446. // this is not an ideal solution and will ultimately be replaced with
  447. // something smarter.
  448. delete locationWithProject.query._allp;
  449. browserHistory.replace(locationWithProject);
  450. }
  451. this.setState({project, loadingGroup: false});
  452. GroupStore.loadInitialData([data]);
  453. if (trackView) {
  454. // make sure releases have loaded before we track the view
  455. groupReleasePromise.then(() => this.trackView(project));
  456. }
  457. } catch (error) {
  458. this.handleRequestError(error);
  459. }
  460. }
  461. listener = GroupStore.listen(itemIds => this.onGroupChange(itemIds), undefined);
  462. onGroupChange(itemIds: Set<string>) {
  463. const id = this.props.params.groupId;
  464. if (itemIds.has(id)) {
  465. const group = GroupStore.get(id) as Group;
  466. if (group) {
  467. // TODO(ts) This needs a better approach. issueActions is splicing attributes onto
  468. // group objects to cheat here.
  469. if ((group as Group & {stale?: boolean}).stale) {
  470. this.fetchData();
  471. return;
  472. }
  473. this.setState({
  474. group,
  475. });
  476. }
  477. }
  478. }
  479. getTitle() {
  480. const {organization} = this.props;
  481. const {group} = this.state;
  482. const defaultTitle = 'Sentry';
  483. if (!group) {
  484. return defaultTitle;
  485. }
  486. const {title} = getTitle(group, organization?.features);
  487. const message = getMessage(group);
  488. const {project} = group;
  489. const eventDetails = `${organization.slug} - ${project.slug}`;
  490. if (title && message) {
  491. return `${title}: ${message} - ${eventDetails}`;
  492. }
  493. return `${title || message || defaultTitle} - ${eventDetails}`;
  494. }
  495. tabClickAnalyticsEvent(tab: Tab) {
  496. const {organization} = this.props;
  497. const {project, group} = this.state;
  498. if (!project || !group) {
  499. return;
  500. }
  501. trackAdvancedAnalyticsEvent('issue_details.tab_changed', {
  502. organization,
  503. group_id: parseInt(group.id, 10),
  504. issue_category: group.issueCategory,
  505. project_id: parseInt(project.id, 10),
  506. tab,
  507. });
  508. }
  509. renderError() {
  510. const {projects, location} = this.props;
  511. const projectId = location.query.project;
  512. const project = projects.find(proj => proj.id === projectId);
  513. switch (this.state.errorType) {
  514. case ERROR_TYPES.GROUP_NOT_FOUND:
  515. return (
  516. <StyledLoadingError
  517. message={t('The issue you were looking for was not found.')}
  518. />
  519. );
  520. case ERROR_TYPES.MISSING_MEMBERSHIP:
  521. return (
  522. <MissingProjectMembership
  523. organization={this.props.organization}
  524. project={project}
  525. />
  526. );
  527. default:
  528. return <StyledLoadingError onRetry={this.remountComponent} />;
  529. }
  530. }
  531. renderContent(project: AvatarProject, group: Group) {
  532. const {children, environments, organization, location, router} = this.props;
  533. const {loadingEvent, eventError, event, replayIds} = this.state;
  534. const {currentTab, baseUrl} = this.getCurrentRouteInfo(group);
  535. const groupReprocessingStatus = getGroupReprocessingStatus(group);
  536. let childProps: Record<string, any> = {
  537. environments,
  538. group,
  539. project,
  540. };
  541. if (currentTab === Tab.DETAILS) {
  542. if (group.id !== event?.groupID && !eventError) {
  543. // if user pastes only the event id into the url, but it's from another group, redirect to correct group/event
  544. const redirectUrl = `/organizations/${organization.slug}/issues/${event?.groupID}/events/${event?.id}/`;
  545. router.push(redirectUrl);
  546. } else {
  547. childProps = {
  548. ...childProps,
  549. event,
  550. loadingEvent,
  551. eventError,
  552. groupReprocessingStatus,
  553. onRetry: () => this.remountComponent(),
  554. };
  555. }
  556. }
  557. if (currentTab === Tab.TAGS) {
  558. childProps = {...childProps, event, baseUrl};
  559. } else if (currentTab === Tab.REPLAYS) {
  560. childProps = {...childProps, replayIds};
  561. }
  562. return (
  563. <Tabs
  564. value={currentTab}
  565. onChange={tab => {
  566. this.tabClickAnalyticsEvent(tab);
  567. router.push({
  568. pathname: `${baseUrl}${TabPaths[tab]}`,
  569. query: tab === Tab.EVENTS ? omit(location.query, 'query') : location.query,
  570. });
  571. }}
  572. >
  573. <GroupHeader
  574. organization={organization}
  575. groupReprocessingStatus={groupReprocessingStatus}
  576. event={event}
  577. group={group}
  578. replaysCount={replayIds?.length}
  579. baseUrl={baseUrl}
  580. project={project as Project}
  581. />
  582. <GroupTabPanels>
  583. <Item key={currentTab}>
  584. {isValidElement(children) ? cloneElement(children, childProps) : children}
  585. </Item>
  586. </GroupTabPanels>
  587. </Tabs>
  588. );
  589. }
  590. renderPageContent() {
  591. const {error: isError, group, project, loading} = this.state;
  592. const isLoading = loading || (!group && !isError);
  593. if (isLoading) {
  594. return <LoadingIndicator />;
  595. }
  596. if (isError) {
  597. return this.renderError();
  598. }
  599. const {organization} = this.props;
  600. return (
  601. <Projects
  602. orgId={organization.slug}
  603. slugs={[project?.slug ?? '']}
  604. data-test-id="group-projects-container"
  605. >
  606. {({projects, initiallyLoaded, fetchError}) =>
  607. initiallyLoaded ? (
  608. fetchError ? (
  609. <StyledLoadingError message={t('Error loading the specified project')} />
  610. ) : (
  611. // TODO(ts): Update renderContent function to deal with empty group
  612. this.renderContent(projects[0], group!)
  613. )
  614. ) : (
  615. <LoadingIndicator />
  616. )
  617. }
  618. </Projects>
  619. );
  620. }
  621. render() {
  622. const {project, group} = this.state;
  623. const {organization} = this.props;
  624. const isSampleError = group?.tags?.some(tag => tag.key === 'sample_event');
  625. return (
  626. <Fragment>
  627. {isSampleError && project && (
  628. <SampleEventAlert project={project} organization={organization} />
  629. )}
  630. <SentryDocumentTitle noSuffix title={this.getTitle()}>
  631. <PageFiltersContainer
  632. skipLoadLastUsed
  633. forceProject={project}
  634. shouldForceProject
  635. >
  636. {this.renderPageContent()}
  637. </PageFiltersContainer>
  638. </SentryDocumentTitle>
  639. </Fragment>
  640. );
  641. }
  642. }
  643. export default withRouteAnalytics(withApi(Sentry.withProfiler(GroupDetails)));
  644. const StyledLoadingError = styled(LoadingError)`
  645. margin: ${space(2)};
  646. `;
  647. const GroupTabPanels = styled(TabPanels)`
  648. flex-grow: 1;
  649. display: flex;
  650. flex-direction: column;
  651. justify-content: stretch;
  652. `;