index.tsx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. import styled from '@emotion/styled';
  2. import omit from 'lodash/omit';
  3. import Breadcrumbs from 'sentry/components/breadcrumbs';
  4. import * as Layout from 'sentry/components/layouts/thirds';
  5. import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
  6. import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
  7. import {t} from 'sentry/locale';
  8. import {space} from 'sentry/styles/space';
  9. import {PageAlert, PageAlertProvider} from 'sentry/utils/performance/contexts/pageAlert';
  10. import {useLocation} from 'sentry/utils/useLocation';
  11. import useRouter from 'sentry/utils/useRouter';
  12. import {SamplesTables} from 'sentry/views/performance/mobile/components/samplesTables';
  13. import {SpanSamplesPanel} from 'sentry/views/performance/mobile/components/spanSamplesPanel';
  14. import {SpanOperationTable} from 'sentry/views/performance/mobile/ui/screenSummary/spanOperationTable';
  15. import {ModulePageProviders} from 'sentry/views/performance/modulePageProviders';
  16. import {useModuleBreadcrumbs} from 'sentry/views/performance/utils/useModuleBreadcrumbs';
  17. import {ReleaseComparisonSelector} from 'sentry/views/starfish/components/releaseSelector';
  18. import {ModuleName, SpanMetricsField} from 'sentry/views/starfish/types';
  19. type Query = {
  20. 'device.class': string;
  21. primaryRelease: string;
  22. project: string;
  23. secondaryRelease: string;
  24. spanDescription: string;
  25. spanGroup: string;
  26. spanOp: string;
  27. transaction: string;
  28. };
  29. function ScreenSummary() {
  30. const location = useLocation<Query>();
  31. const router = useRouter();
  32. const {
  33. transaction: transactionName,
  34. spanGroup,
  35. spanDescription,
  36. spanOp,
  37. 'device.class': deviceClass,
  38. } = location.query;
  39. const crumbs = useModuleBreadcrumbs('mobile-ui');
  40. return (
  41. <Layout.Page>
  42. <PageAlertProvider>
  43. <Layout.Header>
  44. <Layout.HeaderContent>
  45. <Breadcrumbs
  46. crumbs={[
  47. ...crumbs,
  48. {
  49. label: t('Screen Summary'),
  50. },
  51. ]}
  52. />
  53. <Layout.Title>{transactionName}</Layout.Title>
  54. </Layout.HeaderContent>
  55. </Layout.Header>
  56. <Layout.Body>
  57. <Layout.Main fullWidth>
  58. <PageAlert />
  59. <HeaderContainer>
  60. <ControlsContainer>
  61. <PageFilterBar condensed>
  62. <DatePageFilter />
  63. </PageFilterBar>
  64. <ReleaseComparisonSelector />
  65. </ControlsContainer>
  66. </HeaderContainer>
  67. <SamplesContainer>
  68. <SamplesTables
  69. transactionName={transactionName}
  70. SpanOperationTable={SpanOperationTable}
  71. // TODO(nar): Add event samples component specific to ui module
  72. EventSamples={_props => <div />}
  73. />
  74. </SamplesContainer>
  75. {spanGroup && spanOp && (
  76. <SpanSamplesPanel
  77. additionalFilters={{
  78. ...(deviceClass ? {[SpanMetricsField.DEVICE_CLASS]: deviceClass} : {}),
  79. }}
  80. groupId={spanGroup}
  81. moduleName={ModuleName.OTHER}
  82. transactionName={transactionName}
  83. spanDescription={spanDescription}
  84. spanOp={spanOp}
  85. onClose={() => {
  86. router.replace({
  87. pathname: router.location.pathname,
  88. query: omit(
  89. router.location.query,
  90. 'spanGroup',
  91. 'transactionMethod',
  92. 'spanDescription',
  93. 'spanOp'
  94. ),
  95. });
  96. }}
  97. />
  98. )}
  99. </Layout.Main>
  100. </Layout.Body>
  101. </PageAlertProvider>
  102. </Layout.Page>
  103. );
  104. }
  105. function PageWithProviders() {
  106. const location = useLocation<Query>();
  107. const {transaction} = location.query;
  108. return (
  109. <ModulePageProviders
  110. title={[transaction, t('Screen Loads')].join(' — ')}
  111. features={['spans-first-ui', 'starfish-mobile-ui-module']}
  112. >
  113. <ScreenSummary />
  114. </ModulePageProviders>
  115. );
  116. }
  117. export default PageWithProviders;
  118. const ControlsContainer = styled('div')`
  119. display: flex;
  120. gap: ${space(1.5)};
  121. `;
  122. const HeaderContainer = styled('div')`
  123. display: flex;
  124. flex-wrap: wrap;
  125. gap: ${space(2)};
  126. justify-content: space-between;
  127. `;
  128. const SamplesContainer = styled('div')`
  129. margin-top: ${space(2)};
  130. `;