index.tsx 3.2 KB

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