55
66import Component from '@glimmer/component' ;
77import { action } from '@ember/object' ;
8-
8+ import { assert } from '@ember/debug' ;
99import {
1010 TYPES_HOST_CATALOG ,
1111 TYPES_HOST_CATALOG_PLUGIN ,
12+ TYPE_HOST_CATALOG_PLUGIN_AWS ,
13+ TYPE_HOST_CATALOG_PLUGIN_AZURE ,
14+ TYPE_HOST_CATALOG_PLUGIN_GCP ,
15+ TYPE_HOST_CATALOG_STATIC ,
1216} from 'api/models/host-catalog' ;
17+ import awsHostCatalogFormComponent from './aws' ;
18+ import azureHostCatalogFormComponent from './azure' ;
19+ import gcpHostCatalogFormComponent from './gcp' ;
20+ import staticHostCatalogFormComponent from './static' ;
21+
22+ const modelCompositeTypeToComponent = {
23+ [ TYPE_HOST_CATALOG_PLUGIN_AWS ] : awsHostCatalogFormComponent ,
24+ [ TYPE_HOST_CATALOG_PLUGIN_AZURE ] : azureHostCatalogFormComponent ,
25+ [ TYPE_HOST_CATALOG_PLUGIN_GCP ] : gcpHostCatalogFormComponent ,
26+ [ TYPE_HOST_CATALOG_STATIC ] : staticHostCatalogFormComponent ,
27+ } ;
1328
1429const icons = [ 'aws-color' , 'azure-color' , 'gcp-color' ] ;
1530
@@ -27,6 +42,20 @@ export default class FormHostCatalogIndexComponent extends Component {
2742 ) ;
2843 }
2944
45+ /**
46+ * Returns the host catalog form component associated with the model's composite type
47+ * @type {Component }
48+ */
49+ get hostCatalogFormComponent ( ) {
50+ const component =
51+ modelCompositeTypeToComponent [ this . args . model . compositeType ] ;
52+ assert (
53+ `Mapped component must exist for host catalog composite type: ${ this . args . model . compositeType } ` ,
54+ component ,
55+ ) ;
56+ return component ;
57+ }
58+
3059 // =actions
3160
3261 @action
0 commit comments