Skip to content

Commit

Permalink
[Fleet] Sync hash history with Kibana scoped history (#102523)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed Jun 17, 2021
1 parent dc5972c commit b815394
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions x-pack/plugins/fleet/public/applications/fleet/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
12 changes: 12 additions & 0 deletions x-pack/plugins/fleet/public/applications/integrations/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}>
Expand Down

0 comments on commit b815394

Please sign in to comment.