chore: 🤖 use statically referenced components for host catalog (#3073)

This commit is contained in:
hashicc authored and GitHub committed 2025-11-24 16:54:23 -05:00
1 parent 6fcc743217
commit 30c2cab0b7
2 files changed
+40 -12

No files matched your search

@@ -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}}
/>
@@ -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'];
@@ -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