fix: Load hosts in a host set instead of all catalogs

This commit is contained in:
Susmitha Girumala committed 2020-09-10 15:11:44 -04:00
1 parent c4247ee9e1
commit 850d167ffb
1 file changed
+11 -4
@@ -1,9 +1,15 @@
import Route from '@ember/routing/route';
import { hash } from 'rsvp';
import { hash, all } from 'rsvp';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHostSetHostsRoute extends Route {
// =services
@service intl;
@service notify;
// =methods
/**
@@ -13,18 +19,18 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHo
this.store.unloadAll('host');
}
/**
* Loads all hosts under the current host catalog.
* @return {Promise{[HostModel]}}
*/
async model() {
const scopeID = this.modelFor('scopes.scope.projects.project').id;
const hostCatalogID = this.modelFor('scopes.scope.projects.project.host-catalogs.host-catalog').id;
const hostSet = this.modelFor('scopes.scope.projects.project.host-catalogs.host-catalog.host-sets.host-set');
return hash({
hostSet,
hosts: this.store.findAll('host', { adapterOptions: { scopeID, hostCatalogID } })
hosts: all(hostSet.host_ids.map(id =>
this.store.findRecord('host', id, { adapterOptions: { scopeID } })
))
});
}
@@ -37,6 +43,7 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHo
try {
const scopeID = this.modelFor('scopes.scope.projects.project').id;
const hostCatalogID = this.modelFor('scopes.scope.projects.project.host-catalogs.host-catalog').id;
//FIXME: Are adapterOptions needed?
await hostSet.removeHost(host.id, { adapterOptions : { scopeID, hostCatalogID } });
this.refresh();
this.notify.success(this.intl.t('notify.delete-success'));