databaseLandingPage.tsx 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import {browserHistory} from 'react-router';
  2. import styled from '@emotion/styled';
  3. import Alert from 'sentry/components/alert';
  4. import Breadcrumbs from 'sentry/components/breadcrumbs';
  5. import FeedbackWidget from 'sentry/components/feedback/widget/feedbackWidget';
  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 SearchBar from 'sentry/components/searchBar';
  12. import {t} from 'sentry/locale';
  13. import {space} from 'sentry/styles/space';
  14. import {decodeScalar} from 'sentry/utils/queryString';
  15. import {useLocation} from 'sentry/utils/useLocation';
  16. import useOrganization from 'sentry/utils/useOrganization';
  17. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  18. import {ModulePageProviders} from 'sentry/views/performance/database/modulePageProviders';
  19. import {NoDataMessage} from 'sentry/views/performance/database/noDataMessage';
  20. import {ModuleName, SpanMetricsField} from 'sentry/views/starfish/types';
  21. import {QueryParameterNames} from 'sentry/views/starfish/views/queryParameters';
  22. import {ActionSelector} from 'sentry/views/starfish/views/spans/selectors/actionSelector';
  23. import {DomainSelector} from 'sentry/views/starfish/views/spans/selectors/domainSelector';
  24. import SpansTable from 'sentry/views/starfish/views/spans/spansTable';
  25. import {SpanTimeCharts} from 'sentry/views/starfish/views/spans/spanTimeCharts';
  26. import {useModuleFilters} from 'sentry/views/starfish/views/spans/useModuleFilters';
  27. import {useModuleSort} from 'sentry/views/starfish/views/spans/useModuleSort';
  28. function DatabaseLandingPage() {
  29. const organization = useOrganization();
  30. const moduleName = ModuleName.DB;
  31. const location = useLocation();
  32. const spanDescription = decodeScalar(location.query?.['span.description'], '');
  33. const moduleFilters = useModuleFilters();
  34. const sort = useModuleSort(QueryParameterNames.SPANS_SORT);
  35. const handleSearch = (newQuery: string) => {
  36. browserHistory.push({
  37. ...location,
  38. query: {
  39. ...location.query,
  40. 'span.description': newQuery === '' ? undefined : newQuery,
  41. cursor: undefined,
  42. },
  43. });
  44. };
  45. return (
  46. <ModulePageProviders title={[t('Performance'), t('Database')].join(' — ')}>
  47. <Layout.Header>
  48. <Layout.HeaderContent>
  49. <Breadcrumbs
  50. crumbs={[
  51. {
  52. label: 'Performance',
  53. to: normalizeUrl(`/organizations/${organization.slug}/performance/`),
  54. preservePageFilters: true,
  55. },
  56. {
  57. label: 'Queries',
  58. },
  59. ]}
  60. />
  61. <Layout.Title>{t('Queries')}</Layout.Title>
  62. </Layout.HeaderContent>
  63. </Layout.Header>
  64. <Layout.Body>
  65. <Layout.Main fullWidth>
  66. <NoDataMessage Wrapper={AlertBanner} />
  67. <FeedbackWidget />
  68. <PaddedContainer>
  69. <PageFilterBar condensed>
  70. <ProjectPageFilter />
  71. <EnvironmentPageFilter />
  72. <DatePageFilter />
  73. </PageFilterBar>
  74. </PaddedContainer>
  75. <SpanTimeCharts moduleName={moduleName} appliedFilters={{}} />
  76. <FilterOptionsContainer>
  77. <ActionSelector
  78. moduleName={moduleName}
  79. value={moduleFilters[SpanMetricsField.SPAN_ACTION] || ''}
  80. />
  81. <DomainSelector
  82. moduleName={moduleName}
  83. value={moduleFilters[SpanMetricsField.SPAN_DOMAIN] || ''}
  84. />
  85. </FilterOptionsContainer>
  86. <SearchBarContainer>
  87. <SearchBar
  88. query={spanDescription}
  89. placeholder={t('Search for more Queries')}
  90. onSearch={handleSearch}
  91. />
  92. </SearchBarContainer>
  93. <SpansTable moduleName={moduleName} sort={sort} limit={LIMIT} />
  94. </Layout.Main>
  95. </Layout.Body>
  96. </ModulePageProviders>
  97. );
  98. }
  99. const PaddedContainer = styled('div')`
  100. margin-bottom: ${space(2)};
  101. `;
  102. function AlertBanner(props) {
  103. return <Alert {...props} type="info" showIcon />;
  104. }
  105. const FilterOptionsContainer = styled('div')`
  106. display: grid;
  107. grid-template-columns: repeat(3, 1fr);
  108. gap: ${space(2)};
  109. margin-bottom: ${space(2)};
  110. max-width: 800px;
  111. `;
  112. const SearchBarContainer = styled('div')`
  113. margin-bottom: ${space(2)};
  114. `;
  115. const LIMIT: number = 25;
  116. export default DatabaseLandingPage;