renderBlockingSelector.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import {CompactSelect} from 'sentry/components/compactSelect';
  2. import {t} from 'sentry/locale';
  3. import {trackAnalytics} from 'sentry/utils/analytics';
  4. import {useLocation} from 'sentry/utils/useLocation';
  5. import {useNavigate} from 'sentry/utils/useNavigate';
  6. import useOrganization from 'sentry/utils/useOrganization';
  7. import {QueryParameterNames} from 'sentry/views/insights/common/views/queryParameters';
  8. import {SpanMetricsField} from 'sentry/views/insights/types';
  9. const {RESOURCE_RENDER_BLOCKING_STATUS} = SpanMetricsField;
  10. function RenderBlockingSelector({value}: {value?: string}) {
  11. const navigate = useNavigate();
  12. const location = useLocation();
  13. const organization = useOrganization();
  14. const options = [
  15. {value: '', label: 'All'},
  16. {value: 'non-blocking', label: t('No')},
  17. {value: 'blocking', label: t('Yes')},
  18. ];
  19. return (
  20. <CompactSelect
  21. triggerProps={{prefix: `${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. navigate({
  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;