headers.tsx 4.8 KB

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