pageload.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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('performance-screens-platform-selector') && project && isCrossPlatform(project) && <PlatformSelector />}
  47. </HeaderWrapper>
  48. </Layout.HeaderContent>
  49. </Layout.Header>
  50. <Layout.Body>
  51. <FloatingFeedbackWidget />
  52. <Layout.Main fullWidth>
  53. <PageErrorAlert />
  54. <PageFiltersContainer>
  55. <Container>
  56. <PageFilterBar condensed>
  57. <ProjectPageFilter />
  58. <EnvironmentPageFilter />
  59. <DatePageFilter />
  60. </PageFilterBar>
  61. <ReleaseComparisonSelector />
  62. </Container>
  63. <ErrorBoundary mini>
  64. {onboardingProject && (
  65. <OnboardingContainer>
  66. <Onboarding
  67. organization={organization}
  68. project={onboardingProject}
  69. />
  70. </OnboardingContainer>
  71. )}
  72. {!onboardingProject && (
  73. <ScreensView yAxes={[YAxis.TTID, YAxis.TTFD]} chartHeight={240} project={project} />
  74. )}
  75. </ErrorBoundary>
  76. </PageFiltersContainer>
  77. </Layout.Main>
  78. </Layout.Body>
  79. </PageErrorProvider>
  80. </Layout.Page>
  81. </SentryDocumentTitle>
  82. );
  83. }
  84. const Container = styled('div')`
  85. display: grid;
  86. grid-template-rows: auto auto auto;
  87. gap: ${space(2)};
  88. margin-bottom: ${space(2)};
  89. @media (min-width: ${p => p.theme.breakpoints.large}) {
  90. grid-template-rows: auto;
  91. grid-template-columns: auto 1fr auto;
  92. }
  93. `;
  94. const OnboardingContainer = styled('div')`
  95. margin-top: ${space(2)};
  96. `;
  97. const HeaderWrapper = styled('div')`
  98. display: flex;
  99. `;