index.tsx 1.8 KB

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