Skip to content

Commit b1b2567

Browse files
side nav and default layout no longer re-render when clusterReady toggles
1 parent 085a115 commit b1b2567

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

shell/components/SideNav.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import { TYPE_MODES } from '@shell/store/type-map';
2020
import { NAME as NAVLINKS } from '@shell/config/product/navlinks';
2121
import Group from '@shell/components/nav/Group';
2222
import LocaleSelector from '@shell/components/LocaleSelector';
23+
import { getClusterFromRoute } from 'utils/router';
24+
import { BLANK_CLUSTER } from 'store/store-types';
2325
2426
export default {
2527
name: 'SideNav',
@@ -91,7 +93,13 @@ export default {
9193
},
9294
9395
clusterReady(a, b) {
94-
if ( !isEqual(a, b) ) {
96+
const currentInStore = this.currentProduct?.inStore;
97+
const rootInStore = this.rootProduct?.inStore;
98+
99+
const isClusterBasedProduct = currentInStore === 'cluster' || rootInStore === 'cluster';
100+
const clusterInRoute = getClusterFromRoute(this.$route) && getClusterFromRoute(this.$route) !== BLANK_CLUSTER;
101+
102+
if ( (isClusterBasedProduct || clusterInRoute) && !isEqual(a, b) ) {
95103
// Immediately update because you'll see it come in later
96104
this.getGroups();
97105
}

shell/components/templates/default.vue

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import BrowserTabVisibility from '@shell/mixins/browser-tab-visibility';
2626
import { getClusterFromRoute, getProductFromRoute } from '@shell/utils/router';
2727
import SideNav from '@shell/components/SideNav';
2828
import { Layout } from '@shell/types/window-manager';
29+
import { BLANK_CLUSTER } from 'store/store-types';
2930
3031
const SET_LOGIN_ACTION = 'set-as-login';
3132
@@ -93,16 +94,33 @@ export default {
9394
return !this.$route?.matched?.length;
9495
},
9596
97+
/**
98+
* Product config specifies what vuex store is being used by type-map to generate its side nav, generally "management" or "cluster"
99+
* If the current product or root product are using a "cluster" store, this component will re-render the main outlet when clusterReady is toggled
100+
* clusterReady will also be used if the route contains a cluster param (excluding the blank cluster workaround: _)
101+
*/
102+
typemapStoreReady() {
103+
const currentInStore = this.currentProduct?.inStore;
104+
const rootInStore = this.rootProduct?.inStore;
105+
const clusterInRoute = !!getClusterFromRoute(this.$route) && getClusterFromRoute(this.$route) !== BLANK_CLUSTER;
106+
107+
if (currentInStore === 'cluster' || rootInStore === 'cluster' || clusterInRoute) {
108+
return this.clusterReady;
109+
}
110+
111+
return this.managementReady;
112+
},
113+
96114
/**
97115
* When navigation involves unloading one cluster and loading another, clusterReady toggles from true->false->true in middleware (before new route content renders)
98116
* Prevent rendering "outlet" until the route changes to avoid re-rendering old route content after its cluster is unloaded
117+
99118
*/
100119
clusterAndRouteReady() {
101120
const targetRoute = this.$store.getters['targetRoute'];
102121
const routeReady = targetRoute ? this.currentProduct?.name === getProductFromRoute(this.$route) && this.currentProduct?.name === getProductFromRoute(targetRoute) : this.currentProduct?.name === getProductFromRoute(this.$route);
103122
104-
return this.clusterReady &&
105-
this.clusterId === getClusterFromRoute(this.$route) && routeReady;
123+
return routeReady && this.typemapStoreReady;
106124
},
107125
},
108126
@@ -171,7 +189,7 @@ export default {
171189
>
172190
<Header />
173191
<SideNav
174-
v-if="clusterReady"
192+
v-if="typemapStoreReady"
175193
class="default-side-nav"
176194
/>
177195
<main

0 commit comments

Comments
 (0)