pageload.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 {
  15. PageErrorAlert,
  16. PageErrorProvider,
  17. } from 'sentry/utils/performance/contexts/pageError';
  18. import useOrganization from 'sentry/utils/useOrganization';
  19. import usePageFilters from 'sentry/utils/usePageFilters';
  20. import useProjects from 'sentry/utils/useProjects';
  21. import {useOnboardingProject} from 'sentry/views/performance/browser/webVitals/utils/useOnboardingProject';
  22. import Onboarding from 'sentry/views/performance/onboarding';
  23. import {ReleaseComparisonSelector} from 'sentry/views/starfish/components/releaseSelector';
  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('Mobile')} orgSlug={organization.slug}>
  40. <Layout.Page>
  41. <PageErrorProvider>
  42. <Layout.Header>
  43. <Layout.HeaderContent>
  44. <HeaderWrapper>
  45. <Layout.Title>{t('Mobile')}</Layout.Title>
  46. {organization.features.includes(
  47. 'performance-screens-platform-selector'
  48. ) &&
  49. project &&
  50. isCrossPlatform(project) && <PlatformSelector />}
  51. </HeaderWrapper>
  52. </Layout.HeaderContent>
  53. </Layout.Header>
  54. <Layout.Body>
  55. <FloatingFeedbackWidget />
  56. <Layout.Main fullWidth>
  57. <PageErrorAlert />
  58. <PageFiltersContainer>
  59. <Container>
  60. <PageFilterBar condensed>
  61. <ProjectPageFilter />
  62. <EnvironmentPageFilter />
  63. <DatePageFilter />
  64. </PageFilterBar>
  65. <ReleaseComparisonSelector />
  66. </Container>
  67. <ErrorBoundary mini>
  68. {onboardingProject && (
  69. <OnboardingContainer>
  70. <Onboarding
  71. organization={organization}
  72. project={onboardingProject}
  73. />
  74. </OnboardingContainer>
  75. )}
  76. {!onboardingProject && (
  77. <ScreensView
  78. yAxes={[YAxis.TTID, YAxis.TTFD]}
  79. chartHeight={240}
  80. project={project}
  81. />
  82. )}
  83. </ErrorBoundary>
  84. </PageFiltersContainer>
  85. </Layout.Main>
  86. </Layout.Body>
  87. </PageErrorProvider>
  88. </Layout.Page>
  89. </SentryDocumentTitle>
  90. );
  91. }
  92. const Container = styled('div')`
  93. display: grid;
  94. grid-template-rows: auto auto auto;
  95. gap: ${space(2)};
  96. margin-bottom: ${space(2)};
  97. @media (min-width: ${p => p.theme.breakpoints.large}) {
  98. grid-template-rows: auto;
  99. grid-template-columns: auto 1fr auto;
  100. }
  101. `;
  102. const OnboardingContainer = styled('div')`
  103. margin-top: ${space(2)};
  104. `;
  105. const HeaderWrapper = styled('div')`
  106. display: flex;
  107. `;