index.tsx 2.7 KB

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