[Fleet] Sync hash history with Kibana scoped history (#102523)

This commit is contained in:
Nicolas Chaulet 2021-06-17 13:57:35 -04:00 committed by GitHub
parent dc5972cc4a
commit b8153946c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View file

@ -206,6 +206,17 @@ export const FleetAppContext: React.FC<{
({ children, startServices, config, history, kibanaVersion, extensions, routerHistory }) => {
const isDarkMode = useObservable<boolean>(startServices.uiSettings.get$('theme:darkMode'));
const [routerHistoryInstance] = useState(routerHistory || createHashHistory());
// Sync our hash history with Kibana scoped history
useEffect(() => {
const unlistenParentHistory = history.listen(() => {
const newHash = createHashHistory();
if (newHash.location.pathname !== routerHistoryInstance.location.pathname) {
routerHistoryInstance.replace(newHash.location.pathname);
}
});
return unlistenParentHistory;
}, [history, routerHistoryInstance]);
return (
<startServices.i18n.Context>

View file

@ -191,6 +191,18 @@ export const IntegrationsAppContext: React.FC<{
const isDarkMode = useObservable<boolean>(startServices.uiSettings.get$('theme:darkMode'));
const [routerHistoryInstance] = useState(routerHistory || createHashHistory());
// Sync our hash history with Kibana scoped history
useEffect(() => {
const unlistenParentHistory = history.listen(() => {
const newHash = createHashHistory();
if (newHash.location.pathname !== routerHistoryInstance.location.pathname) {
routerHistoryInstance.replace(newHash.location.pathname);
}
});
return unlistenParentHistory;
}, [history, routerHistoryInstance]);
return (
<startServices.i18n.Context>
<KibanaContextProvider services={{ ...startServices }}>