diff --git a/addons/api/mirage/factories/host-catalog.js b/addons/api/mirage/factories/host-catalog.js index 910e8bb3c..1cc61a56d 100644 --- a/addons/api/mirage/factories/host-catalog.js +++ b/addons/api/mirage/factories/host-catalog.js @@ -26,8 +26,6 @@ const pluginTypes = [ 'foobar', ]; -let pluginTypeCounter = 1; - export default factory.extend({ id: () => generateId('hc_'), @@ -64,7 +62,7 @@ export default factory.extend({ if (this.type === TYPE_HOST_CATALOG_DYNAMIC) { return { id: `plugin-id-${i}`, - name: pluginTypes[pluginTypeCounter++ % pluginTypes.length], + name: pluginTypes[i % pluginTypes.length], description: faker.word.words(), }; } diff --git a/addons/api/mirage/scenarios/default.js b/addons/api/mirage/scenarios/default.js index 007956e66..1e90829f7 100644 --- a/addons/api/mirage/scenarios/default.js +++ b/addons/api/mirage/scenarios/default.js @@ -110,7 +110,18 @@ export default function (server) { // Other resources server.schema.scopes.where({ type: 'project' }).models.forEach((scope) => { - server.createList('host-catalog', 8, { scope }, 'withChildren'); + server.createList( + 'host-catalog', + 2, + { scope, type: 'static' }, + 'withChildren', + ); + server.createList( + 'host-catalog', + 8, + { scope, type: 'plugin' }, + 'withChildren', + ); server.createList('credential-store', 3, { scope }, 'withAssociations'); server.createList('target', 2, { scope }, 'withAssociations'); server.create('target', { scope, address: '0.0.0.0' }); diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index c8663e6ec..deee3e030 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -241,7 +241,7 @@ host-catalog: label: Client/Application ID help: The client (application) ID of an Azure service principal that Boundary will use to authenticate and discover hosts from Azure. worker_filter: - help: Insert a worker filter in order to route requests to the correct worker. + help: Insert a worker filter in order to select the correct worker. project_id: label: Project ID help: Project ID of the instances you want to add to this GCP Host Catalog. diff --git a/ui/admin/app/components/form/host-catalog/aws/index.hbs b/ui/admin/app/components/form/host-catalog/aws/index.hbs index a897070ec..7debb291a 100644 --- a/ui/admin/app/components/form/host-catalog/aws/index.hbs +++ b/ui/admin/app/components/form/host-catalog/aws/index.hbs @@ -354,12 +354,15 @@ - {{t 'form.worker_filter.label'}} + {{t + 'form.worker_filter.label' + }} {{t 'resources.host-catalog.form.worker_filter.help'}} diff --git a/ui/admin/app/components/form/host-catalog/aws/index.js b/ui/admin/app/components/form/host-catalog/aws/index.js index e6c8bf5e6..e3c37db67 100644 --- a/ui/admin/app/components/form/host-catalog/aws/index.js +++ b/ui/admin/app/components/form/host-catalog/aws/index.js @@ -4,12 +4,17 @@ */ import Component from '@glimmer/component'; +import { service } from '@ember/service'; import { TYPES_CREDENTIALS, TYPE_CREDENTIAL_DYNAMIC, } from 'api/models/host-catalog'; export default class FormHostCatalogAwsComponent extends Component { + // =services + + @service featureEdition; + // =attributes /** @@ -27,4 +32,11 @@ export default class FormHostCatalogAwsComponent extends Component { get showDynamicCredentials() { return this.args.model.credentialType === TYPE_CREDENTIAL_DYNAMIC; } + + /** + * Returns true if current edition is HCP. + */ + get isWorkerFilterRequired() { + return this.featureEdition.edition === 'hcp'; + } } diff --git a/ui/admin/config/environment.js b/ui/admin/config/environment.js index 256371f15..8109948a9 100644 --- a/ui/admin/config/environment.js +++ b/ui/admin/config/environment.js @@ -144,7 +144,6 @@ module.exports = function (environment) { }, features: features, - featureFlags: {}, }; if (environment === 'development') { diff --git a/ui/admin/tests/acceptance/host-catalogs/create-test.js b/ui/admin/tests/acceptance/host-catalogs/create-test.js index 70c1c8365..39f416184 100644 --- a/ui/admin/tests/acceptance/host-catalogs/create-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/create-test.js @@ -19,6 +19,7 @@ module('Acceptance | host-catalogs | create', function (hooks) { setupIndexedDb(hooks); let featuresService; + let featureEdition; let getHostCatalogCount; const instances = { @@ -78,6 +79,7 @@ module('Acceptance | host-catalogs | create', function (hooks) { urls.newAzureDynamicHostCatalog = `${urls.newHostCatalog}?type=azure`; urls.newGCPDynamicHostCatalog = `${urls.newHostCatalog}?type=gcp`; featuresService = this.owner.lookup('service:features'); + featureEdition = this.owner.lookup('service:featureEdition'); // Generate resource counter getHostCatalogCount = () => @@ -262,11 +264,26 @@ module('Acceptance | host-catalogs | create', function (hooks) { assert.dom(selectors.FIELD_WORKER_FILTER).doesNotExist(); }); - test('users should see worker filter field in enterprise edition when AWS host catalog is selected', async function (assert) { + test('users should see optional worker filter field in enterprise edition when AWS host catalog is selected', async function (assert) { featuresService.enable('worker-filter'); + featureEdition.setEdition('enterprise'); await visit(urls.newAWSDynamicHostCatalog); assert.dom(selectors.FIELD_WORKER_FILTER).isVisible(); + assert + .dom(selectors.FIELD_AWS_WORKER_FILTER_LABEL) + .includesText('Optional'); + }); + + test('users should see required worker filter field in hcp edition when AWS host catalog is selected', async function (assert) { + featuresService.enable('worker-filter'); + featureEdition.setEdition('hcp'); + await visit(urls.newAWSDynamicHostCatalog); + + assert.dom(selectors.FIELD_WORKER_FILTER).isVisible(); + assert + .dom(selectors.FIELD_AWS_WORKER_FILTER_LABEL) + .includesText('Required'); }); test('users should see worker filter field in enterprise edition when GCP host catalog is selected', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/selectors.js b/ui/admin/tests/acceptance/host-catalogs/selectors.js index 377edd734..2efc37631 100644 --- a/ui/admin/tests/acceptance/host-catalogs/selectors.js +++ b/ui/admin/tests/acceptance/host-catalogs/selectors.js @@ -7,6 +7,8 @@ export const FIELD_TYPE = '[name="Type"]'; export const FIELD_TYPE_VALUE = (type) => `[value=${type}]`; export const FIELD_WORKER_FILTER = '[name=worker_filter]'; +export const FIELD_AWS_WORKER_FILTER_LABEL = + '[data-test-aws-worker-filter-label]'; export const FIELD_ZONE = '[name="zone"]'; export const FIELD_ZONE_VALUE = 'us-west-1';