renderBlockingSelector.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import {browserHistory} from 'react-router';
  2. import {t} from 'sentry/locale';
  3. import {useLocation} from 'sentry/utils/useLocation';
  4. import type {Option} from 'sentry/views/performance/browser/resources/shared/selectControlWithProps';
  5. import SelectControlWithProps from 'sentry/views/performance/browser/resources/shared/selectControlWithProps';
  6. import {SpanMetricsField} from 'sentry/views/starfish/types';
  7. import {QueryParameterNames} from 'sentry/views/starfish/views/queryParameters';
  8. const {RESOURCE_RENDER_BLOCKING_STATUS} = SpanMetricsField;
  9. function RenderBlockingSelector({value}: {value?: string}) {
  10. const location = useLocation();
  11. const options: Option[] = [
  12. {value: '', label: 'All'},
  13. {value: 'non-blocking', label: t('No')},
  14. {value: 'blocking', label: t('Yes')},
  15. ];
  16. return (
  17. <SelectControlWithProps
  18. inFieldLabel={`${t('Blocking')}:`}
  19. options={options}
  20. value={value}
  21. onChange={newValue => {
  22. browserHistory.push({
  23. ...location,
  24. query: {
  25. ...location.query,
  26. [RESOURCE_RENDER_BLOCKING_STATUS]: newValue?.value,
  27. [QueryParameterNames.SPANS_CURSOR]: undefined,
  28. },
  29. });
  30. }}
  31. />
  32. );
  33. }
  34. export default RenderBlockingSelector;