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() }; + }, }); diff --git a/addons/core/translations/en-us.yaml b/addons/core/translations/en-us.yaml index 6dc0f659b..afe5d18f2 100644 --- a/addons/core/translations/en-us.yaml +++ b/addons/core/translations/en-us.yaml @@ -32,6 +32,7 @@ titles: no-results: No Results choose-a-provider: Choose a provider provider: Provider + 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 af2499c28..1984dbe49 100644 --- a/ui/admin/app/components/form/host/aws/index.hbs +++ b/ui/admin/app/components/form/host/aws/index.hbs @@ -72,6 +72,18 @@ + {{#each @model.ip_addresses as |ip_address|}} + + <:title>{{t 'titles.ip-addresses'}} + <:body> + + + + {{/each}} {{#if (can 'save model' @model)}} + + <:title>{{t 'titles.ip-addresses'}} + <:body> + {{#each @model.ip_addresses as |ip_address|}} + + + {{/each}} + + + {{#if (can 'save model' @model)}}