pageload.tsx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import {useMemo} from 'react';
  2. import styled from '@emotion/styled';
  3. import {Breadcrumbs} from 'sentry/components/breadcrumbs';
  4. import ErrorBoundary from 'sentry/components/errorBoundary';
  5. import FloatingFeedbackWidget from 'sentry/components/feedback/widget/floatingFeedbackWidget';
  6. import * as Layout from 'sentry/components/layouts/thirds';
  7. import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
  8. import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter';
  9. import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
  10. import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
  11. import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter';
  12. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  13. import {t} from 'sentry/locale';
  14. import {space} from 'sentry/styles/space';
  15. import {PageAlert, PageAlertProvider} from 'sentry/utils/performance/contexts/pageAlert';
  16. import useOrganization from 'sentry/utils/useOrganization';
  17. import usePageFilters from 'sentry/utils/usePageFilters';
  18. import useProjects from 'sentry/utils/useProjects';
  19. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  20. import {useOnboardingProject} from 'sentry/views/performance/browser/webVitals/utils/useOnboardingProject';
  21. import Onboarding from 'sentry/views/performance/onboarding';
  22. import {ReleaseComparisonSelector} from 'sentry/views/starfish/components/releaseSelector';
  23. import {ROUTE_NAMES} from 'sentry/views/starfish/utils/routeNames';
  24. import {ScreensView, YAxis} from 'sentry/views/starfish/views/screens';
  25. import {PlatformSelector} from 'sentry/views/starfish/views/screens/platformSelector';
  26. import {isCrossPlatform} from 'sentry/views/starfish/views/screens/utils';
  27. export default function PageloadModule() {
  28. const organization = useOrganization();
  29. const onboardingProject = useOnboardingProject();
  30. const {selection} = usePageFilters();
  31. const {projects} = useProjects();
  32. const project = useMemo(() => {
  33. if (selection.projects.length !== 1) {
  34. return null;
  35. }
  36. return projects.find(p => p.id === String(selection.projects));
  37. }, [projects, selection.projects]);
  38. return (
  39. <SentryDocumentTitle title={t('Screen Loads')} orgSlug={organization.slug}>
  40. <Layout.Page>
  41. <PageAlertProvider>
  42. <Layout.Header>
  43. <Layout.HeaderContent>
  44. <Breadcrumbs
  45. crumbs={[
  46. {
  47. label: t('Performance'),
  48. to: normalizeUrl(`/organizations/${organization.slug}/performance/`),
  49. preservePageFilters: true,
  50. },
  51. {
  52. label: ROUTE_NAMES.pageload,
  53. },
  54. ]}
  55. />
  56. <HeaderWrapper>
  57. <Layout.Title>{t('Screen Loads')}</Layout.Title>
  58. {organization.features.includes(
  59. 'performance-screens-platform-selector'
  60. ) &&
  61. project &&
  62. isCrossPlatform(project) && <PlatformSelector />}
  63. </HeaderWrapper>
  64. </Layout.HeaderContent>
  65. </Layout.Header>
  66. <Layout.Body>
  67. <FloatingFeedbackWidget />
  68. <Layout.Main fullWidth>
  69. <PageAlert />
  70. <PageFiltersContainer>
  71. <Container>
  72. <PageFilterBar condensed>
  73. <ProjectPageFilter />
  74. <EnvironmentPageFilter />
  75. <DatePageFilter />
  76. </PageFilterBar>
  77. <ReleaseComparisonSelector />
  78. </Container>
  79. <ErrorBoundary mini>
  80. {onboardingProject && (
  81. <OnboardingContainer>
  82. <Onboarding
  83. organization={organization}
  84. project={onboardingProject}
  85. />
  86. </OnboardingContainer>
  87. )}
  88. {!onboardingProject && (
  89. <ScreensView
  90. yAxes={[YAxis.TTID, YAxis.TTFD]}
  91. chartHeight={240}
  92. project={project}
  93. />
  94. )}
  95. </ErrorBoundary>
  96. </PageFiltersContainer>
  97. </Layout.Main>
  98. </Layout.Body>
  99. </PageAlertProvider>
  100. </Layout.Page>
  101. </SentryDocumentTitle>
  102. );
  103. }
  104. const Container = styled('div')`
  105. display: grid;
  106. grid-template-rows: auto auto auto;
  107. gap: ${space(2)};
  108. margin-bottom: ${space(2)};
  109. @media (min-width: ${p => p.theme.breakpoints.large}) {
  110. grid-template-rows: auto;
  111. grid-template-columns: auto 1fr auto;
  112. }
  113. `;
  114. const OnboardingContainer = styled('div')`
  115. margin-top: ${space(2)};
  116. `;
  117. const HeaderWrapper = styled('div')`
  118. display: flex;
  119. `;