index.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import React from 'react';
  2. import styled from '@emotion/styled';
  3. import {Breadcrumbs} from 'sentry/components/breadcrumbs';
  4. import ButtonBar from 'sentry/components/buttonBar';
  5. import FeedbackWidgetButton from 'sentry/components/feedback/widget/feedbackWidgetButton';
  6. import * as Layout from 'sentry/components/layouts/thirds';
  7. import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
  8. import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter';
  9. import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
  10. import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter';
  11. import {PageHeadingQuestionTooltip} from 'sentry/components/pageHeadingQuestionTooltip';
  12. import {space} from 'sentry/styles/space';
  13. import {RateUnit} from 'sentry/utils/discover/fields';
  14. import {PageAlert, PageAlertProvider} from 'sentry/utils/performance/contexts/pageAlert';
  15. import useOrganization from 'sentry/utils/useOrganization';
  16. import ResourceView, {
  17. DEFAULT_RESOURCE_TYPES,
  18. FilterOptionsContainer,
  19. } from 'sentry/views/performance/browser/resources/resourceView';
  20. import {
  21. MODULE_DESCRIPTION,
  22. MODULE_DOC_LINK,
  23. PERFORMANCE_MODULE_DESCRIPTION,
  24. } from 'sentry/views/performance/browser/resources/settings';
  25. import {
  26. BrowserStarfishFields,
  27. useResourceModuleFilters,
  28. } from 'sentry/views/performance/browser/resources/utils/useResourceFilters';
  29. import {DEFAULT_RESOURCE_FILTERS} from 'sentry/views/performance/browser/resources/utils/useResourcesQuery';
  30. import {ModulePageProviders} from 'sentry/views/performance/modulePageProviders';
  31. import {useModuleBreadcrumbs} from 'sentry/views/performance/utils/useModuleBreadcrumbs';
  32. import {useModuleTitle} from 'sentry/views/performance/utils/useModuleTitle';
  33. import {ModuleName} from 'sentry/views/starfish/types';
  34. import {DomainSelector} from 'sentry/views/starfish/views/spans/selectors/domainSelector';
  35. const {SPAN_OP, SPAN_DOMAIN} = BrowserStarfishFields;
  36. export const RESOURCE_THROUGHPUT_UNIT = RateUnit.PER_MINUTE;
  37. function ResourcesLandingPage() {
  38. const filters = useResourceModuleFilters();
  39. const organization = useOrganization();
  40. const moduleTitle = useModuleTitle(ModuleName.RESOURCE);
  41. const crumbs = useModuleBreadcrumbs('resource');
  42. const isInsightsEnabled = organization.features.includes('performance-insights');
  43. return (
  44. <React.Fragment>
  45. <PageAlertProvider>
  46. <Layout.Header>
  47. <Layout.HeaderContent>
  48. <Breadcrumbs crumbs={crumbs} />
  49. <Layout.Title>
  50. {moduleTitle}
  51. <PageHeadingQuestionTooltip
  52. docsUrl={MODULE_DOC_LINK}
  53. title={
  54. isInsightsEnabled ? MODULE_DESCRIPTION : PERFORMANCE_MODULE_DESCRIPTION
  55. }
  56. />
  57. </Layout.Title>
  58. </Layout.HeaderContent>
  59. <Layout.HeaderActions>
  60. <ButtonBar gap={1}>
  61. <FeedbackWidgetButton />
  62. </ButtonBar>
  63. </Layout.HeaderActions>
  64. </Layout.Header>
  65. <Layout.Body>
  66. <Layout.Main fullWidth>
  67. <PageAlert />
  68. <FilterOptionsContainer columnCount={2}>
  69. <PageFilterBar condensed>
  70. <ProjectPageFilter />
  71. <EnvironmentPageFilter />
  72. <DatePageFilter />
  73. </PageFilterBar>
  74. <DomainSelector
  75. emptyOptionLocation="top"
  76. value={filters[SPAN_DOMAIN] || ''}
  77. additionalQuery={[
  78. ...DEFAULT_RESOURCE_FILTERS,
  79. `${SPAN_OP}:[${DEFAULT_RESOURCE_TYPES.join(',')}]`,
  80. ]}
  81. />
  82. </FilterOptionsContainer>
  83. <ResourceView />
  84. </Layout.Main>
  85. </Layout.Body>
  86. </PageAlertProvider>
  87. </React.Fragment>
  88. );
  89. }
  90. function PageWithProviders() {
  91. return (
  92. <ModulePageProviders moduleName="resource" features="insights-initial-modules">
  93. <ResourcesLandingPage />
  94. </ModulePageProviders>
  95. );
  96. }
  97. export default PageWithProviders;
  98. export const PaddedContainer = styled('div')`
  99. margin-bottom: ${space(2)};
  100. `;