File tree Expand file tree Collapse file tree 2 files changed +47
-15
lines changed
ui/admin/app/components/form/host Expand file tree Collapse file tree 2 files changed +47
-15
lines changed Original file line number Diff line number Diff line change 44}}
55
66{{ #if @model.compositeType }}
7- {{ component
8- (concat ' form/host/' @model.compositeType )
9- model = @model
10- submit = @submit
11- cancel = @cancel
12- }}
7+ <this .hostFormComponent
8+ @model ={{ @model }}
9+ @submit ={{ @submit }}
10+ @cancel ={{ @cancel }}
11+ />
1312{{ else }}
14- {{! create-and-add-host cancel route doesn't
15- have a model and this else part is required to prevent
16- erroring out here. This has been noted in the tech debt doc to further investigate }}
17- {{ component
18- (concat ' form/host/' ' static' )
19- model = @model
20- submit = @submit
21- cancel = @cancel
22- }}
13+ {{! create-and-add-host cancel route doesn't have a model and this else part is required
14+ to prevent erroring out here. This has been noted in the tech debt doc to further investigate }}
15+ <Form ::Host::Static
16+ @model ={{ @model }}
17+ @submit ={{ @submit }}
18+ @cancel ={{ @cancel }}
19+ />
2320{{ /if }}
Original file line number Diff line number Diff line change 1+ import Component from '@glimmer/component' ;
2+ import { assert } from '@ember/debug' ;
3+ import {
4+ TYPE_HOST_CATALOG_PLUGIN_AWS ,
5+ TYPE_HOST_CATALOG_PLUGIN_AZURE ,
6+ TYPE_HOST_CATALOG_PLUGIN_GCP ,
7+ TYPE_HOST_CATALOG_STATIC ,
8+ } from 'api/models/host-catalog' ;
9+ import awsHostFormComponent from './aws' ;
10+ import azureHostFormComponent from './azure' ;
11+ import gcpHostFormComponent from './gcp' ;
12+ import staticHostFormComponent from './static' ;
13+
14+ const modelCompositeTypeToComponent = {
15+ [ TYPE_HOST_CATALOG_PLUGIN_AWS ] : awsHostFormComponent ,
16+ [ TYPE_HOST_CATALOG_PLUGIN_AZURE ] : azureHostFormComponent ,
17+ [ TYPE_HOST_CATALOG_PLUGIN_GCP ] : gcpHostFormComponent ,
18+ [ TYPE_HOST_CATALOG_STATIC ] : staticHostFormComponent ,
19+ } ;
20+
21+ export default class FormHostIndex extends Component {
22+ /**
23+ * Returns the host form component associated with the model's composite type
24+ * @type {Component }
25+ */
26+ get hostFormComponent ( ) {
27+ const component =
28+ modelCompositeTypeToComponent [ this . args . model . compositeType ] ;
29+ assert (
30+ `Mapped component must exist for host composite type: ${ this . args . model . compositeType } ` ,
31+ component ,
32+ ) ;
33+ return component ;
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments