From 6d358a565fc8b9a2cb12ca642585d8cdc9a07dd3 Mon Sep 17 00:00:00 2001 From: dharini Date: Tue, 15 Feb 2022 14:05:59 -0800 Subject: [PATCH 1/4] =?UTF-8?q?chore:=20=F0=9F=A4=96=20show=20ip=5Faddress?= =?UTF-8?q?es=20in=20host=20aws=20and=20azure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/admin/app/components/form/host/aws/index.hbs | 9 ++++++++- ui/admin/app/components/form/host/azure/index.hbs | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ui/admin/app/components/form/host/aws/index.hbs b/ui/admin/app/components/form/host/aws/index.hbs index 9fda57479..a8bd48401 100644 --- a/ui/admin/app/components/form/host/aws/index.hbs +++ b/ui/admin/app/components/form/host/aws/index.hbs @@ -71,7 +71,14 @@ - + {{#each @model.ip_addresses as |address|}} + + {{/each}} {{#if (can 'save model' @model)}} - + {{#each @model.ip_addresses as |address|}} + + {{/each}} {{#if (can 'save model' @model)}} Date: Tue, 15 Feb 2022 14:48:08 -0800 Subject: [PATCH 2/4] update attr name --- ui/admin/app/components/form/host/aws/index.hbs | 4 ++-- ui/admin/app/components/form/host/azure/index.hbs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/admin/app/components/form/host/aws/index.hbs b/ui/admin/app/components/form/host/aws/index.hbs index a8bd48401..8e6a2cc08 100644 --- a/ui/admin/app/components/form/host/aws/index.hbs +++ b/ui/admin/app/components/form/host/aws/index.hbs @@ -71,9 +71,9 @@ - {{#each @model.ip_addresses as |address|}} + {{#each @model.ip_addresses as |ip_address|}} - {{#each @model.ip_addresses as |address|}} + {{#each @model.ip_addresses as |ip_address|}} Date: Tue, 15 Feb 2022 15:12:20 -0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fixt=20host=20mock=20?= =?UTF-8?q?data=20attributes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor ip_addresses, dns_names and external_id to not be nested under attributes: {} when generating mock data. --- addons/api/mirage/factories/host.js | 55 +++++++------------ addons/api/mirage/generated/factories/host.js | 5 +- 2 files changed, 25 insertions(+), 35 deletions(-) diff --git a/addons/api/mirage/factories/host.js b/addons/api/mirage/factories/host.js index 93323e965..3bf07f11a 100644 --- a/addons/api/mirage/factories/host.js +++ b/addons/api/mirage/factories/host.js @@ -2,32 +2,6 @@ import factory from '../generated/factories/host'; import permissions from '../helpers/permissions'; import { internet, datatype } from 'faker'; -/** - * Returns an array of strings with IP addresses. - * @returns {array} - */ -const returnIpAddressesArray = () => { - const addressesAmount = Math.floor(Math.random() * 6) + 1; - let result = []; - for (let i = 0; i < addressesAmount; ++i) { - result.push(internet.ip()); - } - return result; -}; - -/** - * Returns an array of strings with DNS names. - * @param {string} hostType - */ -const returnDnsNames = () => { - const dnsNamesAmount = Math.floor(Math.random() * 6) + 1; - let result = []; - for (let i = 0; i < dnsNamesAmount; i++) { - result.push(internet.domainName()); - } - return result; -}; - export default factory.extend({ id: (i) => `host-id-${i}`, type() { @@ -45,13 +19,26 @@ export default factory.extend({ return this.hostCatalog.plugin; } }, - attributes() { - return { - address: internet.ipv6(), - ip_addresses: returnIpAddressesArray(), - external_id: datatype.uuid(), - // Only aws plugins have dns_names - dns_names: this.plugin?.name === 'aws' ? returnDnsNames() : undefined, - }; + ip_addresses() { + const addressesAmount = Math.floor(Math.random() * 6) + 1; + let result = []; + for (let i = 0; i < addressesAmount; ++i) { + result.push(internet.ip()); + } + return result; + }, + external_id() { + return datatype.uuid(); + }, + // Only aws plugins have dns_names + dns_names() { + if (this.plugin?.name === 'aws') { + const dnsNamesAmount = Math.floor(Math.random() * 6) + 1; + let result = []; + for (let i = 0; i < dnsNamesAmount; i++) { + result.push(internet.domainName()); + } + return result; + } }, }); diff --git a/addons/api/mirage/generated/factories/host.js b/addons/api/mirage/generated/factories/host.js index 658c334bf..6b26bab0b 100644 --- a/addons/api/mirage/generated/factories/host.js +++ b/addons/api/mirage/generated/factories/host.js @@ -1,5 +1,5 @@ import { Factory } from 'ember-cli-mirage'; -import { random, date, datatype } from 'faker'; +import { random, date, datatype, internet } from 'faker'; /** * GeneratedHostModelFactory @@ -11,4 +11,7 @@ export default Factory.extend({ created_time: () => date.recent(), updated_time: () => date.recent(), version: () => datatype.number(), + attributes: () => { + return { address: internet.ipv6() }; + }, }); From 5f1df8a0a0a431769807f13375303d7d66e78ae1 Mon Sep 17 00:00:00 2001 From: dharini Date: Tue, 15 Feb 2022 16:12:05 -0800 Subject: [PATCH 4/4] =?UTF-8?q?chore:=20=F0=9F=A4=96=20show=20latest=20ip?= =?UTF-8?q?=20addresses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/core/translations/en-us.yaml | 1 + .../app/components/form/host/aws/index.hbs | 17 +++++++++----- .../app/components/form/host/azure/index.hbs | 23 ++++++++++++------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/addons/core/translations/en-us.yaml b/addons/core/translations/en-us.yaml index 73a720d62..12232d8a6 100644 --- a/addons/core/translations/en-us.yaml +++ b/addons/core/translations/en-us.yaml @@ -30,6 +30,7 @@ titles: label: Label value: Value no-results: No Results + ip-addresses: Latest IP Addresses descriptions: empty-set: There are no items to display yet. You may be able to add items or try back later. origin-initialization: To get started, please enter your origin URL diff --git a/ui/admin/app/components/form/host/aws/index.hbs b/ui/admin/app/components/form/host/aws/index.hbs index 8e6a2cc08..1ceea8ff7 100644 --- a/ui/admin/app/components/form/host/aws/index.hbs +++ b/ui/admin/app/components/form/host/aws/index.hbs @@ -71,13 +71,18 @@ + {{#each @model.ip_addresses as |ip_address|}} - + + <:title>{{t 'titles.ip-addresses'}} + <:body> + + + {{/each}} {{#if (can 'save model' @model)}} - {{#each @model.ip_addresses as |ip_address|}} - - {{/each}} + + + <:title>{{t 'titles.ip-addresses'}} + <:body> + {{#each @model.ip_addresses as |ip_address|}} + + + {{/each}} + + + {{#if (can 'save model' @model)}}