index.tsx 2.3 KB

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