utils.tsx 526 B

12345678910111213141516171819202122
  1. import pick from 'lodash/pick';
  2. import * as qs from 'query-string';
  3. import {URL_PARAM} from 'sentry/constants/pageFilters';
  4. const DEFAULT_STATUS = 'unresolved';
  5. /**
  6. * Get query for API given the current location.search string
  7. */
  8. export function getQuery(search: string) {
  9. const query = qs.parse(search);
  10. const status = typeof query.status !== 'undefined' ? query.status : DEFAULT_STATUS;
  11. const queryParams = {
  12. status,
  13. ...pick(query, ['cursor', ...Object.values(URL_PARAM)]),
  14. };
  15. return queryParams;
  16. }