From 361bdf02a4869f82f0eb0817df5d37e0f4ba7f55 Mon Sep 17 00:00:00 2001
From: dharini
Date: Sun, 13 Feb 2022 22:42:34 -0800
Subject: [PATCH 01/14] updates to host-set plugin filters
---
.../components/form/host-set/aws/index.hbs | 86 ++++++++++++++++++-
.../components/form/host-set/azure/index.hbs | 1 +
.../app/components/form/host-set/index.hbs | 2 +
.../host-catalog/host-sets/host-set.js | 28 ++++++
.../host-catalog/host-sets/index.js | 1 +
.../host-catalog/host-sets/new.js | 25 ++++++
.../host-catalog/host-sets/host-set/index.hbs | 2 +
.../host-catalog/host-sets/new.hbs | 2 +
8 files changed, 146 insertions(+), 1 deletion(-)
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 f800e9d53..5f5b54838 100644
--- a/ui/admin/app/components/form/host-set/aws/index.hbs
+++ b/ui/admin/app/components/form/host-set/aws/index.hbs
@@ -6,7 +6,7 @@
@showEditToggle={{if @model.isNew false true}}
as |form|
>
-
+
<: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|}}
+
+
+
+ FIELDD
+
+
+
+
+
+ {{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 340860893..cfa9f2591 100644
--- a/ui/admin/app/components/form/host-set/azure/index.hbs
+++ b/ui/admin/app/components/form/host-set/azure/index.hbs
@@ -80,6 +80,7 @@
\ No newline at end of file
diff --git a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/new.hbs b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/new.hbs
index 941f3e819..4047f364c 100644
--- a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/new.hbs
+++ b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/new.hbs
@@ -5,4 +5,6 @@
@submit={{route-action 'save' @model}}
@cancel={{route-action 'cancel' @model}}
@changeType={{route-action 'changeType' @model.type}}
+ @removeItemByIndex={{route-action 'removeItemByIndex' @model}}
+ @addStringItem={{route-action 'addStringItem' @model}}
/>
\ No newline at end of file
From d53cfbcc3318e15ee36ee46515c6cb72446bfd8c Mon Sep 17 00:00:00 2001
From: Randall Morey
Date: Mon, 14 Feb 2022 11:14:52 -0500
Subject: [PATCH 02/14] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20simplify=20nes?=
=?UTF-8?q?ted=20fields=20normalization?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
addons/api/addon/serializers/application.js | 23 ++++++++-------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/addons/api/addon/serializers/application.js b/addons/api/addon/serializers/application.js
index dcc33eff6..0b20dd128 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;
});
return hash;
}
From ac215e200f32772050054e28496d2fca45dde9a6 Mon Sep 17 00:00:00 2001
From: Randall Morey
Date: Mon, 14 Feb 2022 11:24:58 -0500
Subject: [PATCH 03/14] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20simplify=20hos?=
=?UTF-8?q?t=20catalog=20modeling=20and=20normalization?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
addons/api/addon/generated/models/host-catalog.js | 5 -----
addons/api/addon/serializers/host-catalog.js | 8 --------
addons/api/tests/unit/serializers/host-catalog-test.js | 8 --------
3 files changed, 21 deletions(-)
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/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/serializers/host-catalog-test.js b/addons/api/tests/unit/serializers/host-catalog-test.js
index 2811dea39..8b1af8c94 100644
--- a/addons/api/tests/unit/serializers/host-catalog-test.js
+++ b/addons/api/tests/unit/serializers/host-catalog-test.js
@@ -190,10 +190,6 @@ module('Unit | Serializer | host catalog', function (hooks) {
description: 'Test description',
authorized_actions: ['no-op'],
type: 'static',
- access_key_id: null,
- secret_access_key: null,
- secret_id: null,
- secret_value: null,
},
relationships: {},
},
@@ -249,8 +245,6 @@ module('Unit | Serializer | host catalog', function (hooks) {
region: 'Illinois',
access_key_id: '0xF3B0a6f8',
secret_access_key: 'zq{2:IVc8@W^',
- secret_id: null,
- secret_value: null,
},
relationships: {},
},
@@ -310,8 +304,6 @@ module('Unit | Serializer | host catalog', function (hooks) {
client_id: 'client',
tenant_id: 'tenant',
subscription_id: 'subscription',
- access_key_id: null,
- secret_access_key: null,
},
relationships: {},
},
From 93fd52954f2f4127ba749591e480772b618a068a Mon Sep 17 00:00:00 2001
From: Randall Morey
Date: Mon, 14 Feb 2022 11:50:39 -0500
Subject: [PATCH 04/14] =?UTF-8?q?chore:=20=F0=9F=A4=96=20explicitly=20set?=
=?UTF-8?q?=20secrets=20to=20null=20when=20missing?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
addons/api/addon/serializers/application.js | 2 +-
addons/api/tests/unit/serializers/host-catalog-test.js | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/addons/api/addon/serializers/application.js b/addons/api/addon/serializers/application.js
index 0b20dd128..8f519e8e2 100644
--- a/addons/api/addon/serializers/application.js
+++ b/addons/api/addon/serializers/application.js
@@ -264,7 +264,7 @@ export default class ApplicationSerializer extends RESTSerializer {
options: { isNestedSecret },
} = attribute;
const value = hash.secrets?.[name];
- if (isNestedSecret) hash[name] = value;
+ if (isNestedSecret) hash[name] = value || null;
});
return hash;
}
diff --git a/addons/api/tests/unit/serializers/host-catalog-test.js b/addons/api/tests/unit/serializers/host-catalog-test.js
index 8b1af8c94..2811dea39 100644
--- a/addons/api/tests/unit/serializers/host-catalog-test.js
+++ b/addons/api/tests/unit/serializers/host-catalog-test.js
@@ -190,6 +190,10 @@ module('Unit | Serializer | host catalog', function (hooks) {
description: 'Test description',
authorized_actions: ['no-op'],
type: 'static',
+ access_key_id: null,
+ secret_access_key: null,
+ secret_id: null,
+ secret_value: null,
},
relationships: {},
},
@@ -245,6 +249,8 @@ module('Unit | Serializer | host catalog', function (hooks) {
region: 'Illinois',
access_key_id: '0xF3B0a6f8',
secret_access_key: 'zq{2:IVc8@W^',
+ secret_id: null,
+ secret_value: null,
},
relationships: {},
},
@@ -304,6 +310,8 @@ module('Unit | Serializer | host catalog', function (hooks) {
client_id: 'client',
tenant_id: 'tenant',
subscription_id: 'subscription',
+ access_key_id: null,
+ secret_access_key: null,
},
relationships: {},
},
From 9ccae001d3a24b7a0acf896b04d82e429560eefa Mon Sep 17 00:00:00 2001
From: dharini
Date: Mon, 14 Feb 2022 10:20:00 -0800
Subject: [PATCH 05/14] =?UTF-8?q?fix:=20=F0=9F=90=9B=20lint?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../components/form/host-set/aws/index.hbs | 33 ++++++----------
.../host-catalog/host-sets/host-set.js | 38 +++++++++----------
.../host-catalog/host-sets/new.js | 36 +++++++++---------
3 files changed, 48 insertions(+), 59 deletions(-)
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 9a594df91..9b2612f1a 100644
--- a/ui/admin/app/components/form/host-set/aws/index.hbs
+++ b/ui/admin/app/components/form/host-set/aws/index.hbs
@@ -6,7 +6,7 @@
@showEditToggle={{if @model.isNew false true}}
as |form|
>
-
+
- {{#each @model.filters as |filter i|}}
-
-
+ {{#each @model.filters as |filter i|}}
+
+
- FIELDD
-
+
{{t 'actions.remove'}}
-
-
- {{/each}}
+
+
+ {{/each}}
@@ -142,18 +137,12 @@
{{t 'actions.add'}}
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 173dbcc6d..ca0a83061 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
@@ -58,23 +58,23 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsHostSetRoute exte
* @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 `authMethod`. This is used to manage entries in fragment array
- * fields such as `signing_algorithms`.
- * @param {hostSetModel} authMethod
- * @param {string} property
- * @param {number} index
- */
- @action
- async removeItemByIndex(hostSet, property, index) {
- const array = hostSet.get(property);
- array.removeAt(index);
- }
+ @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 `authMethod`. This is used to manage entries in fragment array
+ * fields such as `signing_algorithms`.
+ * @param {hostSetModel} authMethod
+ * @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 527d80a71..d06e51619 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
@@ -70,22 +70,22 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsNewRoute extends
* @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 `authMethod`. This is used to manage entries in fragment array
- * fields such as `signing_algorithms`.
- * @param {hostSetModel} authMethod
- * @param {string} property
- * @param {number} index
- */
- @action
- async removeItemByIndex(hostSet, property, index) {
- const array = hostSet.get(property);
- array.removeAt(index);
- }
+ @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 `authMethod`. This is used to manage entries in fragment array
+ * fields such as `signing_algorithms`.
+ * @param {hostSetModel} authMethod
+ * @param {string} property
+ * @param {number} index
+ */
+ @action
+ async removeItemByIndex(hostSet, property, index) {
+ const array = hostSet.get(property);
+ array.removeAt(index);
+ }
}
From 5b245a3ce19c107416d33ec8b1da69f85937289b Mon Sep 17 00:00:00 2001
From: dharini
Date: Mon, 14 Feb 2022 10:37:58 -0800
Subject: [PATCH 06/14] lint
---
.../scopes/scope/host-catalogs/host-catalog/host-sets/index.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/index.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/index.js
index 74afc4b4f..1f49ad3af 100644
--- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/index.js
+++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/index.js
@@ -1,5 +1,4 @@
import Route from '@ember/routing/route';
-
export default class ScopesScopeHostCatalogsHostCatalogHostSetsIndexRoute extends Route {
// =methods
setupController(controller) {
From 83cf084ee683fcdf405cfe606ea195477928ba9d Mon Sep 17 00:00:00 2001
From: dharini
Date: Mon, 14 Feb 2022 12:34:05 -0800
Subject: [PATCH 07/14] =?UTF-8?q?fix:=20=F0=9F=90=9B=20fix=20address?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ui/admin/app/components/form/host/static/index.hbs | 2 +-
.../scopes/scope/host-catalogs/host-catalog/hosts/index.hbs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui/admin/app/components/form/host/static/index.hbs b/ui/admin/app/components/form/host/static/index.hbs
index 9b39cdb26..352cf1089 100644
--- a/ui/admin/app/components/form/host/static/index.hbs
+++ b/ui/admin/app/components/form/host/static/index.hbs
@@ -56,7 +56,7 @@
- {{host.attributes.address}}
+ {{host.address}}
{{/each}}
From ea5ab02d7008f07214338ae24ad95236c80717d2 Mon Sep 17 00:00:00 2001
From: Dharini Jeeva
Date: Mon, 14 Feb 2022 12:39:48 -0800
Subject: [PATCH 08/14] Update host-set.js
---
.../scope/host-catalogs/host-catalog/host-sets/host-set.js | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
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 ca0a83061..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
@@ -66,9 +66,8 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsHostSetRoute exte
/**
* Removes an item from array `property` at `index` on the
- * passed `authMethod`. This is used to manage entries in fragment array
- * fields such as `signing_algorithms`.
- * @param {hostSetModel} authMethod
+ * passed `hostSet`.
+ * @param {hostSetModel} hostSet
* @param {string} property
* @param {number} index
*/
From 21aef6a722224602514023db3a390cf61857ee3e Mon Sep 17 00:00:00 2001
From: Dharini Jeeva
Date: Mon, 14 Feb 2022 12:40:32 -0800
Subject: [PATCH 09/14] Update new.js
---
.../scopes/scope/host-catalogs/host-catalog/host-sets/new.js | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
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 d06e51619..7b2e64b72 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
@@ -77,9 +77,8 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsNewRoute extends
}
/**
* Removes an item from array `property` at `index` on the
- * passed `authMethod`. This is used to manage entries in fragment array
- * fields such as `signing_algorithms`.
- * @param {hostSetModel} authMethod
+ * passed `hostSet`.
+ * @param {hostSetModel} hostSet
* @param {string} property
* @param {number} index
*/
From 0b44a649b785f119423b4f59f3be34fd8c8637f3 Mon Sep 17 00:00:00 2001
From: dharini
Date: Mon, 14 Feb 2022 12:45:32 -0800
Subject: [PATCH 10/14] typo
---
ui/admin/app/components/form/host-set/aws/index.hbs | 1 -
1 file changed, 1 deletion(-)
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 9b2612f1a..17cd29947 100644
--- a/ui/admin/app/components/form/host-set/aws/index.hbs
+++ b/ui/admin/app/components/form/host-set/aws/index.hbs
@@ -130,7 +130,6 @@
From b15c8b056f7a1ab8a2a0fff57c34620013e64571 Mon Sep 17 00:00:00 2001
From: dharini
Date: Mon, 14 Feb 2022 12:55:07 -0800
Subject: [PATCH 11/14] =?UTF-8?q?fix:=20=F0=9F=90=9B=20error=20name?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ui/admin/app/components/form/host/static/index.hbs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/ui/admin/app/components/form/host/static/index.hbs b/ui/admin/app/components/form/host/static/index.hbs
index 352cf1089..d86c04f1c 100644
--- a/ui/admin/app/components/form/host/static/index.hbs
+++ b/ui/admin/app/components/form/host/static/index.hbs
@@ -58,14 +58,14 @@
@type='text'
@value={{@model.address}}
@label={{t 'form.address.label'}}
- @error={{@model.errors.name}}
+ @error={{@model.errors.address}}
@helperText={{t 'form.address.help'}}
readonly={{false}}
as |field|
>
- {{#if @model.errors.name}}
+ {{#if @model.errors.address}}
- {{#each @model.errors.name as |error|}}
+ {{#each @model.errors.address as |error|}}
{{error.message}}
{{/each}}
From 4438a6719ff511fa73f0a0d8de4ce3672f476a76 Mon Sep 17 00:00:00 2001
From: dharini
Date: Mon, 14 Feb 2022 13:55:34 -0800
Subject: [PATCH 12/14] =?UTF-8?q?fix:=20=F0=9F=90=9B=20lint?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ui/admin/app/components/form/host-set/aws/index.hbs | 5 +----
.../scopes/scope/host-catalogs/host-catalog/host-sets/new.js | 2 +-
2 files changed, 2 insertions(+), 5 deletions(-)
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 17cd29947..336972b1a 100644
--- a/ui/admin/app/components/form/host-set/aws/index.hbs
+++ b/ui/admin/app/components/form/host-set/aws/index.hbs
@@ -127,10 +127,7 @@
-
+
Date: Mon, 14 Feb 2022 18:06:12 -0500
Subject: [PATCH 13/14] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20consolidate=20?=
=?UTF-8?q?host=20catalog=20type=20badges=20to=20component?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
addons/api/addon/models/host-set.js | 13 ++++++-
addons/api/tests/unit/models/host-set-test.js | 10 +++--
.../host-catalog-type-badge/index.hbs | 15 ++++++++
.../host-catalog/host-sets/host-set/hosts.hbs | 2 +-
.../host-catalog/host-sets/index.hbs | 24 +-----------
.../scopes/scope/host-catalogs/index.hbs | 38 +------------------
.../scope/targets/target/host-sources.hbs | 4 +-
7 files changed, 38 insertions(+), 68 deletions(-)
create mode 100644 ui/admin/app/components/host-catalog-type-badge/index.hbs
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/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/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/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 9bcbe0fd4..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,7 +26,7 @@
{{host.description}}
- {{host.type}}
+
{{hostSet.description}}
- {{#if hostSet.isStatic}}
-
- {{t
- (concat
- 'resources.host-set.types.' hostSet.compositeType '.label'
- )
- }}
-
- {{else}}
-
- {{t
- (concat
- 'resources.host-set.types.' hostSet.compositeType '.label'
- )
- }}
-
- {{/if}}
+
{{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}}
- {{t
- (concat 'resources.host-set.types.' hostSet.model.type)
- }}
+
Date: Mon, 14 Feb 2022 15:37:12 -0800
Subject: [PATCH 14/14] =?UTF-8?q?chore:=20=F0=9F=A4=96=20use=20hostcatalog?=
=?UTF-8?q?badge=20component?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ui/admin/app/components/form/target/add-host-sets/index.hbs | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
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 ca5c7a3e4..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
@@ -34,9 +34,7 @@
{{hostSet.name}}
- {{t
- (concat 'resources.host-set.types.' hostSet.type)
- }}
+
{{hostSet.host_catalog_id}}