headers.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 {PageFilters} from 'sentry/types';
  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. <AssigneesLabel isSavedSearchesOpen={isSavedSearchesOpen}>
  53. <ToolbarHeader>{t('Assignee')}</ToolbarHeader>
  54. </AssigneesLabel>
  55. </Fragment>
  56. )}
  57. </Fragment>
  58. );
  59. }
  60. export default Headers;
  61. const GraphHeaderWrapper = styled('div')<{isSavedSearchesOpen?: boolean}>`
  62. width: 160px;
  63. margin-left: ${space(2)};
  64. margin-right: ${space(2)};
  65. animation: 0.25s FadeIn linear forwards;
  66. @media (max-width: ${p =>
  67. p.isSavedSearchesOpen ? p.theme.breakpoints.xlarge : p.theme.breakpoints.large}) {
  68. display: none;
  69. }
  70. @keyframes FadeIn {
  71. 0% {
  72. opacity: 0;
  73. }
  74. 100% {
  75. opacity: 1;
  76. }
  77. }
  78. `;
  79. const GraphHeader = styled('div')`
  80. display: flex;
  81. `;
  82. const StyledToolbarHeader = styled(ToolbarHeader)`
  83. flex: 1;
  84. `;
  85. const GraphToggle = styled('a')<{active: boolean}>`
  86. font-size: 13px;
  87. padding-left: ${space(1)};
  88. &,
  89. &:hover,
  90. &:focus,
  91. &:active {
  92. color: ${p => (p.active ? p.theme.textColor : p.theme.disabled)};
  93. }
  94. `;
  95. const EventsOrUsersLabel = styled(ToolbarHeader)`
  96. display: inline-grid;
  97. align-items: center;
  98. justify-content: flex-end;
  99. text-align: right;
  100. width: 60px;
  101. margin: 0 ${space(2)};
  102. @media (min-width: ${p => p.theme.breakpoints.xlarge}) {
  103. width: 80px;
  104. }
  105. `;
  106. const AssigneesLabel = styled('div')<{isSavedSearchesOpen?: boolean}>`
  107. justify-content: flex-end;
  108. text-align: right;
  109. width: 80px;
  110. margin-left: ${space(2)};
  111. margin-right: ${space(2)};
  112. @media (max-width: ${p =>
  113. p.isSavedSearchesOpen ? p.theme.breakpoints.large : p.theme.breakpoints.medium}) {
  114. display: none;
  115. }
  116. `;
  117. // Reprocessing
  118. const StartedColumn = styled(ToolbarHeader)`
  119. margin: 0 ${space(2)};
  120. ${p => p.theme.overflowEllipsis};
  121. width: 85px;
  122. @media (min-width: ${p => p.theme.breakpoints.small}) {
  123. width: 140px;
  124. }
  125. `;
  126. const EventsReprocessedColumn = styled(ToolbarHeader)`
  127. margin: 0 ${space(2)};
  128. ${p => p.theme.overflowEllipsis};
  129. width: 75px;
  130. @media (min-width: ${p => p.theme.breakpoints.small}) {
  131. width: 140px;
  132. }
  133. `;
  134. const ProgressColumn = styled(ToolbarHeader)`
  135. margin: 0 ${space(2)};
  136. display: none;
  137. @media (min-width: ${p => p.theme.breakpoints.small}) {
  138. display: block;
  139. width: 160px;
  140. }
  141. `;