Skip to content

Commit

Permalink
Declare , , and `` in root state
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Rak <[email protected]>
  • Loading branch information
rak-phillip committed May 20, 2024
1 parent 63968a4 commit 5a00bcc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
6 changes: 4 additions & 2 deletions shell/store/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ export const actions = {
}
},

async logout({ dispatch, commit, getters }, options = {}) {
async logout({
dispatch, commit, getters, rootState
}, options = {}) {
// So, we only do this check if auth has been initialized.
//
// It's possible to be logged in and visit auth/logout directly instead
Expand All @@ -362,7 +364,7 @@ export const actions = {
}

// Unload plugins - we will load again on login
await this.$plugin.logout();
await rootState.$plugin.logout();

try {
await dispatch('rancher/request', {
Expand Down
24 changes: 19 additions & 5 deletions shell/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ export const state = () => {
isRancherInHarvester: false,
targetRoute: null,
rootProduct: undefined,
$router: undefined,
$route: undefined,
$plugin: undefined,
};
};

Expand Down Expand Up @@ -722,6 +725,18 @@ export const mutations = {

targetRoute(state, route) {
state.targetRoute = route;
},

setRouter(state, router) {
state.$router = router;
},

setRoute(state, route) {
state.$route = route;
},

setPlugin(state, pluginDefinition) {
state.$plugin = pluginDefinition;
}
};

Expand Down Expand Up @@ -1128,11 +1143,10 @@ export const actions = {
}
},

nuxtClientInit({ dispatch, rootState }, nuxt) {
Object.defineProperty(rootState, '$router', { value: nuxt.app.router });
Object.defineProperty(rootState, '$route', { value: nuxt.route });
Object.defineProperty(rootState, '$plugin', { value: nuxt.app.$plugin });
Object.defineProperty(this, '$plugin', { value: nuxt.app.$plugin });
nuxtClientInit({ dispatch, commit, rootState }, nuxt) {
commit('setRouter', nuxt.app.router);
commit('setRoute', nuxt.route);
commit('setPlugin', nuxt.app.$plugin);

dispatch('management/rehydrateSubscribe');
dispatch('cluster/rehydrateSubscribe');
Expand Down

0 comments on commit 5a00bcc

Please sign in to comment.