renderBlockingSelector.tsx 1.2 KB

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