pageload.tsx 4.2 KB

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