mirror of https://github.com/rancher/ui.git
Merge pull request #3142 from loganhz/catalog-21008
Fallback to latest version if default version not exists in a catalog app
This commit is contained in:
commit
a297dff4dc
|
|
@ -64,6 +64,10 @@ export default Route.extend({
|
|||
def = get(app, 'externalIdInfo.version');
|
||||
}
|
||||
|
||||
if ( !links[def] ) {
|
||||
def = get(results, 'tpl.latestVersion');
|
||||
}
|
||||
|
||||
catalogTemplateUrl = links[def];
|
||||
|
||||
var version = get(this, 'settings.rancherVersion');
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { inject as service } from '@ember/service';
|
|||
import Resource from '@rancher/ember-api-store/models/resource';
|
||||
import C from 'ui/utils/constants';
|
||||
import { reference } from '@rancher/ember-api-store/utils/denormalize';
|
||||
import { compare as compareVersion } from 'ui/utils/parse-version';
|
||||
|
||||
const Template = Resource.extend({
|
||||
scope: service(),
|
||||
|
|
@ -14,6 +15,12 @@ const Template = Resource.extend({
|
|||
clusterCatalog: reference('clusterCatalogId', 'clusterCatalog', 'store'),
|
||||
projectCatalog: reference('projectCatalogId'),
|
||||
|
||||
latestVersion: computed('versionLinks', function() {
|
||||
const links = get(this, 'versionLinks');
|
||||
|
||||
return get(Object.keys(links || {}).sort((a, b) => compareVersion(a, b)), 'lastObject');
|
||||
}),
|
||||
|
||||
isGlobalCatalog: computed('clusterCatalog', 'projectCatalog', function() {
|
||||
if (!this.clusterCatalog && !this.projectCatalog) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -726,6 +726,8 @@ export default Component.extend(NewOrEdit, CatalogApp, {
|
|||
|
||||
initSelectedTemplateModel() {
|
||||
let def = get(this, 'templateResource.defaultVersion');
|
||||
const latest = get(this, 'templateResource.latestVersion');
|
||||
|
||||
const links = get(this, 'versionLinks');
|
||||
const app = get(this, 'primaryResource');
|
||||
|
||||
|
|
@ -733,11 +735,7 @@ export default Component.extend(NewOrEdit, CatalogApp, {
|
|||
def = get(app, 'externalIdInfo.version');
|
||||
}
|
||||
|
||||
if (links[def]) {
|
||||
set(this, 'selectedTemplateUrl', links[def]);
|
||||
} else {
|
||||
set(this, 'selectedTemplateUrl', null);
|
||||
}
|
||||
set(this, 'selectedTemplateUrl', links[def] || links[latest] || null)
|
||||
|
||||
return;
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue