index.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import {Component} from 'react';
  2. import {RouteComponentProps} from 'react-router';
  3. import styled from '@emotion/styled';
  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. class EventDetails extends Component<Props> {
  16. getEventSlug = (): string => {
  17. const {eventSlug} = this.props.params;
  18. if (typeof eventSlug === 'string') {
  19. return eventSlug.trim();
  20. }
  21. return '';
  22. };
  23. getEventView = (): EventView => {
  24. const {location} = this.props;
  25. return EventView.fromLocation(location);
  26. };
  27. getDocumentTitle = (name: string | undefined): Array<string> =>
  28. typeof name === 'string' && String(name).trim().length > 0
  29. ? [String(name).trim(), t('Discover')]
  30. : [t('Discover')];
  31. render() {
  32. const {organization, location, params, router, route} = this.props;
  33. const eventView = this.getEventView();
  34. const eventSlug = this.getEventSlug();
  35. const documentTitle = this.getDocumentTitle(eventView.name).join(' - ');
  36. const projectSlug = eventSlug.split(':')[0];
  37. return (
  38. <SentryDocumentTitle
  39. title={documentTitle}
  40. orgSlug={organization.slug}
  41. projectSlug={projectSlug}
  42. >
  43. <StyledPageContent>
  44. <NoProjectMessage organization={organization}>
  45. <EventDetailsContent
  46. organization={organization}
  47. location={location}
  48. params={params}
  49. eventView={eventView}
  50. eventSlug={eventSlug}
  51. router={router}
  52. route={route}
  53. />
  54. </NoProjectMessage>
  55. </StyledPageContent>
  56. </SentryDocumentTitle>
  57. );
  58. }
  59. }
  60. export default withOrganization(EventDetails);
  61. const StyledPageContent = styled(PageContent)`
  62. padding: 0;
  63. `;