Remove route action to load all MC App template versions

only load the versions we need

rancher/rancher#17790
This commit is contained in:
Westly Wright 2019-01-31 14:45:08 -07:00
parent 03a280a7fc
commit 75f2a5f274
No known key found for this signature in database
GPG Key ID: 4FAB3D8673DC54A3
2 changed files with 28 additions and 8 deletions

View File

@ -1,20 +1,26 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { hash } from 'rsvp';
import { all } from 'rsvp';
import { get } from '@ember/object';
export default Route.extend({
globalStore: service(),
catalog: service(),
beforeModel() {
return hash({
templateversions: this.globalStore.find('templateversion'),
templates: this.catalog.fetchTemplates(),
});
},
model() {
return this.globalStore.findAll('multiclusterapp').then( (resp) => ({ apps: resp }));
},
afterModel(model/* , transition */) {
let promises = [];
get(model, 'apps').forEach((app) => {
promises.push(this.catalog.fetchTemplate(get(app, 'templateVersionId'), true));
});
return all(promises).then(() => {
return this.catalog.fetchMultiClusterAppTemplates(get(model, 'apps'));
});
},
});

View File

@ -102,6 +102,20 @@ export default Service.extend({
return allSettled(deps);
},
fetchMultiClusterAppTemplates(apps) {
let deps = [];
apps.forEach((app) => {
let extInfo = get(app, 'externalIdInfo');
if ( extInfo && extInfo.templateId ) {
deps.push(this.fetchTemplate(extInfo.templateId, false));
}
});
return allSettled(deps);
},
fetchUnScopedCatalogs() {
return hash({
projectCatalogs: this.fetchCatalogs('projectCatalog'),