index.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import {RouteComponentProps} from 'react-router';
  2. import styled from '@emotion/styled';
  3. import omit from 'lodash/omit';
  4. import NoProjectMessage from 'sentry/components/noProjectMessage';
  5. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  6. import {t} from 'sentry/locale';
  7. import {PageContent} from 'sentry/styles/organization';
  8. import {Organization} from 'sentry/types';
  9. import EventView from 'sentry/utils/discover/eventView';
  10. import withOrganization from 'sentry/utils/withOrganization';
  11. import EventDetailsContent from './content';
  12. type Props = RouteComponentProps<{eventSlug: string}, {}> & {
  13. organization: Organization;
  14. };
  15. function EventDetails({organization, location, params, router, route}: Props) {
  16. const eventSlug = typeof params.eventSlug === 'string' ? params.eventSlug.trim() : '';
  17. const isHomepage = location.query.homepage;
  18. const eventView = EventView.fromLocation(
  19. isHomepage ? {...location, query: omit(location.query, 'id')} : location
  20. );
  21. const eventName = eventView.name;
  22. const documentTitle =
  23. typeof eventName === 'string' && String(eventName).trim().length > 0
  24. ? [String(eventName).trim(), t('Discover')]
  25. : [t('Discover')];
  26. const projectSlug = eventSlug.split(':')[0];
  27. return (
  28. <SentryDocumentTitle
  29. title={documentTitle.join(' - ')}
  30. orgSlug={organization.slug}
  31. projectSlug={projectSlug}
  32. >
  33. <StyledPageContent>
  34. <NoProjectMessage organization={organization}>
  35. <EventDetailsContent
  36. organization={organization}
  37. location={location}
  38. params={params}
  39. eventView={eventView}
  40. eventSlug={eventSlug}
  41. router={router}
  42. route={route}
  43. isHomepage={isHomepage}
  44. />
  45. </NoProjectMessage>
  46. </StyledPageContent>
  47. </SentryDocumentTitle>
  48. );
  49. }
  50. export default withOrganization(EventDetails);
  51. const StyledPageContent = styled(PageContent)`
  52. padding: 0;
  53. `;