index.tsx 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import styled from '@emotion/styled';
  2. import Breadcrumbs from 'sentry/components/breadcrumbs';
  3. import FeatureBadge from 'sentry/components/featureBadge';
  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>
  50. {t('Resources')}
  51. <FeatureBadge type="alpha" />
  52. </Layout.Title>
  53. </Layout.HeaderContent>
  54. </Layout.Header>
  55. <Layout.Body>
  56. <Layout.Main fullWidth>
  57. <FilterOptionsContainer>
  58. <PageFilterBar condensed>
  59. <ProjectPageFilter />
  60. <DatePageFilter />
  61. </PageFilterBar>
  62. <DomainSelector
  63. emptyOptionLocation="top"
  64. value={filters[SPAN_DOMAIN] || ''}
  65. additionalQuery={[
  66. ...DEFAULT_RESOURCE_FILTERS,
  67. `${SPAN_OP}:[${DEFAULT_RESOURCE_TYPES.join(',')}]`,
  68. ]}
  69. />
  70. </FilterOptionsContainer>
  71. {(!filters[SPAN_OP] ||
  72. filters[SPAN_OP] === 'resource.script' ||
  73. filters[SPAN_OP] === 'resource.css') && <JSCSSView />}
  74. {filters[SPAN_OP] === 'resource.img' && <ImageView />}
  75. </Layout.Main>
  76. </Layout.Body>
  77. </ModulePageProviders>
  78. );
  79. }
  80. export const PaddedContainer = styled('div')`
  81. margin-bottom: ${space(2)};
  82. `;
  83. export default ResourcesLandingPage;