From fd3f0f0ef242f14dc76cd1bbccfd51d26065c686 Mon Sep 17 00:00:00 2001 From: hashicc <191911133+hashicc@users.noreply.github.com> Date: Mon, 17 Nov 2025 12:17:01 -0500 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20use=20statically=20refe?= =?UTF-8?q?renced=20components=20for=20host=20catalog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/form/host-catalog/index.hbs | 21 ++++++------- .../app/components/form/host-catalog/index.js | 31 ++++++++++++++++++- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/ui/admin/app/components/form/host-catalog/index.hbs b/ui/admin/app/components/form/host-catalog/index.hbs index f65e9fdaef..b8efea59fe 100644 --- a/ui/admin/app/components/form/host-catalog/index.hbs +++ b/ui/admin/app/components/form/host-catalog/index.hbs @@ -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 -}} \ No newline at end of file + \ No newline at end of file diff --git a/ui/admin/app/components/form/host-catalog/index.js b/ui/admin/app/components/form/host-catalog/index.js index b7a7232db7..564abafb3c 100644 --- a/ui/admin/app/components/form/host-catalog/index.js +++ b/ui/admin/app/components/form/host-catalog/index.js @@ -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