fix: 🐛 minor UI changes, ent flag for worker filter (#2517)

This commit is contained in:
Dharini Jeeva authored and GitHub committed 2024-10-10 12:44:12 -07:00
1 parent 857bf01596
commit 0ff91f9182
6 files changed
+97 -44

No files matched your search

@@ -145,7 +145,12 @@
</Hds::Form::TextInput::Field>
{{#if @model.isNew}}
<Hds::Form::Radio::Group @layout='vertical' @name='credential_type' as |G|>
<Hds::Form::Radio::Group
class='dynamic-credential-selection'
@layout='vertical'
@name='credential_type'
as |G|
>
<G.Legend>
{{t 'resources.host-catalog.types.credential.label'}}
</G.Legend>
@@ -217,7 +222,7 @@
{{t 'resources.storage-bucket.form.role_arn.label'}}
</F.Label>
<F.HelperText>
{{t 'resources.storage-bucket.form.role_arn.help'}}
{{t 'resources.host-catalog.help.role_arn'}}
</F.HelperText>
{{#if @model.errors.role_arn}}
<F.Error as |E|>
@@ -364,46 +369,64 @@
</Hds::Form::TextInput::Field>
{{/if}}
<Hds::Form::Textarea::Field
name='worker_filter'
@value={{@model.worker_filter}}
@isOptional={{true}}
@isInvalid={{@model.errors.worker_filter}}
disabled={{form.disabled}}
as |F|
>
<F.Label>
{{t 'resources.host-catalog.form.worker_filter.label'}}
</F.Label>
<F.HelperText>
{{t 'resources.host-catalog.form.worker_filter.help'}}
<Hds::Link::Inline @href={{doc-url 'worker.create-tags'}}>
{{t 'actions.learn-more'}}
</Hds::Link::Inline>
</F.HelperText>
{{#if @model.errors.worker_filter}}
<F.Error as |E|>
{{#each @model.errors.worker_filter as |error|}}
<E.Message>
{{error.message}}
</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::Textarea::Field>
<Hds::Form::Checkbox::Field
name='disable_credential_rotation'
checked={{@model.disable_credential_rotation}}
disabled={{form.disabled}}
{{on 'change' (fn this.toggleDisableCredentialRotation @model)}}
as |F|
>
<F.Label>
{{t 'form.disable_credential_rotation.label'}}
</F.Label>
</Hds::Form::Checkbox::Field>
{{#if (feature-flag 'dynamic-credentials-worker-filter')}}
<Hds::Form::Textarea::Field
data-test-dynamic-credential-worker-filter
name='worker_filter'
@value={{@model.worker_filter}}
@isOptional={{true}}
@isInvalid={{@model.errors.worker_filter}}
disabled={{form.disabled}}
as |F|
>
<F.Label>
{{t 'resources.host-catalog.form.worker_filter.label'}}
</F.Label>
<F.HelperText>
{{t 'resources.host-catalog.form.worker_filter.help'}}
<Hds::Link::Inline @href={{doc-url 'worker.create-tags'}}>
{{t 'actions.learn-more'}}
</Hds::Link::Inline>
</F.HelperText>
{{#if @model.errors.worker_filter}}
<F.Error as |E|>
{{#each @model.errors.worker_filter as |error|}}
<E.Message>
{{error.message}}
</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::Textarea::Field>
{{/if}}
{{#if this.showDynamicCredentials}}
<Hds::Form::Checkbox::Field
name='disable_credential_rotation'
checked={{true}}
disabled={{true}}
as |F|
>
<F.Label>
{{t 'form.disable_credential_rotation.label'}}
</F.Label>
<F.HelperText>
{{t 'resources.host-catalog.help.disable_credential_rotation'}}
</F.HelperText>
</Hds::Form::Checkbox::Field>
{{else}}
<Hds::Form::Checkbox::Field
name='disable_credential_rotation'
checked={{@model.disable_credential_rotation}}
disabled={{form.disabled}}
{{on 'change' (fn this.toggleDisableCredentialRotation @model)}}
as |F|
>
<F.Label>
{{t 'form.disable_credential_rotation.label'}}
</F.Label>
</Hds::Form::Checkbox::Field>
{{/if}}
&nbsp;
{{#if (can 'save model' @model)}}
+6
View File
@@ -1073,3 +1073,9 @@
gap: 1.5rem;
}
}
.dynamic-credential-selection {
.hds-form-group__control-field {
margin-bottom: 0;
}
}
+2
View File
@@ -28,6 +28,7 @@ const baseEdition = {
'target-network-address': false,
'vault-worker-filter': false,
'ldap-auth-methods': false,
'dynamic-credentials-worker-filter': false,
};
// Editions maps edition keys to their associated featuresets.
const featureEditions = {};
@@ -43,6 +44,7 @@ featureEditions.enterprise = {
...featureEditions.oss,
'target-worker-filters-v2-ingress': true,
'vault-worker-filter': true,
'dynamic-credentials-worker-filter': true,
};
featureEditions.hcp = {
...featureEditions.enterprise,
@@ -21,6 +21,7 @@ module('Acceptance | host-catalogs | create', function (hooks) {
setupMirage(hooks);
setupIndexedDb(hooks);
let featuresService;
let getHostCatalogCount;
const NAME_INPUT_SELECTOR = '[name="name"]';
@@ -84,6 +85,8 @@ module('Acceptance | host-catalogs | create', function (hooks) {
urls.newStaticHostCatalog = `${urls.newHostCatalog}?type=static`;
urls.newAWSDynamicHostCatalog = `${urls.newHostCatalog}?type=aws`;
urls.newAzureDynamicHostCatalog = `${urls.newHostCatalog}?type=azure`;
featuresService = this.owner.lookup('service:features');
// Generate resource counter
getHostCatalogCount = () =>
this.server.schema.hostCatalogs.all().models.length;
@@ -196,6 +199,17 @@ module('Acceptance | host-catalogs | create', function (hooks) {
assert.dom('[data-test-error-message-name]').hasText('Name is required.');
});
test('users should not see worker filter field in community edition', async function (assert) {
await visit(urls.newAWSDynamicHostCatalog);
assert.dom('[data-test-dynamic-credential-worker-filter]').doesNotExist();
});
test('users should see worker filter field in enterprise edition', async function (assert) {
featuresService.enable('dynamic-credentials-worker-filter');
await visit(urls.newAWSDynamicHostCatalog);
assert.dom('[data-test-dynamic-credential-worker-filter]').exists();
});
test('users cannot directly navigate to new host catalog route without proper authorization', async function (assert) {
instances.scopes.project.authorized_collection_actions['host-catalogs'] =
instances.scopes.project.authorized_collection_actions[