Skip to content
This repository was archived by the owner on Aug 12, 2026. It is now read-only.

Commit d89e721

Browse files
committed
Fix switching context from app view
Signed-off-by: Andrei Kvapil <[email protected]>
1 parent ffc0b02 commit d89e721

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

‎dashboard/src/components/Header/ContextSelector.tsx‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,21 @@ function ContextSelector() {
6666
const changeContext = () => {
6767
dispatch(actions.namespace.setNamespace(cluster, namespace));
6868
// Regex matching a namespaced route: e.g. /c/cluster/ns/namespace
69-
const nsRegex = /^\/c\/([^/]*)\/ns\/[^/]*\//;
69+
const nsRegex = /^\/c\/[^/]*\/ns\/[^/]*\//; // matches "/c/<cluster>/ns/<namespace>/"
70+
const base = `/c/${cluster}/ns/${namespace}/`;
7071
if (nsRegex.test(location.pathname)) {
71-
// Change the namespace in the route
72-
navigate(
73-
location.pathname
74-
.replace(nsRegex, `/c/${cluster}/ns/${namespace}/`)
75-
.concat(location.search),
76-
);
72+
const restOfPath = location.pathname.replace(nsRegex, "");
73+
// All application-related routes start with "apps/"
74+
if (restOfPath.startsWith("apps/")) {
75+
// go to the apps list for the newly-selected namespace
76+
navigate(app.apps.list(cluster, namespace) + location.search);
77+
} else {
78+
// keep the remainder of the path (catalog, operators, etc.)
79+
navigate(base + restOfPath + location.search);
80+
}
81+
} else {
82+
// fallback: just go to the apps list
83+
navigate(app.apps.list(cluster, namespace) + location.search);
7784
}
7885
setOpen(false);
7986
};

0 commit comments

Comments
 (0)