diff --git a/addons/api/addon/generated/models/host-catalog.js b/addons/api/addon/generated/models/host-catalog.js
index 0591352e2..660711a70 100644
--- a/addons/api/addon/generated/models/host-catalog.js
+++ b/addons/api/addon/generated/models/host-catalog.js
@@ -39,11 +39,6 @@ export default class GeneratedHostCatalogModel extends BaseModel {
})
disabled;
- @attr({
- description: 'Attributes specific to the catalog type',
- })
- attributes;
-
@attr('number', {
description: 'Current version number of this resource.',
})
diff --git a/addons/api/addon/models/host-set.js b/addons/api/addon/models/host-set.js
index 98f7cd5e2..bd5f64f1a 100644
--- a/addons/api/addon/models/host-set.js
+++ b/addons/api/addon/models/host-set.js
@@ -1,5 +1,6 @@
import GeneratedHostSetModel from '../generated/models/host-set';
import { fragmentArray } from 'ember-data-model-fragments/attributes';
+import { types } from './host-catalog';
export default class HostSetModel extends GeneratedHostSetModel {
// =attributes
@@ -20,6 +21,14 @@ export default class HostSetModel extends GeneratedHostSetModel {
return this.type === 'plugin';
}
+ /**
+ * True if the host set is an unknown type.
+ * @type {boolean}
+ */
+ get isUnknown() {
+ return this.isPlugin && !types.includes(this.plugin?.name);
+ }
+
/**
* Returns if a host-set plugin is AWS or not
* @type {boolean}
@@ -41,7 +50,9 @@ export default class HostSetModel extends GeneratedHostSetModel {
* @type {string}
*/
get compositeType() {
- return this.plugin ? this.plugin.name : this.type;
+ if (this.isUnknown) return 'unknown';
+ if (this.isPlugin) return this.plugin.name;
+ return 'static';
}
/**
diff --git a/addons/api/addon/serializers/application.js b/addons/api/addon/serializers/application.js
index dcc33eff6..8f519e8e2 100644
--- a/addons/api/addon/serializers/application.js
+++ b/addons/api/addon/serializers/application.js
@@ -234,11 +234,13 @@ export default class ApplicationSerializer extends RESTSerializer {
*/
normalizeNestedAttributes(typeClass, hash) {
typeClass.attributes.forEach((attribute) => {
- const { isNestedAttribute } = attribute.options;
- const attributeValue = hash.attributes?.[attribute.name];
- if (isNestedAttribute && typeof attributeValue != 'undefined') {
- hash[attribute.name] = attributeValue;
- }
+ const {
+ name,
+ options: { isNestedAttribute },
+ } = attribute;
+ const value = hash.attributes?.[name];
+ const isUndefined = value === undefined;
+ if (isNestedAttribute && !isUndefined) hash[name] = value;
});
return hash;
}
@@ -261,15 +263,8 @@ export default class ApplicationSerializer extends RESTSerializer {
name,
options: { isNestedSecret },
} = attribute;
- const attributeValue = hash.secrets?.[name];
-
- // FIXME: This could be improved
- if (isNestedSecret) {
- hash[name] = null;
- if (typeof attributeValue != 'undefined') {
- hash[name] = attributeValue;
- }
- }
+ const value = hash.secrets?.[name];
+ if (isNestedSecret) hash[name] = value || null;
});
return hash;
}
diff --git a/addons/api/addon/serializers/host-catalog.js b/addons/api/addon/serializers/host-catalog.js
index f5d1cd983..77c78c680 100644
--- a/addons/api/addon/serializers/host-catalog.js
+++ b/addons/api/addon/serializers/host-catalog.js
@@ -1,5 +1,4 @@
import ApplicationSerializer from './application';
-import { copy } from 'ember-copy';
const fieldsByType = {
aws: [
@@ -57,11 +56,4 @@ export default class HostCatalogSerializer extends ApplicationSerializer {
delete serialized.secrets;
return serialized;
}
-
- normalize(typeClass, hash, ...rest) {
- let normalizedHash = copy(hash, true);
- const normalized = super.normalize(typeClass, normalizedHash, ...rest);
- delete normalized.data.attributes.attributes;
- return normalized;
- }
}
diff --git a/addons/api/tests/unit/models/host-set-test.js b/addons/api/tests/unit/models/host-set-test.js
index 33189d3d4..f3dd6c020 100644
--- a/addons/api/tests/unit/models/host-set-test.js
+++ b/addons/api/tests/unit/models/host-set-test.js
@@ -183,15 +183,19 @@ module('Unit | Model | host set', function (hooks) {
test('get compositeType return expected values', async function (assert) {
assert.expect(3);
const store = this.owner.lookup('service:store');
- const modelPlugin = store.createRecord('host-set', {
+ const modelPlugin1 = store.createRecord('host-set', {
+ type: 'plugin',
+ plugin: { name: 'aws' },
+ });
+ const modelPlugin2 = store.createRecord('host-set', {
type: 'plugin',
plugin: { name: 'Test name' },
});
const modelStatic = store.createRecord('host-set', {
type: 'static',
});
- assert.equal(typeof modelPlugin.compositeType, 'string');
- assert.equal(modelPlugin.compositeType, 'Test name');
+ assert.equal(modelPlugin1.compositeType, 'aws');
+ assert.equal(modelPlugin2.compositeType, 'unknown');
assert.equal(modelStatic.compositeType, 'static');
});
diff --git a/ui/admin/app/components/form/host-set/aws/index.hbs b/ui/admin/app/components/form/host-set/aws/index.hbs
index d61cdc0de..f090e2d18 100644
--- a/ui/admin/app/components/form/host-set/aws/index.hbs
+++ b/ui/admin/app/components/form/host-set/aws/index.hbs
@@ -78,6 +78,75 @@
<:title>{{t 'form.provider.filter.label'}}
<:description>{{t 'form.provider.filter.help'}}
+ <:body>
+ {{#if @model.errors.filters}}
+
+ {{#each @model.errors.filters as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+
+ {{t 'titles.value'}}
+
+
+
+
+ {{#each @model.filters as |filter i|}}
+
+
+
+
+
+
+
+
+ {{t 'actions.remove'}}
+
+
+
+ {{/each}}
+
+
+
+
+
+
+
+ {{t 'actions.add'}}
+
+
+
+
+
+
{{#if (can 'save model' @model)}}
diff --git a/ui/admin/app/components/form/host-set/azure/index.hbs b/ui/admin/app/components/form/host-set/azure/index.hbs
index 9150d5e7f..8abc0724d 100644
--- a/ui/admin/app/components/form/host-set/azure/index.hbs
+++ b/ui/admin/app/components/form/host-set/azure/index.hbs
@@ -78,6 +78,7 @@
- {{#if @model.errors.name}}
+ {{#if @model.errors.address}}
- {{#each @model.errors.name as |error|}}
+ {{#each @model.errors.address as |error|}}
{{error.message}}
{{/each}}
diff --git a/ui/admin/app/components/form/target/add-host-sets/index.hbs b/ui/admin/app/components/form/target/add-host-sets/index.hbs
index 241489b42..bd4c97765 100644
--- a/ui/admin/app/components/form/target/add-host-sets/index.hbs
+++ b/ui/admin/app/components/form/target/add-host-sets/index.hbs
@@ -33,33 +33,9 @@
/>
{{hostSet.name}}
- {{#if hostSet.isPlugin}}
-
- {{t
- (concat
- 'resources.host-catalog.types.'
- hostSet.compositeType
- '.label'
- )
- }}
-
- {{else}}
-
- {{t
- (concat
- 'resources.host-catalog.types.'
- hostSet.compositeType
- '.label'
- )
- }}
-
- {{/if}}
+
+
+
{{hostSet.host_catalog_id}}
diff --git a/ui/admin/app/components/host-catalog-type-badge/index.hbs b/ui/admin/app/components/host-catalog-type-badge/index.hbs
new file mode 100644
index 000000000..8ee191dea
--- /dev/null
+++ b/ui/admin/app/components/host-catalog-type-badge/index.hbs
@@ -0,0 +1,15 @@
+{{#if @model.isStatic}}
+
+ {{t (concat 'resources.host-catalog.types.' @model.compositeType '.label')}}
+
+{{else if @model.isUnknown}}
+
+ {{t (concat 'resources.host-catalog.types.' @model.compositeType '.label')}}
+
+{{else}}
+
+ {{t (concat 'resources.host-catalog.types.' @model.compositeType '.label')}}
+
+{{/if}}
\ No newline at end of file
diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set.js
index 31339c0dc..5ffb8cf76 100644
--- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set.js
+++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/host-set.js
@@ -1,4 +1,5 @@
import Route from '@ember/routing/route';
+import { action } from '@ember/object';
export default class ScopesScopeHostCatalogsHostCatalogHostSetsHostSetRoute extends Route {
// =methods
@@ -49,4 +50,30 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsHostSetRoute exte
}
);
}
+
+ /**
+ * Adds a string item to array `property` on the passed `filter`.
+
+ * @param {hostSetModel} hostSet
+ * @param {string} property
+ * @param {string} value
+ */
+ @action
+ async addStringItem(hostSet, property, value) {
+ const array = hostSet.get(property);
+ array.addObject({ value });
+ }
+
+ /**
+ * Removes an item from array `property` at `index` on the
+ * passed `hostSet`.
+ * @param {hostSetModel} hostSet
+ * @param {string} property
+ * @param {number} index
+ */
+ @action
+ async removeItemByIndex(hostSet, property, index) {
+ const array = hostSet.get(property);
+ array.removeAt(index);
+ }
}
diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/new.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/new.js
index 952e5d195..38b1c86c6 100644
--- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/new.js
+++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/new.js
@@ -63,4 +63,28 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsNewRoute extends
async changeType(type) {
await this.router.replaceWith({ queryParams: { type } });
}
+ /**
+ * Adds a string item to array `property` on the passed `filter`.
+
+ * @param {hostSetModel} hostSet
+ * @param {string} property
+ * @param {string} value
+ */
+ @action
+ async addStringItem(hostSet, property, value) {
+ const array = hostSet.get(property);
+ array.addObject({ value });
+ }
+ /**
+ * Removes an item from array `property` at `index` on the
+ * passed `hostSet`.
+ * @param {hostSetModel} hostSet
+ * @param {string} property
+ * @param {number} index
+ */
+ @action
+ async removeItemByIndex(hostSet, property, index) {
+ const array = hostSet.get(property);
+ array.removeAt(index);
+ }
}
diff --git a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts.hbs b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts.hbs
index f854d86e0..21d06fcb9 100644
--- a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts.hbs
+++ b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts.hbs
@@ -26,29 +26,7 @@
{{host.description}}
- {{#if host.isStatic}}
-
- {{t
- (concat
- 'resources.host-catalog.types.' host.compositeType '.label'
- )
- }}
-
- {{else}}
-
- {{t
- (concat
- 'resources.host-catalog.types.' host.compositeType '.label'
- )
- }}
-
- {{/if}}
+
\ No newline at end of file
diff --git a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/index.hbs b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/index.hbs
index 8a949544c..a8f12fff4 100644
--- a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/index.hbs
+++ b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/index.hbs
@@ -25,33 +25,7 @@
{{hostSet.description}}
- {{#if hostSet.isStatic}}
-
- {{t
- (concat
- 'resources.host-catalog.types.'
- hostSet.compositeType
- '.label'
- )
- }}
-
- {{else}}
-
- {{t
- (concat
- 'resources.host-catalog.types.'
- hostSet.compositeType
- '.label'
- )
- }}
-
- {{/if}}
+
\ No newline at end of file
diff --git a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/hosts/index.hbs b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/hosts/index.hbs
index 8877b6ea1..7176af48f 100644
--- a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/hosts/index.hbs
+++ b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/hosts/index.hbs
@@ -61,7 +61,7 @@
- {{host.attributes.address}}
+ {{host.address}}
{{/each}}
diff --git a/ui/admin/app/templates/scopes/scope/host-catalogs/index.hbs b/ui/admin/app/templates/scopes/scope/host-catalogs/index.hbs
index 79e33a11c..85262272b 100644
--- a/ui/admin/app/templates/scopes/scope/host-catalogs/index.hbs
+++ b/ui/admin/app/templates/scopes/scope/host-catalogs/index.hbs
@@ -56,43 +56,7 @@
{{hostCatalog.description}}
- {{#if hostCatalog.isStatic}}
-
- {{t
- (concat
- 'resources.host-catalog.types.'
- hostCatalog.compositeType
- '.label'
- )
- }}
-
- {{else if hostCatalog.isUnknown}}
-
- {{t
- (concat
- 'resources.host-catalog.types.'
- hostCatalog.compositeType
- '.label'
- )
- }}
-
- {{else}}
-
- {{t
- (concat
- 'resources.host-catalog.types.'
- hostCatalog.compositeType
- '.label'
- )
- }}
-
- {{/if}}
+
{{hostSet.model.description}}
- {{#if hostSet.model.isPlugin}}
-
- {{t
- (concat
- 'resources.host-catalog.types.'
- hostSet.model.compositeType
- '.label'
- )
- }}
-
- {{else}}
-
- {{t
- (concat
- 'resources.host-catalog.types.'
- hostSet.model.compositeType
- '.label'
- )
- }}
-
- {{/if}}
-
+