fix: Reload host-set to get all attributes

Update comments
This commit is contained in:
Susmitha Girumala committed 2020-09-10 15:11:45 -04:00
1 parent b942257d12
commit 7186304f3a
6 files changed
+32 -38

No files matched your search

@@ -23,7 +23,7 @@ export default class FormHostSetAddHostsIndexComponent extends Component {
}
/**
* Hosts not currently assigned to current host set.
* Hosts currently not assigned to current host set.
* @type {[HostModel]}
*/
@computed('args.{model,hosts}')
@@ -34,6 +34,10 @@ export default class FormHostSetAddHostsIndexComponent extends Component {
// =actions
/**
* Toggle host selection
* @param {HostModel} host
*/
@action
toggleHost(host) {
if (!this.selectedHostIDs.includes(host.id)) {
@@ -43,6 +47,10 @@ export default class FormHostSetAddHostsIndexComponent extends Component {
}
}
/**
* Callback submit with selected host ids
* @param {requestCallback} fn
*/
@action
submit(fn) {
fn(this.selectedHostIDs);
@@ -13,6 +13,7 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHo
const { id: scopeID } = this.modelFor('scopes.scope.projects.project');
const hostCatalogID = this.modelFor('scopes.scope.projects.project.host-catalogs.host-catalog').id;
return this.store.findRecord('host-set', host_set_id, {
reload: true,
adapterOptions: { scopeID, hostCatalogID }
});
}
@@ -20,15 +20,14 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHo
}
/**
* Loads all hosts under the current host catalog.
* @return {Promise{[HostModel]}}
* Loads current host set and all hosts under the current host catalog.
* @return {Promise{HostSetModel,[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,
hostSet: this.modelFor('scopes.scope.projects.project.host-catalogs.host-catalog.host-sets.host-set'),
hosts: this.store.findAll('host', { adapterOptions: { scopeID, hostCatalogID } })
});
}
@@ -20,23 +20,24 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHo
}
/**
* Loads all hosts under the current host catalog.
* @return {Promise{[HostModel]}}
* Loads all hosts under the current host set.
* @return {Promise{HostSetModel,[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: this.store.findRecord('host-set', hostSet.id, { adapterOptions: { scopeID, hostCatalogID } }),
hosts: all(hostSet.host_ids.map(hostFragment =>
this.store.findRecord('host', hostFragment.value, { adapterOptions: { scopeID, hostCatalogID } })
hostSet,
hosts: all(hostSet.host_ids.map(host =>
this.store.findRecord('host', host.value, { adapterOptions: { scopeID, hostCatalogID } })
))
});
}
/**
* Remove a host from the current hostset and redirect to hosts index.
* Remove a host from the current host set and redirect to hosts index.
* @param {HostSetModel} hostSet
* @param {HostModel} host
*/
@action
@@ -44,7 +45,6 @@ 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'));
@@ -0,0 +1,12 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
// import { render } from '@ember/test-helpers';
// import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | form/host-set/add-hosts', function(hooks) {
setupRenderingTest(hooks);
test('it renders', async function(assert) {
assert.expect(0);
});
});
@@ -1,26 +0,0 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | form/host-set/add-hosts/index', function(hooks) {
setupRenderingTest(hooks);
test('it renders', async function(assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`<Form::HostSet::AddHosts::Index />`);
assert.equal(this.element.textContent.trim(), '');
// Template block usage:
await render(hbs`
<Form::HostSet::AddHosts::Index>
template block text
</Form::HostSet::AddHosts::Index>
`);
assert.equal(this.element.textContent.trim(), 'template block text');
});
});