toolbarResults.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import styled from '@emotion/styled';
  2. import {SegmentedControl} from 'sentry/components/segmentedControl';
  3. import {t} from 'sentry/locale';
  4. import type {ResultMode} from 'sentry/views/explore/hooks/useResultsMode';
  5. import {ToolbarRow, ToolbarSection} from './styles';
  6. interface ToolbarResultsProps {
  7. resultMode: ResultMode;
  8. setResultMode: (newMode: ResultMode) => void;
  9. }
  10. export function ToolbarResults({resultMode, setResultMode}: ToolbarResultsProps) {
  11. return (
  12. <ToolbarSection data-test-id="section-result-mode">
  13. <StyledToolbarRow>
  14. <SegmentedControl
  15. aria-label={t('Result Mode')}
  16. value={resultMode}
  17. onChange={setResultMode}
  18. >
  19. <SegmentedControl.Item key={'samples' as const}>
  20. {t('Samples')}
  21. </SegmentedControl.Item>
  22. <SegmentedControl.Item key={'aggregate' as const}>
  23. {t('Aggregates')}
  24. </SegmentedControl.Item>
  25. </SegmentedControl>
  26. </StyledToolbarRow>
  27. </ToolbarSection>
  28. );
  29. }
  30. const StyledToolbarRow = styled(ToolbarRow)`
  31. > div {
  32. flex-grow: 1;
  33. > label > :last-child {
  34. flex-grow: 1;
  35. }
  36. }
  37. `;