123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- import {Fragment, useEffect} from 'react';
- import type {RouteComponentProps} from 'react-router';
- import styled from '@emotion/styled';
- import isEqual from 'lodash/isEqual';
- import ArchivedBox from 'sentry/components/archivedBox';
- import GroupEventDetailsLoadingError from 'sentry/components/errors/groupEventDetailsLoadingError';
- import {withMeta} from 'sentry/components/events/meta/metaProxy';
- import HookOrDefault from 'sentry/components/hookOrDefault';
- import * as Layout from 'sentry/components/layouts/thirds';
- import LoadingIndicator from 'sentry/components/loadingIndicator';
- import {TransactionProfileIdProvider} from 'sentry/components/profiling/transactionProfileIdProvider';
- import ResolutionBox from 'sentry/components/resolutionBox';
- import useSentryAppComponentsData from 'sentry/stores/useSentryAppComponentsData';
- import {space} from 'sentry/styles/space';
- import type {
- Group,
- GroupActivityReprocess,
- GroupReprocessing,
- Organization,
- Project,
- } from 'sentry/types';
- import type {Event} from 'sentry/types/event';
- import {defined} from 'sentry/utils';
- import {browserHistory} from 'sentry/utils/browserHistory';
- import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig';
- import {VisuallyCompleteWithData} from 'sentry/utils/performanceForSentry';
- import usePrevious from 'sentry/utils/usePrevious';
- import {normalizeUrl} from 'sentry/utils/withDomainRequired';
- import GroupEventDetailsContent from 'sentry/views/issueDetails/groupEventDetails/groupEventDetailsContent';
- import GroupEventHeader from 'sentry/views/issueDetails/groupEventHeader';
- import GroupSidebar from 'sentry/views/issueDetails/groupSidebar';
- import ReprocessingProgress from '../reprocessingProgress';
- import {
- getEventEnvironment,
- getGroupMostRecentActivity,
- ReprocessingStatus,
- useEnvironmentsFromUrl,
- } from '../utils';
- const EscalatingIssuesFeedback = HookOrDefault({
- hookName: 'component:escalating-issues-banner-feedback',
- });
- export interface GroupEventDetailsProps
- extends RouteComponentProps<{groupId: string; eventId?: string}, {}> {
- eventError: boolean;
- group: Group;
- groupReprocessingStatus: ReprocessingStatus;
- loadingEvent: boolean;
- onRetry: () => void;
- organization: Organization;
- project: Project;
- event?: Event;
- }
- function GroupEventDetails(props: GroupEventDetailsProps) {
- const {
- group,
- project,
- organization,
- location,
- event,
- groupReprocessingStatus,
- loadingEvent,
- onRetry,
- eventError,
- params,
- } = props;
- const projectId = project.id;
- const environments = useEnvironmentsFromUrl();
- const prevEnvironment = usePrevious(environments);
- const prevEvent = usePrevious(event);
- // load the data
- useSentryAppComponentsData({projectId});
- // If environments are being actively changed and will no longer contain the
- // current event's environment, redirect to latest
- useEffect(() => {
- const environmentsHaveChanged = !isEqual(prevEnvironment, environments);
- // If environments are being actively changed and will no longer contain the
- // current event's environment, redirect to latest
- if (
- environmentsHaveChanged &&
- prevEvent &&
- params.eventId &&
- !['latest', 'oldest'].includes(params.eventId)
- ) {
- const shouldRedirect =
- environments.length > 0 &&
- !environments.find(env => env === getEventEnvironment(prevEvent as Event));
- if (shouldRedirect) {
- browserHistory.replace(
- normalizeUrl({
- pathname: `/organizations/${organization.slug}/issues/${params.groupId}/`,
- query: location.query,
- })
- );
- return;
- }
- }
- }, [
- prevEnvironment,
- environments,
- location.query,
- organization.slug,
- params,
- prevEvent,
- ]);
- const renderGroupStatusBanner = () => {
- if (group.status === 'ignored') {
- return (
- <GroupStatusBannerWrapper>
- <ArchivedBox
- substatus={group.substatus}
- statusDetails={group.statusDetails}
- organization={organization}
- />
- </GroupStatusBannerWrapper>
- );
- }
- if (group.status === 'resolved') {
- return (
- <GroupStatusBannerWrapper>
- <ResolutionBox
- statusDetails={group.statusDetails}
- activities={group.activity}
- projectId={project.id}
- />
- </GroupStatusBannerWrapper>
- );
- }
- return null;
- };
- const renderContent = () => {
- if (loadingEvent) {
- return <LoadingIndicator />;
- }
- if (eventError) {
- return (
- <GroupEventDetailsLoadingError environments={environments} onRetry={onRetry} />
- );
- }
- return (
- <GroupEventDetailsContent group={group} event={eventWithMeta} project={project} />
- );
- };
- const eventWithMeta = withMeta(event);
- const issueTypeConfig = getConfigForIssueType(group, project);
- return (
- <TransactionProfileIdProvider
- projectId={event?.projectID}
- transactionId={event?.type === 'transaction' ? event.id : undefined}
- timestamp={event?.dateReceived}
- >
- <VisuallyCompleteWithData
- id="IssueDetails-EventBody"
- hasData={!loadingEvent && !eventError && defined(eventWithMeta)}
- isLoading={loadingEvent}
- >
- <StyledLayoutBody data-test-id="group-event-details">
- {groupReprocessingStatus === ReprocessingStatus.REPROCESSING ? (
- <ReprocessingProgress
- totalEvents={
- (getGroupMostRecentActivity(group.activity) as GroupActivityReprocess)
- .data.eventCount
- }
- pendingEvents={
- (group.statusDetails as GroupReprocessing['statusDetails']).pendingEvents
- }
- />
- ) : (
- <Fragment>
- <StyledLayoutMain>
- {renderGroupStatusBanner()}
- <EscalatingIssuesFeedback organization={organization} group={group} />
- {eventWithMeta && issueTypeConfig.stats.enabled && (
- <GroupEventHeader
- group={group}
- event={eventWithMeta}
- project={project}
- />
- )}
- {renderContent()}
- </StyledLayoutMain>
- <StyledLayoutSide>
- <GroupSidebar
- organization={organization}
- project={project}
- group={group}
- event={eventWithMeta}
- environments={environments}
- />
- </StyledLayoutSide>
- </Fragment>
- )}
- </StyledLayoutBody>
- </VisuallyCompleteWithData>
- </TransactionProfileIdProvider>
- );
- }
- const StyledLayoutBody = styled(Layout.Body)`
- /* Makes the borders align correctly */
- padding: 0 !important;
- @media (min-width: ${p => p.theme.breakpoints.large}) {
- align-content: stretch;
- }
- `;
- const GroupStatusBannerWrapper = styled('div')`
- margin-bottom: ${space(2)};
- `;
- const StyledLayoutMain = styled(Layout.Main)`
- padding-top: ${space(2)};
- @media (max-width: ${p => p.theme.breakpoints.medium}) {
- padding-top: ${space(1)};
- }
- @media (min-width: ${p => p.theme.breakpoints.large}) {
- border-right: 1px solid ${p => p.theme.border};
- padding-right: 0;
- }
- `;
- const StyledLayoutSide = styled(Layout.Side)`
- padding: ${space(3)} ${space(2)} ${space(3)};
- @media (min-width: ${p => p.theme.breakpoints.large}) {
- padding-right: ${space(4)};
- padding-left: 0;
- }
- `;
- export default GroupEventDetails;
|