Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions ui/admin/app/components/form/host-catalog/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
SPDX-License-Identifier: BUSL-1.1
}}

{{component
(concat 'form/host-catalog/' @model.compositeType)
model=@model
submit=@submit
cancel=@cancel
changeType=@changeType
changeCredentialType=@changeCredentialType
mapResourceTypeWithIcon=this.mapResourceTypeWithIcon
hostCatalogTypes=this.hostCatalogTypes
toggleDisableCredentialRotation=this.toggleDisableCredentialRotation
}}
<this.hostCatalogFormComponent
@model={{@model}}
@submit={{@submit}}
@cancel={{@cancel}}
@changeType={{@changeType}}
@changeCredentialType={{@changeCredentialType}}
@mapResourceTypeWithIcon={{this.mapResourceTypeWithIcon}}
@hostCatalogTypes={{this.hostCatalogTypes}}
@toggleDisableCredentialRotation={{this.toggleDisableCredentialRotation}}
/>
31 changes: 30 additions & 1 deletion ui/admin/app/components/form/host-catalog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,26 @@

import Component from '@glimmer/component';
import { action } from '@ember/object';

import { assert } from '@ember/debug';
import {
TYPES_HOST_CATALOG,
TYPES_HOST_CATALOG_PLUGIN,
TYPE_HOST_CATALOG_PLUGIN_AWS,
TYPE_HOST_CATALOG_PLUGIN_AZURE,
TYPE_HOST_CATALOG_PLUGIN_GCP,
TYPE_HOST_CATALOG_STATIC,
} from 'api/models/host-catalog';
import awsHostCatalogFormComponent from './aws';
import azureHostCatalogFormComponent from './azure';
import gcpHostCatalogFormComponent from './gcp';
import staticHostCatalogFormComponent from './static';

const modelCompositeTypeToComponent = {
[TYPE_HOST_CATALOG_PLUGIN_AWS]: awsHostCatalogFormComponent,
[TYPE_HOST_CATALOG_PLUGIN_AZURE]: azureHostCatalogFormComponent,
[TYPE_HOST_CATALOG_PLUGIN_GCP]: gcpHostCatalogFormComponent,
[TYPE_HOST_CATALOG_STATIC]: staticHostCatalogFormComponent,
};

const icons = ['aws-color', 'azure-color', 'gcp-color'];

Expand All @@ -27,6 +42,20 @@ export default class FormHostCatalogIndexComponent extends Component {
);
}

/**
* Returns the host catalog form component associated with the model's composite type
* @type {Component}
*/
get hostCatalogFormComponent() {
const component =
modelCompositeTypeToComponent[this.args.model.compositeType];
assert(
`Mapped component must exist for host catalog composite type: ${this.args.model.compositeType}`,
component,
);
return component;
}

// =actions

@action
Expand Down
Loading