renderBlockingSelector.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import {CompactSelect} from 'sentry/components/compactSelect';
  2. import {t} from 'sentry/locale';
  3. import {trackAnalytics} from 'sentry/utils/analytics';
  4. import {browserHistory} from 'sentry/utils/browserHistory';
  5. import {useLocation} from 'sentry/utils/useLocation';
  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 location = useLocation();
  12. const organization = useOrganization();
  13. const options = [
  14. {value: '', label: 'All'},
  15. {value: 'non-blocking', label: t('No')},
  16. {value: 'blocking', label: t('Yes')},
  17. ];
  18. return (
  19. <CompactSelect
  20. triggerProps={{prefix: `${t('Blocking')}`}}
  21. options={options}
  22. value={value ?? ''}
  23. onChange={newValue => {
  24. trackAnalytics('insight.asset.filter_by_blocking', {
  25. organization,
  26. filter: newValue?.value,
  27. });
  28. browserHistory.push({
  29. ...location,
  30. query: {
  31. ...location.query,
  32. [RESOURCE_RENDER_BLOCKING_STATUS]: newValue?.value,
  33. [QueryParameterNames.SPANS_CURSOR]: undefined,
  34. },
  35. });
  36. }}
  37. />
  38. );
  39. }
  40. export default RenderBlockingSelector;