renderBlockingSelector.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import {t} from 'sentry/locale';
  2. import {trackAnalytics} from 'sentry/utils/analytics';
  3. import {browserHistory} from 'sentry/utils/browserHistory';
  4. import {useLocation} from 'sentry/utils/useLocation';
  5. import useOrganization from 'sentry/utils/useOrganization';
  6. import type {Option} from 'sentry/views/insights/browser/resources/components/selectControlWithProps';
  7. import SelectControlWithProps from 'sentry/views/insights/browser/resources/components/selectControlWithProps';
  8. import {QueryParameterNames} from 'sentry/views/insights/common/views/queryParameters';
  9. import {SpanMetricsField} from 'sentry/views/insights/types';
  10. const {RESOURCE_RENDER_BLOCKING_STATUS} = SpanMetricsField;
  11. function RenderBlockingSelector({value}: {value?: string}) {
  12. const location = useLocation();
  13. const organization = useOrganization();
  14. const options: Option[] = [
  15. {value: '', label: 'All'},
  16. {value: 'non-blocking', label: t('No')},
  17. {value: 'blocking', label: t('Yes')},
  18. ];
  19. return (
  20. <SelectControlWithProps
  21. inFieldLabel={`${t('Blocking')}:`}
  22. options={options}
  23. value={value}
  24. onChange={newValue => {
  25. trackAnalytics('insight.asset.filter_by_blocking', {
  26. organization,
  27. filter: newValue?.value,
  28. });
  29. browserHistory.push({
  30. ...location,
  31. query: {
  32. ...location.query,
  33. [RESOURCE_RENDER_BLOCKING_STATUS]: newValue?.value,
  34. [QueryParameterNames.SPANS_CURSOR]: undefined,
  35. },
  36. });
  37. }}
  38. />
  39. );
  40. }
  41. export default RenderBlockingSelector;