headers.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import ToolbarHeader from 'sentry/components/toolbarHeader';
  4. import {t} from 'sentry/locale';
  5. import {space} from 'sentry/styles/space';
  6. import type {PageFilters} from 'sentry/types/core';
  7. type Props = {
  8. isReprocessingQuery: boolean;
  9. onSelectStatsPeriod: (statsPeriod: string) => void;
  10. selection: PageFilters;
  11. statsPeriod: string;
  12. isSavedSearchesOpen?: boolean;
  13. };
  14. function Headers({
  15. selection,
  16. statsPeriod,
  17. onSelectStatsPeriod,
  18. isReprocessingQuery,
  19. isSavedSearchesOpen,
  20. }: Props) {
  21. return (
  22. <Fragment>
  23. {isReprocessingQuery ? (
  24. <Fragment>
  25. <StartedColumn>{t('Started')}</StartedColumn>
  26. <EventsReprocessedColumn>{t('Events Reprocessed')}</EventsReprocessedColumn>
  27. <ProgressColumn>{t('Progress')}</ProgressColumn>
  28. </Fragment>
  29. ) : (
  30. <Fragment>
  31. <GraphHeaderWrapper isSavedSearchesOpen={isSavedSearchesOpen}>
  32. <GraphHeader>
  33. <StyledToolbarHeader>{t('Graph:')}</StyledToolbarHeader>
  34. {selection.datetime.period !== '24h' && (
  35. <GraphToggle
  36. active={statsPeriod === '24h'}
  37. onClick={() => onSelectStatsPeriod('24h')}
  38. >
  39. {t('24h')}
  40. </GraphToggle>
  41. )}
  42. <GraphToggle
  43. active={statsPeriod === 'auto'}
  44. onClick={() => onSelectStatsPeriod('auto')}
  45. >
  46. {selection.datetime.period || t('Custom')}
  47. </GraphToggle>
  48. </GraphHeader>
  49. </GraphHeaderWrapper>
  50. <EventsOrUsersLabel>{t('Events')}</EventsOrUsersLabel>
  51. <EventsOrUsersLabel>{t('Users')}</EventsOrUsersLabel>
  52. <PriorityLabel isSavedSearchesOpen={isSavedSearchesOpen}>
  53. <ToolbarHeader>{t('Priority')}</ToolbarHeader>
  54. </PriorityLabel>
  55. <AssigneeLabel isSavedSearchesOpen={isSavedSearchesOpen}>
  56. <ToolbarHeader>{t('Assignee')}</ToolbarHeader>
  57. </AssigneeLabel>
  58. </Fragment>
  59. )}
  60. </Fragment>
  61. );
  62. }
  63. export default Headers;
  64. const GraphHeaderWrapper = styled('div')<{isSavedSearchesOpen?: boolean}>`
  65. width: 160px;
  66. margin-left: ${space(2)};
  67. margin-right: ${space(2)};
  68. /* prettier-ignore */
  69. @media (max-width: ${p =>
  70. p.isSavedSearchesOpen ? p.theme.breakpoints.xlarge : p.theme.breakpoints.large}) {
  71. display: none;
  72. }
  73. `;
  74. const GraphHeader = styled('div')`
  75. display: flex;
  76. `;
  77. const StyledToolbarHeader = styled(ToolbarHeader)`
  78. flex: 1;
  79. `;
  80. const GraphToggle = styled('a')<{active: boolean}>`
  81. font-size: 13px;
  82. padding-left: ${space(1)};
  83. &,
  84. &:hover,
  85. &:focus,
  86. &:active {
  87. color: ${p => (p.active ? p.theme.textColor : p.theme.disabled)};
  88. }
  89. `;
  90. const EventsOrUsersLabel = styled(ToolbarHeader)`
  91. display: inline-grid;
  92. align-items: center;
  93. justify-content: flex-end;
  94. text-align: right;
  95. width: 60px;
  96. margin: 0 ${space(2)};
  97. @media (min-width: ${p => p.theme.breakpoints.xlarge}) {
  98. width: 80px;
  99. }
  100. `;
  101. const PriorityLabel = styled(ToolbarHeader)<{isSavedSearchesOpen?: boolean}>`
  102. justify-content: flex-end;
  103. text-align: right;
  104. width: 70px;
  105. margin: 0 ${space(2)};
  106. /* prettier-ignore */
  107. @media (max-width: ${p =>
  108. p.isSavedSearchesOpen ? p.theme.breakpoints.large : p.theme.breakpoints.medium}) {
  109. display: none;
  110. }
  111. `;
  112. const AssigneeLabel = styled(ToolbarHeader)<{isSavedSearchesOpen?: boolean}>`
  113. justify-content: flex-end;
  114. text-align: right;
  115. width: 60px;
  116. margin-left: ${space(2)};
  117. margin-right: ${space(2)};
  118. /* prettier-ignore */
  119. @media (max-width: ${p =>
  120. p.isSavedSearchesOpen ? p.theme.breakpoints.large : p.theme.breakpoints.medium}) {
  121. display: none;
  122. }
  123. `;
  124. // Reprocessing
  125. const StartedColumn = styled(ToolbarHeader)`
  126. margin: 0 ${space(2)};
  127. ${p => p.theme.overflowEllipsis};
  128. width: 85px;
  129. @media (min-width: ${p => p.theme.breakpoints.small}) {
  130. width: 140px;
  131. }
  132. `;
  133. const EventsReprocessedColumn = styled(ToolbarHeader)`
  134. margin: 0 ${space(2)};
  135. ${p => p.theme.overflowEllipsis};
  136. width: 75px;
  137. @media (min-width: ${p => p.theme.breakpoints.small}) {
  138. width: 140px;
  139. }
  140. `;
  141. const ProgressColumn = styled(ToolbarHeader)`
  142. margin: 0 ${space(2)};
  143. display: none;
  144. @media (min-width: ${p => p.theme.breakpoints.small}) {
  145. display: block;
  146. width: 160px;
  147. }
  148. `;