query.tsx 625 B

1234567891011121314151617181920212223242526
  1. import type {Location} from 'history';
  2. import {defined} from 'sentry/utils';
  3. import {decodeQuery} from 'sentry/utils/discover/eventView';
  4. export function defaultQuery(): string {
  5. return '';
  6. }
  7. export function getQueryFromLocation(location: Location) {
  8. return decodeQuery(location);
  9. }
  10. export function updateLocationWithQuery(
  11. location: Location,
  12. query: string | null | undefined
  13. ) {
  14. if (defined(query)) {
  15. location.query.query = query;
  16. // make sure to clear the cursor every time the query is updated
  17. delete location.query.cursor;
  18. } else if (query === null) {
  19. delete location.query.query;
  20. }
  21. }