renderBlockingSelector.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. 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. },
  28. });
  29. }}
  30. />
  31. );
  32. }
  33. export default RenderBlockingSelector;