From 7d3727dc343187ed72685a801b11a1be2018e9f5 Mon Sep 17 00:00:00 2001 From: Dharini Jeeva Date: Tue, 13 Dec 2022 17:45:26 -0800 Subject: [PATCH] Radio card migration - hostcatalog hosts host sets (#1503) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: 🤖 radio card migration --- addons/api/addon/models/host-catalog.js | 5 +- addons/api/addon/models/host-set.js | 4 +- addons/core/translations/en-us.yaml | 1 - addons/core/translations/form/en-us.yaml | 3 +- addons/core/translations/resources/en-us.yaml | 4 +- .../form/credential/ssh_private_key/index.hbs | 2 +- .../credential/username_password/index.hbs | 2 +- .../form/host-catalog/aws/index.hbs | 91 +++++++--------- .../components/form/host-catalog/aws/index.js | 16 +++ .../form/host-catalog/azure/index.hbs | 102 ++++++++---------- .../form/host-catalog/azure/index.js | 20 ++++ .../form/host-catalog/static/index.hbs | 89 +++++++-------- .../form/host-catalog/static/index.js | 20 ++++ .../components/form/host-set/aws/index.hbs | 31 ++---- .../components/form/host-set/azure/index.hbs | 31 ++---- .../app/components/form/host/aws/index.hbs | 29 ++--- .../app/components/form/host/azure/index.hbs | 30 ++---- .../form/onboarding/choose-path/index.hbs | 49 +++++---- .../components/form/target/details/index.hbs | 2 +- .../acceptance/host-catalogs/create-test.js | 39 +++++-- .../host-catalogs/host-sets/create-test.js | 6 +- .../host-catalogs/host-sets/update-test.js | 12 +-- .../acceptance/onboarding/choose-path-test.js | 8 +- .../scope/projects/targets/target/hosts.hbs | 2 +- 24 files changed, 308 insertions(+), 290 deletions(-) create mode 100644 ui/admin/app/components/form/host-catalog/azure/index.js create mode 100644 ui/admin/app/components/form/host-catalog/static/index.js diff --git a/addons/api/addon/models/host-catalog.js b/addons/api/addon/models/host-catalog.js index 08e1a7d82..e4b78e95c 100644 --- a/addons/api/addon/models/host-catalog.js +++ b/addons/api/addon/models/host-catalog.js @@ -1,6 +1,7 @@ import GeneratedHostCatalogModel from '../generated/models/host-catalog'; -export const types = ['aws', 'azure']; +export const types = ['static', 'plugin']; +export const pluginTypes = ['aws', 'azure']; export default class HostCatalogModel extends GeneratedHostCatalogModel { // =attributes @@ -26,7 +27,7 @@ export default class HostCatalogModel extends GeneratedHostCatalogModel { * @type {boolean} */ get isUnknown() { - return this.isPlugin && !types.includes(this.plugin?.name); + return this.isPlugin && !pluginTypes.includes(this.plugin?.name); } /** diff --git a/addons/api/addon/models/host-set.js b/addons/api/addon/models/host-set.js index ed1c0127f..77c3c6c7b 100644 --- a/addons/api/addon/models/host-set.js +++ b/addons/api/addon/models/host-set.js @@ -1,5 +1,5 @@ import GeneratedHostSetModel from '../generated/models/host-set'; -import { types } from './host-catalog'; +import { pluginTypes } from './host-catalog'; export default class HostSetModel extends GeneratedHostSetModel { // =attributes @@ -25,7 +25,7 @@ export default class HostSetModel extends GeneratedHostSetModel { * @type {boolean} */ get isUnknown() { - return this.isPlugin && !types.includes(this.plugin?.name); + return this.isPlugin && !pluginTypes.includes(this.plugin?.name); } /** diff --git a/addons/core/translations/en-us.yaml b/addons/core/translations/en-us.yaml index efa8a811c..35787d6d8 100644 --- a/addons/core/translations/en-us.yaml +++ b/addons/core/translations/en-us.yaml @@ -41,7 +41,6 @@ descriptions: neither-list-nor-create: You do not have permission to list or create {resource}. no-results: We found no matching records. choose-a-provider: There are several built-in plugins for the most common providers. You can choose from one of the included plugins or use a custom plugin. - choose-a-provider-azure: Boundary does not yet support rotating credentials. provider: This is the provider for this host catalog. The format of the host set filters are specific to each provider. questions: delete-confirm: Are you sure you want to delete this resource? diff --git a/addons/core/translations/form/en-us.yaml b/addons/core/translations/form/en-us.yaml index 8a2286444..682bd73f8 100644 --- a/addons/core/translations/form/en-us.yaml +++ b/addons/core/translations/form/en-us.yaml @@ -150,6 +150,7 @@ secret: help: The client secret value generated by Azure for Boundary to use for authentication. disable_credential_rotation: label: Disable credential rotation + help: Azure host catalogs do not yet support credential rotation. dns_names: label: Latest DNS Names host: @@ -163,4 +164,4 @@ tags: label: Tags secret-editor: details: This secret is saved but won't be displayed - edit: Click to replace this secret \ No newline at end of file + edit: Click to replace this secret diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index b2bfb2a95..46f93a131 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -93,13 +93,13 @@ host-catalog: delete: Delete Host Catalog help: static: Provide a list of hosts and host sets with static addresses - dynamic: Automate discovery of target hosts and services on Azure or AWS + plugin: Automate discovery of target hosts and services on Azure or AWS types: static: Static unknown: Plugin aws: AWS azure: Azure - dynamic: Dynamic + plugin: Dynamic form: aws_region: label: AWS Region diff --git a/ui/admin/app/components/form/credential/ssh_private_key/index.hbs b/ui/admin/app/components/form/credential/ssh_private_key/index.hbs index f59cd5f9e..bcee4bed2 100644 --- a/ui/admin/app/components/form/credential/ssh_private_key/index.hbs +++ b/ui/admin/app/components/form/credential/ssh_private_key/index.hbs @@ -40,7 +40,7 @@ {{/if}} {{#if @model.isNew}} - + {{t 'form.type.label'}} {{#each @types as |credentialType|}} {{#if @model.isNew}} - + {{t 'form.type.label'}} {{#each @types as |credentialType|}} {{#if @model.isNew}} - - <:title>{{t 'form.type.label'}} - <:body> - + {{t 'form.type.label'}} + {{#each this.hostCatalogTypes as |hostCatalogType|}} + - - - - - + {{t + (concat 'resources.host-catalog.types.' hostCatalogType) + }} + {{t + (concat 'resources.host-catalog.help.' hostCatalogType) + }} + + {{/each}} + + + {{t 'titles.provider'}} + {{t 'titles.choose-a-provider'}} + {{t 'descriptions.choose-a-provider'}} - - - <:title>{{t 'titles.provider'}} - - - - <:title>{{t 'titles.choose-a-provider'}} - <:description>{{t 'descriptions.choose-a-provider'}} - - <:body> - - - - - - + {{t + (concat 'resources.host-catalog.types.' pluginType) + }} + + + + {{/each-in}} + {{else}} ({ ...obj, [plugin]: icons[i] }), + {} + ); + } // =actions @action diff --git a/ui/admin/app/components/form/host-catalog/azure/index.hbs b/ui/admin/app/components/form/host-catalog/azure/index.hbs index a09a3d411..807b18f84 100644 --- a/ui/admin/app/components/form/host-catalog/azure/index.hbs +++ b/ui/admin/app/components/form/host-catalog/azure/index.hbs @@ -44,67 +44,47 @@ {{#if @model.isNew}} - - <:title>{{t 'form.type.label'}} - <:body> - + {{t 'form.type.label'}} + {{#each this.hostCatalogTypes as |hostCatalogType|}} + - - - - - - - - - <:title>{{t 'titles.provider'}} - - - <:title>{{t 'titles.choose-a-provider'}} - <:description> - {{concat + {{t + (concat 'resources.host-catalog.types.' hostCatalogType) + }} + {{t + (concat 'resources.host-catalog.help.' hostCatalogType) + }} + + {{/each}} + + + {{t 'titles.provider'}} + {{t 'titles.choose-a-provider'}} + {{concat (t 'descriptions.choose-a-provider') - ' ' - (t 'descriptions.choose-a-provider-azure') - }} - + }} - <:body> - - - - - - + {{t + (concat 'resources.host-catalog.types.' pluginType) + }} + + + {{/each-in}} + {{else}} + + {{#if (can 'save model' @model)}} ({ ...obj, [plugin]: icons[i] }), + {} + ); + } +} diff --git a/ui/admin/app/components/form/host-catalog/static/index.hbs b/ui/admin/app/components/form/host-catalog/static/index.hbs index 2654c6608..3c2245981 100644 --- a/ui/admin/app/components/form/host-catalog/static/index.hbs +++ b/ui/admin/app/components/form/host-catalog/static/index.hbs @@ -46,60 +46,51 @@ {{#if @model.isNew}} - - <:title>{{t 'form.type.label'}} - <:body> - + {{t 'form.type.label'}} + {{#each this.hostCatalogTypes as |hostCatalogType|}} + - - - - - + {{t + (concat 'resources.host-catalog.types.' hostCatalogType) + }} + {{t + (concat 'resources.host-catalog.help.' hostCatalogType) + }} + + {{/each}} + {{#if @model.isPlugin}} - - - <:title>{{t 'titles.provider'}} - - - <:title>{{t 'titles.choose-a-provider'}} - <:description>{{t 'descriptions.choose-a-provider'}} - <:body> - + {{t 'titles.provider'}} + {{t 'titles.choose-a-provider'}} + {{t 'descriptions.choose-a-provider'}} + + {{#each-in this.mapResourceTypeWithIcon as |pluginType|}} + - - - - - + {{t + (concat 'resources.host-catalog.types.' pluginType) + }} + {{t + (concat 'resources.host-catalog.help.' pluginType) + }} + + {{/each-in}} + {{/if}} {{/if}} diff --git a/ui/admin/app/components/form/host-catalog/static/index.js b/ui/admin/app/components/form/host-catalog/static/index.js new file mode 100644 index 000000000..c8f2e50f2 --- /dev/null +++ b/ui/admin/app/components/form/host-catalog/static/index.js @@ -0,0 +1,20 @@ +import Component from '@glimmer/component'; +import { types, pluginTypes } from 'api/models/host-catalog'; + +//Note: this is a temporary solution till we have resource type helper in place +const icons = ['aws-color', 'azure-color']; + +export default class FormStaticHostCatalogAwsComponent extends Component { + // =properties + hostCatalogTypes = types; + /** + * maps resource type with icon + * @type {object} + */ + get mapResourceTypeWithIcon() { + return pluginTypes.reduce( + (obj, plugin, i) => ({ ...obj, [plugin]: icons[i] }), + {} + ); + } +} 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 cc131cd79..0f430dabb 100644 --- a/ui/admin/app/components/form/host-set/aws/index.hbs +++ b/ui/admin/app/components/form/host-set/aws/index.hbs @@ -53,26 +53,17 @@ @disabled={{true}} /> - - <:title>{{t 'titles.provider'}} - <:description>{{t 'descriptions.provider'}} - - <:body> - - - - - + + {{t 'titles.provider'}} + + {{t 'resources.host-catalog.types.aws'}} + + - - <:title>{{t 'titles.provider'}} - <:description>{{t 'descriptions.provider'}} - - <:body> - - - - - + + {{t 'titles.provider'}} + + {{t 'resources.host-catalog.types.azure'}} + + - - <:title>{{t 'titles.provider'}} - <:body> - - - - - + + {{t 'titles.provider'}} + + {{t 'resources.host-catalog.types.aws'}} + + <:title>{{t 'form.ip_addresses.label'}} diff --git a/ui/admin/app/components/form/host/azure/index.hbs b/ui/admin/app/components/form/host/azure/index.hbs index c87c94843..348fe2788 100644 --- a/ui/admin/app/components/form/host/azure/index.hbs +++ b/ui/admin/app/components/form/host/azure/index.hbs @@ -52,25 +52,17 @@ {{/if}} - - <:title>{{t 'titles.provider'}} - <:body> - - - - - - + + {{t 'titles.provider'}} + + {{t 'resources.host-catalog.types.azure'}} + + <:title>{{t 'form.ip_addresses.label'}} <:body> diff --git a/ui/admin/app/components/form/onboarding/choose-path/index.hbs b/ui/admin/app/components/form/onboarding/choose-path/index.hbs index 9e91d69e9..1c4a59b96 100644 --- a/ui/admin/app/components/form/onboarding/choose-path/index.hbs +++ b/ui/admin/app/components/form/onboarding/choose-path/index.hbs @@ -5,26 +5,33 @@ @onSubmit={{fn @submit this.path}} as |form| > - -
- - -
-
+ + + + {{t 'onboarding.quick-start.titles.quick-setup'}} + {{t + 'onboarding.quick-start.descriptions.quick-setup' + }} + + + {{t 'onboarding.quick-start.titles.manual'}} + {{t + 'onboarding.quick-start.descriptions.manual' + }} + + + \ No newline at end of file diff --git a/ui/admin/app/components/form/target/details/index.hbs b/ui/admin/app/components/form/target/details/index.hbs index fb6c93641..9bdb90a2b 100644 --- a/ui/admin/app/components/form/target/details/index.hbs +++ b/ui/admin/app/components/form/target/details/index.hbs @@ -42,7 +42,7 @@ {{#if (and @model.isNew (feature-flag 'ssh-target'))}} - + {{t 'form.type.label'}} {{#each-in this.mapResourceTypeWithIcon as |targetType icon|}} this.server.schema.hostCatalogs.all().models.length; @@ -81,18 +83,29 @@ module('Acceptance | host-catalogs | create', function (hooks) { await visit(urls.newStaticHostCatalog); await fillIn('[name="name"]', 'random string'); await fillIn('[name="description"]', 'random string'); - await fillIn('[name="types"]', 'static'); + await fillIn('[name="type"]', 'static'); await click('[type="submit"]'); assert.strictEqual(gethostCatalogCount(), count + 1); }); - test('Users can create new dynamic host catalogs', async function (assert) { + test('Users can create new dynamic aws host catalogs with aws provider', async function (assert) { assert.expect(1); const count = gethostCatalogCount(); - await visit(urls.newDynamicHostCatalog); + await visit(urls.newAWSDynamicHostCatalog); await fillIn('[name="name"]', 'random string'); await fillIn('[name="description"]', 'random string'); - await fillIn('[name="types"]', 'aws'); + await fillIn('[name="type"]', 'aws'); + await click('[type="submit"]'); + assert.strictEqual(gethostCatalogCount(), count + 1); + }); + + test('Users can create new dynamic aws host catalogs with azure provider', async function (assert) { + assert.expect(1); + const count = gethostCatalogCount(); + await visit(urls.newAzureDynamicHostCatalog); + await fillIn('[name="name"]', 'random string'); + await fillIn('[name="description"]', 'random string'); + await fillIn('[name="type"]', 'azure'); await click('[type="submit"]'); assert.strictEqual(gethostCatalogCount(), count + 1); }); @@ -107,10 +120,20 @@ module('Acceptance | host-catalogs | create', function (hooks) { assert.strictEqual(gethostCatalogCount(), count); }); - test('Users can cancel creation of new dynamic host catalogs', async function (assert) { + test('Users can cancel creation of new dynamic host catalogs with AWS provider', async function (assert) { assert.expect(2); const count = gethostCatalogCount(); - await visit(urls.newDynamicHostCatalog); + await visit(urls.newAWSDynamicHostCatalog); + await fillIn('[name="name"]', 'random string'); + await click('.rose-form-actions [type="button"]'); + assert.strictEqual(currentURL(), urls.hostCatalogs); + assert.strictEqual(gethostCatalogCount(), count); + }); + + test('Users can cancel creation of new dynamic host catalogs with Azure provider', async function (assert) { + assert.expect(2); + const count = gethostCatalogCount(); + await visit(urls.newAzureDynamicHostCatalog); await fillIn('[name="name"]', 'random string'); await click('.rose-form-actions [type="button"]'); assert.strictEqual(currentURL(), urls.hostCatalogs); diff --git a/ui/admin/tests/acceptance/host-catalogs/host-sets/create-test.js b/ui/admin/tests/acceptance/host-catalogs/host-sets/create-test.js index 6aa8fe830..cc0c8891e 100644 --- a/ui/admin/tests/acceptance/host-catalogs/host-sets/create-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/host-sets/create-test.js @@ -97,9 +97,9 @@ module('Acceptance | host-catalogs | host sets | create', function (hooks) { const name = 'aws host set'; await fillIn('[name="name"]', name); await fillIn('[name="preferred_endpoints"]', 'endpoint'); - await click('form fieldset:nth-of-type(2) [title="Add"]'); + await click('form fieldset:nth-of-type(1) [title="Add"]'); await fillIn('[name="filters"]', 'filter'); - await click('form fieldset:nth-of-type(3) [title="Add"]'); + await click('form fieldset:nth-of-type(2) [title="Add"]'); await fillIn('[name="sync_interval_seconds"]', 10); await click('[type="submit"]'); @@ -128,7 +128,7 @@ module('Acceptance | host-catalogs | host sets | create', function (hooks) { const name = 'azure host set'; await fillIn('[name="name"]', name); await fillIn('[name="preferred_endpoints"]', 'endpoint'); - await click('form fieldset:nth-of-type(2) [title="Add"]'); + await click('form fieldset:nth-of-type(1) [title="Add"]'); await fillIn('[name="filter"]', 'filter'); await fillIn('[name="sync_interval_seconds"]', 10); await click('[type="submit"]'); diff --git a/ui/admin/tests/acceptance/host-catalogs/host-sets/update-test.js b/ui/admin/tests/acceptance/host-catalogs/host-sets/update-test.js index 46864ff1c..669ae7425 100644 --- a/ui/admin/tests/acceptance/host-catalogs/host-sets/update-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/host-sets/update-test.js @@ -147,20 +147,20 @@ module('Acceptance | host-catalogs | host sets | update', function (hooks) { await fillIn('[name="name"]', name); // Remove all the preferred endpoints await Promise.all( - findAll('form fieldset:nth-of-type(2) [title="Remove"]').map((element) => + findAll('form fieldset:nth-of-type(1) [title="Remove"]').map((element) => click(element) ) ); await fillIn('[name="preferred_endpoints"]', 'endpoint'); - await click('form fieldset:nth-of-type(2) [title="Add"]'); + await click('form fieldset:nth-of-type(1) [title="Add"]'); // Remove all the filters await Promise.all( - findAll('form fieldset:nth-of-type(3) [title="Remove"]').map((element) => + findAll('form fieldset:nth-of-type(2) [title="Remove"]').map((element) => click(element) ) ); await fillIn('[name="filters"]', 'filter'); - await click('form fieldset:nth-of-type(3) [title="Add"]'); + await click('form fieldset:nth-of-type(2) [title="Add"]'); await fillIn('[name="sync_interval_seconds"]', 10); await click('.rose-form-actions [type="submit"]'); @@ -198,12 +198,12 @@ module('Acceptance | host-catalogs | host sets | update', function (hooks) { await fillIn('[name="name"]', name); // Remove all the preferred endpoints await Promise.all( - findAll('form fieldset:nth-of-type(2) [title="Remove"]').map((element) => + findAll('form fieldset:nth-of-type(1) [title="Remove"]').map((element) => click(element) ) ); await fillIn('[name="preferred_endpoints"]', 'endpoint'); - await click('form fieldset:nth-of-type(2) [title="Add"]'); + await click('form fieldset:nth-of-type(1) [title="Add"]'); await fillIn('[name="filter"]', 'filter'); await fillIn('[name="sync_interval_seconds"]', 10); await click('.rose-form-actions [type="submit"]'); diff --git a/ui/admin/tests/acceptance/onboarding/choose-path-test.js b/ui/admin/tests/acceptance/onboarding/choose-path-test.js index 7c4226850..836892631 100644 --- a/ui/admin/tests/acceptance/onboarding/choose-path-test.js +++ b/ui/admin/tests/acceptance/onboarding/choose-path-test.js @@ -21,15 +21,15 @@ module('Acceptance | onboarding | choose-path', function (hooks) { test('defaults to the guided path', async function (assert) { assert.expect(2); await visit(urls.choosePath); - assert.strictEqual(find('input[name=paths]:checked').value, 'guided'); + assert.strictEqual(find('input[name=path]:checked').value, 'guided'); assert.false(find('input[value=manual]').checked); }); test('updates to the manual path when manual card clicked', async function (assert) { assert.expect(2); await visit(urls.choosePath); - await click('[name="paths"][value="manual"]'); - assert.strictEqual(find('input[name=paths]:checked').value, 'manual'); + await click('[name="path"][value="manual"]'); + assert.strictEqual(find('input[name=path]:checked').value, 'manual'); assert.false(find('input[value=guided]').checked); }); @@ -43,7 +43,7 @@ module('Acceptance | onboarding | choose-path', function (hooks) { test('guided path directs user to /global/new route', async function (assert) { assert.expect(1); await visit(urls.choosePath); - await click('[name="paths"][value="manual"]'); + await click('[name="path"][value="manual"]'); await click('[type="submit"]'); assert.strictEqual(currentURL(), urls.newOrg); }); diff --git a/ui/desktop/app/templates/scopes/scope/projects/targets/target/hosts.hbs b/ui/desktop/app/templates/scopes/scope/projects/targets/target/hosts.hbs index 56ee4d216..33d9fe558 100644 --- a/ui/desktop/app/templates/scopes/scope/projects/targets/target/hosts.hbs +++ b/ui/desktop/app/templates/scopes/scope/projects/targets/target/hosts.hbs @@ -30,7 +30,7 @@ {{#if host.isStatic}} {{host.address}} {{else}} - + {{/if}}