Merge pull request #3986 from richard-cox/master-fix-cluster-template-catalog-store

[master] Ensure we use the correct store when checking for catalog operation
This commit is contained in:
Richard Cox 2021-08-24 14:45:18 +01:00 committed by GitHub
commit a88ad64ce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View File

@ -696,13 +696,16 @@ export default {
return; return;
} }
const res = await this.repo.doAction((isUpgrade ? 'upgrade' : 'install'), input); const res = await this.repo.doAction((isUpgrade ? 'upgrade' : 'install'), input);
const operationId = `${ res.operationNamespace }/${ res.operationName }`; const operationId = `${ res.operationNamespace }/${ res.operationName }`;
// Non-admins without a cluster won't be able to fetch operations immediately // Non-admins without a cluster won't be able to fetch operations immediately
await this.repo.waitForOperation(operationId); await this.repo.waitForOperation(operationId);
// Dynamically use store decided when loading catalog (covers standard user case when there's not cluster)
const inStore = this.$store.getters['catalog/inStore'];
this.operation = await this.$store.dispatch('cluster/find', { this.operation = await this.$store.dispatch(`${ inStore }/find`, {
type: CATALOG.OPERATION, type: CATALOG.OPERATION,
id: operationId id: operationId
}); });

View File

@ -37,7 +37,8 @@ export const state = function() {
namespacedRepos: [], namespacedRepos: [],
charts: {}, charts: {},
versionInfos: {}, versionInfos: {},
config: { namespace: 'catalog' } config: { namespace: 'catalog' },
inStore: undefined,
}; };
}; };
@ -283,6 +284,10 @@ export const getters = {
return steps; return steps;
}; };
},
inStore(state) {
return state.inStore;
} }
}; };
@ -293,6 +298,10 @@ export const mutations = {
Object.assign(currentState, newState); Object.assign(currentState, newState);
}, },
setInStore(state, inStore) {
state.inStore = inStore;
},
setRepos(state, { cluster, namespaced }) { setRepos(state, { cluster, namespaced }) {
state.clusterRepos = cluster; state.clusterRepos = cluster;
state.namespacedRepos = namespaced; state.namespacedRepos = namespaced;
@ -321,7 +330,7 @@ export const actions = {
let promises = {}; let promises = {};
// Installing an app? This is fine (in cluster store) // Installing an app? This is fine (in cluster store)
// Fetching list of cluster templates? This is fine (in management store) // Fetching list of cluster templates? This is fine (in management store)
// Installing a cluster template? This isn't fine (in cluster store as per insalling app, but if there is no cluster we need to default to management) // Installing a cluster template? This isn't fine (in cluster store as per installing app, but if there is no cluster we need to default to management)
const inStore = rootGetters['currentCluster'] ? rootGetters['currentProduct'].inStore : 'management'; const inStore = rootGetters['currentCluster'] ? rootGetters['currentProduct'].inStore : 'management';
if ( rootGetters[`${ inStore }/schemaFor`](CATALOG.CLUSTER_REPO) ) { if ( rootGetters[`${ inStore }/schemaFor`](CATALOG.CLUSTER_REPO) ) {
@ -334,6 +343,9 @@ export const actions = {
const hash = await allHash(promises); const hash = await allHash(promises);
// As per comment above, when there are no clusters this will be management. Store it such that it can be used for those cases
commit('setInStore', inStore);
commit('setRepos', hash); commit('setRepos', hash);
const repos = getters['repos']; const repos = getters['repos'];