mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Feat: Support url params (#25828)
Closes https://github.com/elastic/kibana/issues/23046 Switch to a hash history manager that supports pushState and replaceState. This makes the "basepath" part of the hash's concern, so anything before the hash no longer matters. This also allows undoing a bunch of hacky fixes. This also allows the `urlparam` function to work again! ヽ(;▽;)ノ 
This commit is contained in:
parent
5d73ffadd5
commit
1edb9a9bc8
3 changed files with 10 additions and 21 deletions
|
@ -175,6 +175,7 @@
|
|||
"handlebars": "^4.0.10",
|
||||
"hapi-auth-cookie": "^9.0.0",
|
||||
"history": "4.7.2",
|
||||
"history-extra": "^4.0.2",
|
||||
"humps": "2.0.1",
|
||||
"icalendar": "0.7.1",
|
||||
"inline-style": "^2.0.0",
|
||||
|
@ -269,4 +270,4 @@
|
|||
"engines": {
|
||||
"yarn": "^1.6.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,9 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import chrome from 'ui/chrome';
|
||||
import lzString from 'lz-string';
|
||||
import { createBrowserHistory, createMemoryHistory, parsePath, createPath } from 'history';
|
||||
import { get } from 'lodash';
|
||||
import { APP_ROUTE } from '../../common/lib/constants';
|
||||
import { createMemoryHistory, parsePath, createPath } from 'history';
|
||||
import createHashStateHistory from 'history-extra';
|
||||
import { getWindow } from './get_window';
|
||||
|
||||
function wrapHistoryInstance(history) {
|
||||
|
@ -132,17 +130,7 @@ const instances = new WeakMap();
|
|||
const getHistoryInstance = win => {
|
||||
// if no window object, use memory module
|
||||
if (typeof win === 'undefined' || !win.history) return createMemoryHistory();
|
||||
|
||||
const basePath = chrome.getBasePath();
|
||||
const basename = `${basePath}${APP_ROUTE}#/`;
|
||||
|
||||
// hacky fix for initial page load so basename matches with the hash
|
||||
if (win.location.hash === '') win.history.replaceState({}, '', `${basename}`);
|
||||
|
||||
// if window object, create browser instance
|
||||
return createBrowserHistory({
|
||||
basename,
|
||||
});
|
||||
return createHashStateHistory();
|
||||
};
|
||||
|
||||
export const historyProvider = (win = getWindow()) => {
|
||||
|
@ -150,11 +138,6 @@ export const historyProvider = (win = getWindow()) => {
|
|||
const instance = instances.get(win);
|
||||
if (instance) return instance;
|
||||
|
||||
// temporary fix for search params before the hash; remove them via location redirect
|
||||
// they can't be preserved given this upstream issue https://github.com/ReactTraining/history/issues/564
|
||||
if (get(win, 'location.search', '').length > 0)
|
||||
win.location = `${chrome.getBasePath()}${APP_ROUTE}${win.location.hash}`;
|
||||
|
||||
// create and cache wrapped history instance
|
||||
const historyInstance = getHistoryInstance(win);
|
||||
const wrappedInstance = wrapHistoryInstance(historyInstance);
|
||||
|
|
|
@ -10582,6 +10582,11 @@ highlight.js@^9.12.0, highlight.js@~9.12.0:
|
|||
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.12.0.tgz#e6d9dbe57cbefe60751f02af336195870c90c01e"
|
||||
integrity sha1-5tnb5Xy+/mB1HwKvM2GVhwyQwB4=
|
||||
|
||||
history-extra@^4.0.2:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/history-extra/-/history-extra-4.0.2.tgz#67b512c196e0a521be1d8ac83513f00ca761d9f3"
|
||||
integrity sha512-Nia8vzQHyQcxKQUt5/vxZegurkG2K23TplaWLk1V6EWTuNdZMJUJ78anwGkBcHuLBia8TFUct/R/QDlgRUA42A==
|
||||
|
||||
history@4.7.2, history@^4.7.2:
|
||||
version "4.7.2"
|
||||
resolved "https://registry.yarnpkg.com/history/-/history-4.7.2.tgz#22b5c7f31633c5b8021c7f4a8a954ac139ee8d5b"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue