index.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import {Component} from 'react';
  2. import styled from '@emotion/styled';
  3. import {Location} from 'history';
  4. import {Client} from 'sentry/api';
  5. import NoProjectMessage from 'sentry/components/noProjectMessage';
  6. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  7. import {t} from 'sentry/locale';
  8. import {PageContent} from 'sentry/styles/organization';
  9. import {Organization, PageFilters, Project} from 'sentry/types';
  10. import EventView from 'sentry/utils/discover/eventView';
  11. import withApi from 'sentry/utils/withApi';
  12. import withOrganization from 'sentry/utils/withOrganization';
  13. import withPageFilters from 'sentry/utils/withPageFilters';
  14. import withProjects from 'sentry/utils/withProjects';
  15. import {generatePerformanceEventView} from '../data';
  16. import TrendsContent from './content';
  17. type Props = {
  18. api: Client;
  19. location: Location;
  20. organization: Organization;
  21. projects: Project[];
  22. selection: PageFilters;
  23. };
  24. type State = {
  25. eventView: EventView;
  26. error?: string;
  27. };
  28. class TrendsSummary extends Component<Props, State> {
  29. static getDerivedStateFromProps(nextProps: Readonly<Props>, prevState: State): State {
  30. return {
  31. ...prevState,
  32. eventView: generatePerformanceEventView(nextProps.location, nextProps.projects, {
  33. isTrends: true,
  34. }),
  35. };
  36. }
  37. state: State = {
  38. eventView: generatePerformanceEventView(this.props.location, this.props.projects, {
  39. isTrends: true,
  40. }),
  41. error: undefined,
  42. };
  43. getDocumentTitle(): string {
  44. return [t('Trends'), t('Performance')].join(' - ');
  45. }
  46. setError = (error: string | undefined) => {
  47. this.setState({error});
  48. };
  49. renderContent() {
  50. const {organization, location, projects} = this.props;
  51. const {eventView} = this.state;
  52. return (
  53. <TrendsContent
  54. organization={organization}
  55. location={location}
  56. eventView={eventView}
  57. projects={projects}
  58. />
  59. );
  60. }
  61. render() {
  62. const {organization} = this.props;
  63. return (
  64. <SentryDocumentTitle title={this.getDocumentTitle()} orgSlug={organization.slug}>
  65. <StyledPageContent>
  66. <NoProjectMessage organization={organization}>
  67. {this.renderContent()}
  68. </NoProjectMessage>
  69. </StyledPageContent>
  70. </SentryDocumentTitle>
  71. );
  72. }
  73. }
  74. export default withOrganization(withProjects(withPageFilters(withApi(TrendsSummary))));
  75. const StyledPageContent = styled(PageContent)`
  76. padding: 0;
  77. `;