Skip to content

Commit 2605cff

Browse files
committed
fix: saving previous path
1 parent ff317f3 commit 2605cff

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/state/useAfterInitHook.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,25 @@ import { clusterState } from './clusterAtom';
88
const PREVIOUS_PATHNAME_KEY = 'busola.previous-pathname';
99

1010
export function savePreviousPath() {
11-
const { pathname } = window.location;
11+
const queryParams = new URLSearchParams(window.location.search);
1212

13-
if (pathname !== '/' && pathname !== '/clusters') {
14-
localStorage.setItem(PREVIOUS_PATHNAME_KEY, pathname);
13+
const layoutParam = queryParams.get('layout');
14+
const showCreateParam = queryParams.get('showCreate');
15+
16+
let previousPath = window.location.pathname;
17+
18+
if (layoutParam || showCreateParam) {
19+
previousPath += '?';
20+
const params = [];
21+
22+
if (layoutParam) params.push(`layout=${layoutParam}`);
23+
if (showCreateParam) params.push(`showCreate=${showCreateParam}`);
24+
25+
previousPath += params.join('&');
26+
}
27+
28+
if (previousPath !== '/' && previousPath !== '/clusters') {
29+
localStorage.setItem(PREVIOUS_PATHNAME_KEY, previousPath);
1530
}
1631
}
1732

0 commit comments

Comments
 (0)