index.tsx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import {useMemo} from 'react';
  2. import styled from '@emotion/styled';
  3. import {Breadcrumbs} from 'sentry/components/breadcrumbs';
  4. import ButtonBar from 'sentry/components/buttonBar';
  5. import ErrorBoundary from 'sentry/components/errorBoundary';
  6. import FeedbackWidgetButton from 'sentry/components/feedback/widget/feedbackWidgetButton';
  7. import * as Layout from 'sentry/components/layouts/thirds';
  8. import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
  9. import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter';
  10. import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
  11. import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter';
  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 {normalizeUrl} from 'sentry/utils/withDomainRequired';
  19. import {useOnboardingProject} from 'sentry/views/performance/browser/webVitals/utils/useOnboardingProject';
  20. import {ScreensView, YAxis} from 'sentry/views/performance/mobile/screenload/screens';
  21. import {PlatformSelector} from 'sentry/views/performance/mobile/screenload/screens/platformSelector';
  22. import {isCrossPlatform} from 'sentry/views/performance/mobile/screenload/screens/utils';
  23. import {ModulePageProviders} from 'sentry/views/performance/modulePageProviders';
  24. import Onboarding from 'sentry/views/performance/onboarding';
  25. import {ReleaseComparisonSelector} from 'sentry/views/starfish/components/releaseSelector';
  26. import {ROUTE_NAMES} from 'sentry/views/starfish/utils/routeNames';
  27. export 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. <Layout.Page>
  40. <PageAlertProvider>
  41. <Layout.Header>
  42. <Layout.HeaderContent>
  43. <Breadcrumbs
  44. crumbs={[
  45. {
  46. label: t('Performance'),
  47. to: normalizeUrl(`/organizations/${organization.slug}/performance/`),
  48. preservePageFilters: true,
  49. },
  50. {
  51. label: ROUTE_NAMES.pageload,
  52. },
  53. ]}
  54. />
  55. <HeaderWrapper>
  56. <Layout.Title>{t('Screen Loads')}</Layout.Title>
  57. </HeaderWrapper>
  58. </Layout.HeaderContent>
  59. <Layout.HeaderActions>
  60. <ButtonBar gap={1}>
  61. {project && isCrossPlatform(project) && <PlatformSelector />}
  62. <FeedbackWidgetButton />
  63. </ButtonBar>
  64. </Layout.HeaderActions>
  65. </Layout.Header>
  66. <Layout.Body>
  67. <Layout.Main fullWidth>
  68. <Container>
  69. <PageFilterBar condensed>
  70. <ProjectPageFilter />
  71. <EnvironmentPageFilter />
  72. <DatePageFilter />
  73. </PageFilterBar>
  74. <ReleaseComparisonSelector />
  75. </Container>
  76. <PageAlert />
  77. <ErrorBoundary mini>
  78. {onboardingProject && (
  79. <OnboardingContainer>
  80. <Onboarding organization={organization} project={onboardingProject} />
  81. </OnboardingContainer>
  82. )}
  83. {!onboardingProject && (
  84. <ScreensView
  85. yAxes={[YAxis.TTID, YAxis.TTFD]}
  86. chartHeight={240}
  87. project={project}
  88. />
  89. )}
  90. </ErrorBoundary>
  91. </Layout.Main>
  92. </Layout.Body>
  93. </PageAlertProvider>
  94. </Layout.Page>
  95. );
  96. }
  97. function PageWithProviders() {
  98. return (
  99. <ModulePageProviders
  100. title={t('Screen Loads')}
  101. baseURL="/performance/mobile/screens"
  102. features="spans-first-ui"
  103. >
  104. <PageloadModule />
  105. </ModulePageProviders>
  106. );
  107. }
  108. export default PageWithProviders;
  109. const Container = styled('div')`
  110. display: grid;
  111. grid-template-rows: auto auto auto;
  112. gap: ${space(2)};
  113. margin-bottom: ${space(2)};
  114. @media (min-width: ${p => p.theme.breakpoints.large}) {
  115. grid-template-rows: auto;
  116. grid-template-columns: auto 1fr auto;
  117. }
  118. `;
  119. const OnboardingContainer = styled('div')`
  120. margin-top: ${space(2)};
  121. `;
  122. const HeaderWrapper = styled('div')`
  123. display: flex;
  124. `;