diff --git a/ui/core/app/components/form/host-set/add-hosts/index.js b/ui/core/app/components/form/host-set/add-hosts/index.js
index 03915cdee..74135ed90 100644
--- a/ui/core/app/components/form/host-set/add-hosts/index.js
+++ b/ui/core/app/components/form/host-set/add-hosts/index.js
@@ -28,7 +28,7 @@ export default class FormHostSetAddHostsIndexComponent extends Component {
*/
@computed('args.{model,hosts}')
get filteredHosts() {
- const currentHostIDs = this.args.hosts.map(host => host.id);
+ const currentHostIDs = this.args.model.host_ids.map(host => host.value);
return this.args.hosts.filter(({ id }) => !currentHostIDs.includes(id));
}
diff --git a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/hosts.js b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/hosts.js
index 01cfdb92e..8572fe6c3 100644
--- a/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/hosts.js
+++ b/ui/core/app/routes/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/hosts.js
@@ -25,11 +25,12 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogHostSetsHo
*/
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: all(hostSet.host_ids.map(id =>
- this.store.findRecord('host', id, { adapterOptions: { scopeID } })
+ 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 } })
))
});
}
diff --git a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/add-hosts.hbs b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/add-hosts.hbs
index 5268416ad..3b3070bf7 100644
--- a/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/add-hosts.hbs
+++ b/ui/core/app/templates/scopes/scope/projects/project/host-catalogs/host-catalog/host-sets/host-set/add-hosts.hbs
@@ -1,13 +1,5 @@
{{title (t "actions.add-hosts")}}
-{{!-- --}}
-
{
+ if(!updatedAttrs.hostIds.includes(id)) {
+ updatedAttrs.hostIds.push(id);
+ }
+ })
+ }
+
+ // If deleting hosts, filter them out of the array
+ if (method === 'remove-hosts') {
+ updatedAttrs.hostIds = updatedAttrs.hostIds.filter(id => {
+ return !attrs.hostIds.includes(id);
+ });
+ }
+
+ return hostSet.update(updatedAttrs);
});
// target