зеркало из https://github.com/mozilla/treeherder.git
Bug 1623589 - Make filter URL handling more resilient (#6164)
This commit is contained in:
Родитель
1ff6e16cdd
Коммит
1c8759f89f
|
@ -2,7 +2,7 @@ import pick from 'lodash/pick';
|
|||
import isEqual from 'lodash/isEqual';
|
||||
|
||||
import { thFailureResults } from './constants';
|
||||
import { parseQueryParams } from './url';
|
||||
import { extractSearchString, parseQueryParams } from './url';
|
||||
|
||||
// used with field-filters to determine how to match the value against the
|
||||
// job field.
|
||||
|
@ -100,11 +100,11 @@ export const hasUrlFilterChanges = function hasUrlFilterChanges(
|
|||
newURL,
|
||||
) {
|
||||
const oldFilters = pick(
|
||||
parseQueryParams(oldURL.split('?')[1]),
|
||||
parseQueryParams(extractSearchString(oldURL)),
|
||||
allFilterParams,
|
||||
);
|
||||
const newFilters = pick(
|
||||
parseQueryParams(newURL.split('?')[1]),
|
||||
parseQueryParams(extractSearchString(newURL)),
|
||||
allFilterParams,
|
||||
);
|
||||
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
import { thDefaultRepo } from './constants';
|
||||
import { createQueryParams, getApiUrl, uiJobsUrlBase } from './url';
|
||||
import {
|
||||
createQueryParams,
|
||||
extractSearchString,
|
||||
getApiUrl,
|
||||
uiJobsUrlBase,
|
||||
} from './url';
|
||||
|
||||
export const getQueryString = function getQueryString() {
|
||||
return window.location.hash.split('?')[1];
|
||||
return extractSearchString(window.location.hash);
|
||||
};
|
||||
|
||||
export const getAllUrlParams = function getAllUrlParams() {
|
||||
|
|
|
@ -120,6 +120,12 @@ export const parseQueryParams = function parseQueryParams(search) {
|
|||
);
|
||||
};
|
||||
|
||||
export const extractSearchString = function getQueryString(url) {
|
||||
const parts = url.split('?');
|
||||
|
||||
return parts[parts.length - 1];
|
||||
};
|
||||
|
||||
// `api` requires a preceding forward slash
|
||||
export const createApiUrl = function createApiUrl(api, params) {
|
||||
const apiUrl = getApiUrl(api);
|
||||
|
|
|
@ -113,7 +113,9 @@ export default class FilterModel {
|
|||
* will get updates.
|
||||
*/
|
||||
push = () => {
|
||||
window.location.hash = `#/jobs?${this.getFilterQueryString()}`;
|
||||
const { origin } = window.location;
|
||||
|
||||
window.location.href = `${origin}/#/jobs?${this.getFilterQueryString()}`;
|
||||
};
|
||||
|
||||
setOnlySuperseded = () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче