durationAggregateSelector.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import {browserHistory} from 'react-router';
  2. import styled from '@emotion/styled';
  3. import {CompactSelect} from 'sentry/components/compactSelect';
  4. import {space} from 'sentry/styles/space';
  5. import {useLocation} from 'sentry/utils/useLocation';
  6. import {AVAILABLE_DURATION_AGGREGATE_OPTIONS} from 'sentry/views/performance/database/settings';
  7. interface Props {
  8. aggregate: string;
  9. }
  10. export function DurationAggregateSelector({aggregate}: Props) {
  11. const location = useLocation();
  12. const handleDurationFunctionChange = option => {
  13. browserHistory.push({
  14. ...location,
  15. query: {
  16. ...location.query,
  17. aggregate: option.value,
  18. },
  19. });
  20. };
  21. return (
  22. <StyledCompactSelect
  23. size="md"
  24. options={AVAILABLE_DURATION_AGGREGATE_OPTIONS}
  25. value={aggregate}
  26. onChange={handleDurationFunctionChange}
  27. triggerProps={{borderless: true, size: 'zero'}}
  28. />
  29. );
  30. }
  31. // TODO: Talk to UI folks about making this a built-in dropdown size if we end
  32. // up using this element
  33. const StyledCompactSelect = styled(CompactSelect)`
  34. text-align: left;
  35. font-weight: normal;
  36. margin: -${space(0.5)} -${space(1)} -${space(0.25)};
  37. min-width: 0;
  38. button {
  39. padding: ${space(0.5)} ${space(1)};
  40. font-size: ${p => p.theme.fontSizeLarge};
  41. }
  42. `;