File tree Expand file tree Collapse file tree 4 files changed +67
-22
lines changed
ui/admin/app/components/form Expand file tree Collapse file tree 4 files changed +67
-22
lines changed Original file line number Diff line number Diff line change 33 SPDX-License-Identifier: BUSL-1.1
44}}
55{{ #if @model.type }}
6- {{ component
7- (concat ' form/storage-bucket/' @model.compositeType )
8- model = @model
9- submit = @submit
10- cancel = @cancel
11- updateScope =this.updateScope
12- scopes = @scopes
13- pluginTypes =this.pluginTypes
14- changePluginType = @changePluginType
15- changeCredentialType = @changeCredentialType
16- rollbackSecretAttrs =this.rollbackSecretAttrs
17- toggleDisableCredentialRotation =this.toggleDisableCredentialRotation
18- }}
6+ <this .storageBucketFormComponent
7+ @model ={{ @model }}
8+ @submit ={{ @submit }}
9+ @cancel ={{ @cancel }}
10+ @updateScope ={{ this.updateScope }}
11+ @scopes ={{ @scopes }}
12+ @pluginTypes ={{ this.pluginTypes }}
13+ @changePluginType ={{ @changePluginType }}
14+ @changeCredentialType ={{ @changeCredentialType }}
15+ @rollbackSecretAttrs ={{ this.rollbackSecretAttrs }}
16+ @toggleDisableCredentialRotation ={{ this.toggleDisableCredentialRotation }}
17+ />
1918{{ /if }}
Original file line number Diff line number Diff line change @@ -7,11 +7,18 @@ import Component from '@glimmer/component';
77import { action } from '@ember/object' ;
88import { service } from '@ember/service' ;
99import { set } from '@ember/object' ;
10-
10+ import { assert } from '@ember/debug' ;
1111import {
1212 TYPE_CREDENTIAL_DYNAMIC ,
1313 TYPES_STORAGE_BUCKET_PLUGIN ,
1414} from 'api/models/storage-bucket' ;
15+ import awsFormComponent from './aws' ;
16+ import minioFormComponent from './minio' ;
17+
18+ const modelCompositeTypeToComponent = {
19+ aws : awsFormComponent ,
20+ minio : minioFormComponent ,
21+ } ;
1522
1623export default class FormStorageBucketComponent extends Component {
1724 // =attributes
@@ -24,6 +31,19 @@ export default class FormStorageBucketComponent extends Component {
2431 return TYPES_STORAGE_BUCKET_PLUGIN ;
2532 }
2633
34+ /**
35+ * returns the associated storage bucket form component for the model's composite type
36+ */
37+ get storageBucketFormComponent ( ) {
38+ const component =
39+ modelCompositeTypeToComponent [ this . args . model . compositeType ] ;
40+ assert (
41+ `Mapped component must exist for storage bucket composite type: ${ this . args . model . compositeType } ` ,
42+ component ,
43+ ) ;
44+ return component ;
45+ }
46+
2747 // =actions
2848 @action
2949 updateScope ( event ) {
Original file line number Diff line number Diff line change 44}}
55
66{{ #if @model.type }}
7- {{ component
8- (concat ' form/target/' @model.type )
9- model = @model
10- submit = @submit
11- cancel = @cancel
12- globalScope = @globalScope
13- changeType = @changeType
14- }}
7+ <this .targetFormComponent
8+ @model ={{ @model }}
9+ @submit ={{ @submit }}
10+ @cancel ={{ @cancel }}
11+ @globalScope ={{ @globalScope }}
12+ @changeType ={{ @changeType }}
13+ />
1514{{ /if }}
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) HashiCorp, Inc.
3+ * SPDX-License-Identifier: BUSL-1.1
4+ */
5+
6+ import Component from '@glimmer/component' ;
7+ import { assert } from '@ember/debug' ;
8+ import rdpTargetForm from './rdp' ;
9+ import sshTargetForm from './ssh' ;
10+ import tcpTargetForm from './tcp' ;
11+
12+ const modelTypeToComponent = {
13+ rdp : rdpTargetForm ,
14+ ssh : sshTargetForm ,
15+ tcp : tcpTargetForm ,
16+ } ;
17+
18+ export default class FormTargetIndex extends Component {
19+ get targetFormComponent ( ) {
20+ const component = modelTypeToComponent [ this . args . model . type ] ;
21+ assert (
22+ `Mapped component must exist for target type: ${ this . args . model . type } ` ,
23+ component ,
24+ ) ;
25+ return component ;
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments