Merge pull request #4795 from catherineluse/fix-mcapp-upgrade

This commit is contained in:
Catherine Luse 2021-12-17 22:55:10 -07:00 committed by GitHub
commit e30d79f1ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 4 deletions

View File

@ -19,17 +19,40 @@ export default Route.extend({
var store = get(this, 'globalStore');
var dependencies = {
tpl: get(this, 'catalog').fetchTemplate(params.template),
projects: this.scope.getAllProjects(),
clusters: this.scope.getAllClusters(),
};
if ( params.upgrade ) {
dependencies.upgrade = get(this, 'catalog').fetchTemplate(`${ params.template }-${ params.upgrade }`, true);
}
if (params.appId) {
dependencies.app = store.find('multiclusterapp', params.appId);
dependencies.app.then((appData) => {
const getCurrentVersion = (app) => {
const templateVersionId = app.templateVersionId;
const splitId = templateVersionId.split('-');
const currentVersion = splitId[splitId.length - 1];
return currentVersion;
}
const currentVersion = getCurrentVersion(appData);
// If an app ID is given, the current app version will be used in the
// multi-cluster app launch route.
dependencies.upgrade = get(this, 'catalog').fetchTemplate(`${ params.template }-${ params.upgrade }`, true, currentVersion);
dependencies.tpl = get(this, 'catalog').fetchTemplate(params.template, false, currentVersion);
})
.catch((err) => {
throw new Error(err);
})
} else {
// If an app ID is not given, the current app version will not be used
// in the multi-cluster app launch route.
if ( params.upgrade ) {
dependencies.upgrade = get(this, 'catalog').fetchTemplate(`${ params.template }-${ params.upgrade }`, true);
}
dependencies.tpl = get(this, 'catalog').fetchTemplate(params.template)
}
return hash(dependencies, 'Load dependencies').then((results) => {