From 361bdf02a4869f82f0eb0817df5d37e0f4ba7f55 Mon Sep 17 00:00:00 2001 From: dharini Date: Sun, 13 Feb 2022 22:42:34 -0800 Subject: [PATCH 01/10] 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/10] =?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/10] =?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/10] =?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/10] =?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/10] 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 ea5ab02d7008f07214338ae24ad95236c80717d2 Mon Sep 17 00:00:00 2001 From: Dharini Jeeva Date: Mon, 14 Feb 2022 12:39:48 -0800 Subject: [PATCH 07/10] 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 08/10] 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 09/10] 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 4438a6719ff511fa73f0a0d8de4ce3672f476a76 Mon Sep 17 00:00:00 2001 From: dharini Date: Mon, 14 Feb 2022 13:55:34 -0800 Subject: [PATCH 10/10] =?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 @@ - +