index.tsx 2.3 KB

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