diff --git a/app/catalog-tab/launch/route.js b/app/catalog-tab/launch/route.js index 5703cd771..2db7492fe 100644 --- a/app/catalog-tab/launch/route.js +++ b/app/catalog-tab/launch/route.js @@ -21,18 +21,29 @@ export default Route.extend({ model(params, transition) { const { store, clusterStore } = this; - const dependencies = { - tpl: get(this, 'catalog').fetchTemplate(params.template), - namespaces: clusterStore.findAll('namespace') - }; - - if ( params.upgrade ) { - dependencies.upgrade = get(this, 'catalog').fetchTemplate(`${ params.template }-${ params.upgrade }`, true); - } + let dependencies = { namespaces: clusterStore.findAll('namespace') }; if (params.appId) { dependencies.app = store.find('app', params.appId); + dependencies.app.then((appData) => { + const getCurrentVersion = (app) => { + const externalId = app.externalId; + const splitId = externalId.split('version=') + const currentVersion = splitId[1]; + + return currentVersion; + } + const currentVersion = getCurrentVersion(appData); + + 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); + }) } + + if (params.appName) { dependencies.app = store.find('app', null, { filter: { name: params.appName } }).then((apps) => get(apps, 'firstObject')); } diff --git a/app/models/app.js b/app/models/app.js index 611f600d5..d6458aa6f 100644 --- a/app/models/app.js +++ b/app/models/app.js @@ -216,14 +216,16 @@ const App = Resource.extend(StateCounts, EndpointPorts, { const catalogId = get(this, 'externalIdInfo.catalog'); const vKeys = Object.keys(get(this, 'catalogTemplate.versionLinks')); const latestVersion = vKeys[vKeys.length - 1]; + const currentVersion = get(this, 'externalIdInfo.version') get(this, 'router').transitionTo('catalog-tab.launch', templateId, { queryParams: { - appId: get(this, 'id'), - catalog: catalogId, - namespaceId: get(this, 'targetNamespace'), - upgrade: latestVersion, - istio: get(this, 'isIstio') + appId: get(this, 'id'), + catalog: catalogId, + namespaceId: get(this, 'targetNamespace'), + upgrade: latestVersion, + istio: get(this, 'isIstio'), + currentVersion } }); }, diff --git a/lib/shared/addon/catalog/service.js b/lib/shared/addon/catalog/service.js index e4916760c..d605229e0 100644 --- a/lib/shared/addon/catalog/service.js +++ b/lib/shared/addon/catalog/service.js @@ -67,7 +67,7 @@ export default Service.extend({ let extInfo = parseHelmExternalId(app.get('externalId')); if ( extInfo && extInfo.templateId ) { - deps.push(this.fetchTemplate(extInfo.templateId, false)); + deps.push(this.fetchTemplate(extInfo.templateId, false, extInfo.version)); } }); @@ -81,7 +81,7 @@ export default Service.extend({ let extInfo = get(app, 'externalIdInfo'); if ( extInfo && extInfo.templateId ) { - deps.push(this.fetchTemplate(extInfo.templateId, false)); + deps.push(this.fetchTemplate(extInfo.templateId, false, extInfo.version)); } }); @@ -108,8 +108,9 @@ export default Service.extend({ return get(this, 'globalStore').getById('templateversion', id); }, - fetchTemplate(id, upgrade = false) { + fetchTemplate(id, upgrade = false, currentVersion) { let type, cached, params; + const clusterName = get(this, 'scope.currentCluster.id'); if ( upgrade === true ) { type = 'templateversions'; @@ -117,13 +118,24 @@ export default Service.extend({ } else { type = 'templates'; // we cant check for cached here anylonger because the clusterName is used to build a dynamic versions list of compatible versions for this clusters kube version - params = { clusterName: get(this, 'scope.currentCluster.id') }; + params = { + clusterName, + currentVersion + }; } if ( cached ) { return resolve(cached); } + params = { + // currentVersion allows legacy apps to be upgraded + // after Rancher is upgraded to a version higher than the app's max + // supported Rancher version + clusterName, + currentVersion, + } + let url = this._addLimits(`${ get(this, 'app.apiEndpoint') }/${ type }/${ id }`, params); return get(this, 'globalStore').request({ url });