databaseLandingPage.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import styled from '@emotion/styled';
  2. import Alert from 'sentry/components/alert';
  3. import Breadcrumbs from 'sentry/components/breadcrumbs';
  4. import FeatureBadge from 'sentry/components/featureBadge';
  5. import * as Layout from 'sentry/components/layouts/thirds';
  6. import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
  7. import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter';
  8. import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
  9. import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter';
  10. import {t} from 'sentry/locale';
  11. import {space} from 'sentry/styles/space';
  12. import useOrganization from 'sentry/utils/useOrganization';
  13. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  14. import {ModulePageProviders} from 'sentry/views/performance/database/modulePageProviders';
  15. import {NoDataMessage} from 'sentry/views/performance/database/noDataMessage';
  16. import {RELEASE_LEVEL} from 'sentry/views/performance/database/settings';
  17. import {ModuleName, SpanMetricsField} from 'sentry/views/starfish/types';
  18. import {QueryParameterNames} from 'sentry/views/starfish/views/queryParameters';
  19. import {ActionSelector} from 'sentry/views/starfish/views/spans/selectors/actionSelector';
  20. import {DomainSelector} from 'sentry/views/starfish/views/spans/selectors/domainSelector';
  21. import SpansTable from 'sentry/views/starfish/views/spans/spansTable';
  22. import {SpanTimeCharts} from 'sentry/views/starfish/views/spans/spanTimeCharts';
  23. import {useModuleFilters} from 'sentry/views/starfish/views/spans/useModuleFilters';
  24. import {useModuleSort} from 'sentry/views/starfish/views/spans/useModuleSort';
  25. function DatabaseLandingPage() {
  26. const organization = useOrganization();
  27. const moduleName = ModuleName.DB;
  28. const moduleFilters = useModuleFilters();
  29. const sort = useModuleSort(QueryParameterNames.SPANS_SORT);
  30. return (
  31. <ModulePageProviders title={[t('Performance'), t('Database')].join(' — ')}>
  32. <Layout.Header>
  33. <Layout.HeaderContent>
  34. <Breadcrumbs
  35. crumbs={[
  36. {
  37. label: 'Performance',
  38. to: normalizeUrl(`/organizations/${organization.slug}/performance/`),
  39. preservePageFilters: true,
  40. },
  41. {
  42. label: 'Queries',
  43. },
  44. ]}
  45. />
  46. <Layout.Title>
  47. {t('Queries')}
  48. <FeatureBadge type={RELEASE_LEVEL} />
  49. </Layout.Title>
  50. </Layout.HeaderContent>
  51. </Layout.Header>
  52. <Layout.Body>
  53. <Layout.Main fullWidth>
  54. <NoDataMessage Wrapper={AlertBanner} />
  55. <PaddedContainer>
  56. <PageFilterBar condensed>
  57. <ProjectPageFilter />
  58. <EnvironmentPageFilter />
  59. <DatePageFilter />
  60. </PageFilterBar>
  61. </PaddedContainer>
  62. <SpanTimeCharts moduleName={moduleName} appliedFilters={moduleFilters} />
  63. <FilterOptionsContainer>
  64. <ActionSelector
  65. moduleName={moduleName}
  66. value={moduleFilters[SpanMetricsField.SPAN_ACTION] || ''}
  67. />
  68. <DomainSelector
  69. moduleName={moduleName}
  70. value={moduleFilters[SpanMetricsField.SPAN_DOMAIN] || ''}
  71. />
  72. </FilterOptionsContainer>
  73. <SpansTable moduleName={moduleName} sort={sort} limit={LIMIT} />
  74. </Layout.Main>
  75. </Layout.Body>
  76. </ModulePageProviders>
  77. );
  78. }
  79. const PaddedContainer = styled('div')`
  80. margin-bottom: ${space(2)};
  81. `;
  82. function AlertBanner(props) {
  83. return <Alert {...props} type="info" showIcon />;
  84. }
  85. const FilterOptionsContainer = styled('div')`
  86. display: grid;
  87. grid-template-columns: repeat(3, 1fr);
  88. gap: ${space(2)};
  89. margin-bottom: ${space(2)};
  90. max-width: 800px;
  91. `;
  92. const LIMIT: number = 25;
  93. export default DatabaseLandingPage;