index.tsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import styled from '@emotion/styled';
  2. import Breadcrumbs from 'sentry/components/breadcrumbs';
  3. import FloatingFeedbackWidget from 'sentry/components/feedback/widget/floatingFeedbackWidget';
  4. import * as Layout from 'sentry/components/layouts/thirds';
  5. import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
  6. import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter';
  7. import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
  8. import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter';
  9. import {t} from 'sentry/locale';
  10. import {space} from 'sentry/styles/space';
  11. import {RateUnits} from 'sentry/utils/discover/fields';
  12. import {
  13. PageErrorAlert,
  14. PageErrorProvider,
  15. } from 'sentry/utils/performance/contexts/pageError';
  16. import useOrganization from 'sentry/utils/useOrganization';
  17. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  18. import ImageView from 'sentry/views/performance/browser/resources/imageView';
  19. import JSCSSView, {
  20. DEFAULT_RESOURCE_TYPES,
  21. FilterOptionsContainer,
  22. } from 'sentry/views/performance/browser/resources/jsCssView';
  23. import {
  24. BrowserStarfishFields,
  25. useResourceModuleFilters,
  26. } from 'sentry/views/performance/browser/resources/utils/useResourceFilters';
  27. import {DEFAULT_RESOURCE_FILTERS} from 'sentry/views/performance/browser/resources/utils/useResourcesQuery';
  28. import {ModulePageProviders} from 'sentry/views/performance/database/modulePageProviders';
  29. import {DomainSelector} from 'sentry/views/starfish/views/spans/selectors/domainSelector';
  30. const {SPAN_OP, SPAN_DOMAIN} = BrowserStarfishFields;
  31. export const RESOURCE_THROUGHPUT_UNIT = RateUnits.PER_MINUTE;
  32. function ResourcesLandingPage() {
  33. const organization = useOrganization();
  34. const filters = useResourceModuleFilters();
  35. return (
  36. <ModulePageProviders
  37. title={[t('Performance'), t('Resources')].join(' — ')}
  38. baseURL="/performance/browser/resources"
  39. >
  40. <PageErrorProvider>
  41. <Layout.Header>
  42. <Layout.HeaderContent>
  43. <Breadcrumbs
  44. crumbs={[
  45. {
  46. label: 'Performance',
  47. to: normalizeUrl(`/organizations/${organization.slug}/performance/`),
  48. preservePageFilters: true,
  49. },
  50. {
  51. label: 'Resources',
  52. },
  53. ]}
  54. />
  55. <Layout.Title>{t('Resources')}</Layout.Title>
  56. </Layout.HeaderContent>
  57. </Layout.Header>
  58. <Layout.Body>
  59. <Layout.Main fullWidth>
  60. <FloatingFeedbackWidget />
  61. <PageErrorAlert />
  62. <FilterOptionsContainer columnCount={2}>
  63. <PageFilterBar condensed>
  64. <ProjectPageFilter />
  65. <EnvironmentPageFilter />
  66. <DatePageFilter />
  67. </PageFilterBar>
  68. <DomainSelector
  69. emptyOptionLocation="top"
  70. value={filters[SPAN_DOMAIN] || ''}
  71. additionalQuery={[
  72. ...DEFAULT_RESOURCE_FILTERS,
  73. `${SPAN_OP}:[${DEFAULT_RESOURCE_TYPES.join(',')}]`,
  74. ]}
  75. />
  76. </FilterOptionsContainer>
  77. {(!filters[SPAN_OP] ||
  78. filters[SPAN_OP] === 'resource.script' ||
  79. filters[SPAN_OP] === 'resource.css' ||
  80. filters[SPAN_OP] === 'resource.font') && <JSCSSView />}
  81. {filters[SPAN_OP] === 'resource.img' && <ImageView />}
  82. </Layout.Main>
  83. </Layout.Body>
  84. </PageErrorProvider>
  85. </ModulePageProviders>
  86. );
  87. }
  88. export const PaddedContainer = styled('div')`
  89. margin-bottom: ${space(2)};
  90. `;
  91. export default ResourcesLandingPage;