chore: 🤖 gcp plugin creation in the UI (#2645)

gcp plugin creation and mirage changes
This commit is contained in:
Dharini Jeeva authored and Dharini committed 2025-01-10 14:18:48 -08:00
1 parent 520020f2c6
commit dfa62dd04b
11 files changed
+376 -28

No files matched your search

@@ -398,7 +398,7 @@
name='disable_credential_rotation'
checked={{@model.disable_credential_rotation}}
disabled={{form.disabled}}
{{on 'change' (fn this.toggleDisableCredentialRotation @model)}}
{{on 'change' (fn @toggleDisableCredentialRotation @model)}}
as |F|
>
<F.Label>
@@ -26,13 +26,6 @@ export default class FormHostCatalogAwsComponent extends Component {
return TYPES_CREDENTIALS;
}
// =actions
@action
toggleDisableCredentialRotation(model) {
model.disable_credential_rotation = !model.disable_credential_rotation;
}
/**
* Allows to update the credential type
* @param type {string}
@@ -0,0 +1,261 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}
<Rose::Form
@onSubmit={{@submit}}
@cancel={{@cancel}}
@disabled={{@model.isSaving}}
@showEditToggle={{if @model.isNew false true}}
as |form|
>
<Hds::Form::TextInput::Field
name='name'
@value={{@model.name}}
@isInvalid={{@model.errors.name}}
@isOptional={{true}}
readonly={{form.disabled}}
{{on 'input' (set-from-event @model 'name')}}
as |F|
>
<F.Label>{{t 'form.name.label'}}</F.Label>
<F.HelperText>{{t 'form.name.help'}}</F.HelperText>
{{#if @model.errors.name}}
<F.Error as |E|>
{{#each @model.errors.name as |error|}}
<E.Message>{{error.message}}</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::TextInput::Field>
<Hds::Form::Textarea::Field
name='description'
@value={{@model.description}}
@isInvalid={{@model.errors.description}}
@isOptional={{true}}
readonly={{form.disabled}}
as |F|
>
<F.Label>{{t 'form.description.label'}}</F.Label>
<F.HelperText>{{t 'form.description.help'}}</F.HelperText>
{{#if @model.errors.description}}
<F.Error as |E|>
{{#each @model.errors.description as |error|}}
<E.Message>{{error.message}}</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::Textarea::Field>
{{#if @model.isNew}}
<Hds::Form::RadioCard::Group @name={{t 'form.type.label'}} as |G|>
<G.Legend>{{t 'form.type.label'}}</G.Legend>
{{#each @hostCatalogTypes as |hostCatalogType|}}
<G.RadioCard
@value={{hostCatalogType}}
@maxWidth='20rem'
@checked={{eq hostCatalogType @model.type}}
{{on 'input' (fn @changeType hostCatalogType)}}
as |R|
>
<R.Label>{{t
(concat 'resources.host-catalog.types.' hostCatalogType)
}}</R.Label>
<R.Description>{{t
(concat 'resources.host-catalog.help.' hostCatalogType)
}}</R.Description>
</G.RadioCard>
{{/each}}
</Hds::Form::RadioCard::Group>
<Hds::Form::RadioCard::Group
@name={{t 'form.plugin_type.label'}}
@alignment='center'
as |G|
>
<G.Legend>{{t 'titles.provider'}}</G.Legend>
<G.Legend>{{t 'titles.choose-a-provider'}}</G.Legend>
<G.HelperText>{{concat
(t 'descriptions.choose-a-provider')
}}</G.HelperText>
{{#each-in @mapResourceTypeWithIcon as |pluginType icon|}}
<G.RadioCard
@value={{pluginType}}
@maxWidth='20rem'
@checked={{eq pluginType @model.compositeType}}
{{on 'input' (fn @changeType pluginType)}}
as |R|
>
<R.Label>{{t
(concat 'resources.host-catalog.types.' pluginType)
}}</R.Label>
<R.Icon @name={{icon}} />
</G.RadioCard>
{{/each-in}}
</Hds::Form::RadioCard::Group>
{{else}}
<InfoField
@value={{t 'resources.host-catalog.types.gcp'}}
@icon='gcp-color'
readonly={{true}}
as |F|
>
<F.Label>{{t 'titles.provider'}}</F.Label>
<F.HelperText>{{t 'descriptions.provider'}}
</F.HelperText>
</InfoField>
{{/if}}
<Hds::Form::TextInput::Field
name='project_id'
@value={{@model.project_id}}
@isInvalid={{@model.errors.project_id}}
@isRequired={{true}}
readonly={{form.disabled}}
{{on 'input' (set-from-event @model 'project_id')}}
as |F|
>
<F.Label>{{t 'resources.host-catalog.form.project_id.label'}}</F.Label>
<F.HelperText>{{t
'resources.host-catalog.form.project_id.help'
}}</F.HelperText>
{{#if @model.errors.project_id}}
<F.Error as |E|>
{{#each @model.errors.project_id as |error|}}
<E.Message>{{error.message}}</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::TextInput::Field>
<Hds::Form::TextInput::Field
name='zone'
@value={{@model.zone}}
@isInvalid={{@model.errors.zone}}
@isRequired={{true}}
readonly={{form.disabled}}
{{on 'input' (set-from-event @model 'zone')}}
as |F|
>
<F.Label>{{t 'resources.host-catalog.form.zone.label'}}</F.Label>
<F.HelperText>{{t 'resources.host-catalog.form.zone.help'}}</F.HelperText>
{{#if @model.errors.zone}}
<F.Error as |E|>
{{#each @model.errors.zone as |error|}}
<E.Message>{{error.message}}</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::TextInput::Field>
<Hds::Form::TextInput::Field
name='client_email'
@value={{@model.client_email}}
@isInvalid={{@model.errors.client_email}}
@isOptional={{true}}
readonly={{form.disabled}}
{{on 'input' (set-from-event @model 'client_email')}}
as |F|
>
<F.Label>{{t 'resources.host-catalog.form.client_email.label'}}</F.Label>
<F.HelperText>{{t
'resources.host-catalog.form.client_email.help'
}}</F.HelperText>
{{#if @model.errors.client_email}}
<F.Error as |E|>
{{#each @model.errors.client_email as |error|}}
<E.Message>{{error.message}}</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::TextInput::Field>
<Hds::Form::TextInput::Field
name='target_service_account_id'
@value={{@model.target_service_account_id}}
@isInvalid={{@model.errors.target_service_account_id}}
@isOptional={{true}}
readonly={{form.disabled}}
{{on 'input' (set-from-event @model 'target_service_account_id')}}
as |F|
>
<F.Label>{{t
'resources.host-catalog.form.target_service_account_id.label'
}}</F.Label>
<F.HelperText>{{t
'resources.host-catalog.form.target_service_account_id.help'
}}</F.HelperText>
{{#if @model.errors.target_service_account_id}}
<F.Error as |E|>
{{#each @model.errors.target_service_account_id as |error|}}
<E.Message>{{error.message}}</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::TextInput::Field>
<Hds::Form::TextInput::Field
name='private_key_id'
@type='password'
@value={{@model.private_key_id}}
@isInvalid={{@model.errors.private_key_id}}
@isOptional={{true}}
readonly={{form.disabled}}
{{on 'input' (set-from-event @model 'private_key_id')}}
as |F|
>
<F.Label>{{t 'resources.host-catalog.form.private_key_id.label'}}</F.Label>
<F.HelperText>{{t
'resources.host-catalog.form.private_key_id.help'
}}</F.HelperText>
{{#if @model.errors.private_key_id}}
<F.Error as |E|>
{{#each @model.errors.private_key_id as |error|}}
<E.Message>{{error.message}}</E.Message>
{{/each}}
</F.Error>
{{/if}}
</Hds::Form::TextInput::Field>
<Hds::Form::Textarea::Field
name='private_key'
@value={{@model.private_key}}
@isInvalid={{@model.errors.private_key}}
@isOptional={{true}}
readonly={{form.disabled}}
as |F|
>
<F.Label>{{t 'resources.host-catalog.form.private_key.label'}}</F.Label>
<F.HelperText>{{t
'resources.host-catalog.form.private_key.help'
}}</F.HelperText>
{{#if @model.errors.private_key}}
<F.Error as |E|>
{{#each @model.errors.private_key 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}}
readonly={{form.disabled}}
{{on 'change' (fn @toggleDisableCredentialRotation @model)}}
as |F|
>
<F.Label>{{t 'form.disable_credential_rotation.label'}}</F.Label>
</Hds::Form::Checkbox::Field>
{{#if (can 'save model' @model)}}
<form.actions
@enableEditText={{t 'actions.edit-form'}}
@submitText={{t 'actions.save'}}
@cancelText={{t 'actions.cancel'}}
/>
{{/if}}
</Rose::Form>
@@ -12,4 +12,5 @@
changeCredentialType=@changeCredentialType
mapResourceTypeWithIcon=this.mapResourceTypeWithIcon
hostCatalogTypes=this.hostCatalogTypes
toggleDisableCredentialRotation=this.toggleDisableCredentialRotation
}}
@@ -4,6 +4,8 @@
*/
import Component from '@glimmer/component';
import { action } from '@ember/object';
import {
TYPES_HOST_CATALOG,
TYPES_HOST_CATALOG_PLUGIN,
@@ -24,4 +26,11 @@ export default class FormHostCatalogIndexComponent extends Component {
{},
);
}
// =actions
@action
toggleDisableCredentialRotation(model) {
model.disable_credential_rotation = !model.disable_credential_rotation;
}
}
@@ -4,8 +4,7 @@
*/
import Component from '@glimmer/component';
const types = ['aws', 'azure'];
import { TYPES_HOST_CATALOG_PLUGIN } from 'api/models/host-catalog';
export default class HostCatalogTypeComponent extends Component {
/**
* Display icons only for plugin compositeTypes.
@@ -13,7 +12,7 @@ export default class HostCatalogTypeComponent extends Component {
*/
get icon() {
return (
types.includes(this.args.model.compositeType) &&
TYPES_HOST_CATALOG_PLUGIN.includes(this.args.model.compositeType) &&
`${this.args.model.compositeType}-color`
);
}
@@ -45,6 +45,7 @@ module('Acceptance | host-catalogs | create', function (hooks) {
newStaticHostCatalog: null,
newAWSDynamicHostCatalog: null,
newAzureDynamicHostCatalog: null,
newGCPDynamicHostCatalog: null,
};
hooks.beforeEach(async function () {
@@ -81,6 +82,7 @@ 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`;
urls.newGCPDynamicHostCatalog = `${urls.newHostCatalog}?type=gcp`;
featuresService = this.owner.lookup('service:features');
// Generate resource counter
@@ -110,7 +112,7 @@ module('Acceptance | host-catalogs | create', function (hooks) {
assert.strictEqual(getHostCatalogCount(), count + 1);
});
test('Users can create new dynamic aws host catalogs with azure provider', async function (assert) {
test('Users can create new dynamic azure host catalogs with azure provider', async function (assert) {
const count = getHostCatalogCount();
await visit(urls.newAzureDynamicHostCatalog);
await fillIn(NAME_INPUT_SELECTOR, 'random string');
@@ -120,6 +122,18 @@ module('Acceptance | host-catalogs | create', function (hooks) {
assert.strictEqual(getHostCatalogCount(), count + 1);
});
test('Users can create new dynamic host catalogs with GCP provider ', async function (assert) {
const count = getHostCatalogCount();
await visit(urls.newGCPDynamicHostCatalog);
await fillIn(NAME_INPUT_SELECTOR, 'random string');
await fillIn(DESCRIPTION_INPUT_SELECTOR, 'random string');
await fillIn('[name="zone"]', 'random string');
await fillIn('[name="project_id"]', 'random string');
await fillIn('[name="client_email"]', 'random string');
await click(SAVE_BUTTON_SELECTOR);
assert.strictEqual(getHostCatalogCount(), count + 1);
});
test('Users can cancel creation of new static host catalogs', async function (assert) {
const count = getHostCatalogCount();
await visit(urls.newStaticHostCatalog);
@@ -138,6 +152,15 @@ module('Acceptance | host-catalogs | create', function (hooks) {
assert.strictEqual(getHostCatalogCount(), count);
});
test('Users can cancel creation of new dynamic host catalogs with GCP provider', async function (assert) {
const count = getHostCatalogCount();
await visit(urls.newGCPDynamicHostCatalog);
await fillIn(NAME_INPUT_SELECTOR, 'random string');
await click(CANCEL_BUTTON_SELECTOR);
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) {
const count = getHostCatalogCount();
await visit(urls.newAzureDynamicHostCatalog);