Chore: refactor host catalog model and serializer to accommodate GCP plugin (#2627)
* chore: 🤖 GCP plugin support
This commit is contained in:
1 parent
31f1ed8dd4
commit
520020f2c6
16 files changed
+399
-179
No files matched your search
@@ -66,7 +66,7 @@
|
||||
<G.Legend>
|
||||
{{t 'form.type.label'}}
|
||||
</G.Legend>
|
||||
{{#each this.hostCatalogTypes as |hostCatalogType|}}
|
||||
{{#each @hostCatalogTypes as |hostCatalogType|}}
|
||||
<G.RadioCard
|
||||
@value={{hostCatalogType}}
|
||||
@maxWidth='20rem'
|
||||
@@ -98,7 +98,7 @@
|
||||
{{t 'descriptions.choose-a-provider'}}
|
||||
</G.HelperText>
|
||||
|
||||
{{#each-in this.mapResourceTypeWithIcon as |pluginType icon|}}
|
||||
{{#each-in @mapResourceTypeWithIcon as |pluginType icon|}}
|
||||
<G.RadioCard
|
||||
@value={{pluginType}}
|
||||
@maxWidth='20rem'
|
||||
|
||||
@@ -6,20 +6,12 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { action } from '@ember/object';
|
||||
import {
|
||||
TYPES_HOST_CATALOG,
|
||||
TYPES_HOST_CATALOG_PLUGIN,
|
||||
TYPES_CREDENTIALS,
|
||||
TYPE_CREDENTIAL_DYNAMIC,
|
||||
} from 'api/models/host-catalog';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
|
||||
//Note: this is a temporary solution till we have resource type helper in place
|
||||
const icons = ['aws-color', 'azure-color'];
|
||||
|
||||
export default class FormHostCatalogAwsComponent extends Component {
|
||||
// =properties
|
||||
hostCatalogTypes = TYPES_HOST_CATALOG;
|
||||
|
||||
// =attributes
|
||||
@tracked selectedCredentialType = this.args.model.credentialType;
|
||||
|
||||
@@ -34,16 +26,6 @@ export default class FormHostCatalogAwsComponent extends Component {
|
||||
return TYPES_CREDENTIALS;
|
||||
}
|
||||
|
||||
/**
|
||||
* maps resource type with icon
|
||||
* @type {object}
|
||||
*/
|
||||
get mapResourceTypeWithIcon() {
|
||||
return TYPES_HOST_CATALOG_PLUGIN.reduce(
|
||||
(obj, plugin, i) => ({ ...obj, [plugin]: icons[i] }),
|
||||
{},
|
||||
);
|
||||
}
|
||||
// =actions
|
||||
|
||||
@action
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
{{#if @model.isNew}}
|
||||
<Hds::Form::RadioCard::Group @name={{t 'form.type.label'}} as |G|>
|
||||
<G.Legend>{{t 'form.type.label'}}</G.Legend>
|
||||
{{#each this.hostCatalogTypes as |hostCatalogType|}}
|
||||
{{#each @hostCatalogTypes as |hostCatalogType|}}
|
||||
<G.RadioCard
|
||||
@value={{hostCatalogType}}
|
||||
@maxWidth='20rem'
|
||||
@@ -80,7 +80,7 @@
|
||||
(t 'descriptions.choose-a-provider')
|
||||
}}</G.HelperText>
|
||||
|
||||
{{#each-in this.mapResourceTypeWithIcon as |pluginType icon|}}
|
||||
{{#each-in @mapResourceTypeWithIcon as |pluginType icon|}}
|
||||
<G.RadioCard
|
||||
@value={{pluginType}}
|
||||
@maxWidth='20rem'
|
||||
|
||||
@@ -10,4 +10,6 @@
|
||||
cancel=@cancel
|
||||
changeType=@changeType
|
||||
changeCredentialType=@changeCredentialType
|
||||
mapResourceTypeWithIcon=this.mapResourceTypeWithIcon
|
||||
hostCatalogTypes=this.hostCatalogTypes
|
||||
}}
|
||||
+2
-3
@@ -9,10 +9,9 @@ import {
|
||||
TYPES_HOST_CATALOG_PLUGIN,
|
||||
} 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'];
|
||||
const icons = ['aws-color', 'azure-color', 'gcp-color'];
|
||||
|
||||
export default class FormAzureHostCatalogAwsComponent extends Component {
|
||||
export default class FormHostCatalogIndexComponent extends Component {
|
||||
// =properties
|
||||
hostCatalogTypes = TYPES_HOST_CATALOG;
|
||||
/**
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
<Hds::Form::RadioCard::Group @name={{t 'form.type.label'}} as |G|>
|
||||
<G.Legend>{{t 'form.type.label'}}</G.Legend>
|
||||
{{#each this.hostCatalogTypes as |hostCatalogType|}}
|
||||
{{#each @hostCatalogTypes as |hostCatalogType|}}
|
||||
<G.RadioCard
|
||||
@value={{hostCatalogType}}
|
||||
@maxWidth='20rem'
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Component from '@glimmer/component';
|
||||
import {
|
||||
TYPES_HOST_CATALOG,
|
||||
TYPES_HOST_CATALOG_PLUGIN,
|
||||
} 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_HOST_CATALOG;
|
||||
/**
|
||||
* maps resource type with icon
|
||||
* @type {object}
|
||||
*/
|
||||
get mapResourceTypeWithIcon() {
|
||||
return TYPES_HOST_CATALOG_PLUGIN.reduce(
|
||||
(obj, plugin, i) => ({ ...obj, [plugin]: icons[i] }),
|
||||
{},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -81,6 +81,7 @@ module('Acceptance | host-catalogs | update', function (hooks) {
|
||||
test('can update static AWS credentials to Dynamic AWS credentials', async function (assert) {
|
||||
await visit(urls.AWSHostCatalogWithStaticCredential);
|
||||
await click(EDIT_BUTTON_SELECTOR, 'Activate edit mode');
|
||||
|
||||
assert.strictEqual(
|
||||
find(CREDENTIAL_TYPE_SELECTOR).value,
|
||||
'static-credential',
|
||||
|
||||
Reference in new issue
Block a user