Skip to content

Commit 05c6a99

Browse files
authored
Merge branch 'main' into compliance/update-headers
2 parents 313ba4c + 1d08ddb commit 05c6a99

File tree

4 files changed

+67
-22
lines changed

4 files changed

+67
-22
lines changed

ui/admin/app/components/form/storage-bucket/index.hbs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
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}}

ui/admin/app/components/form/storage-bucket/index.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@ import Component from '@glimmer/component';
77
import { action } from '@ember/object';
88
import { service } from '@ember/service';
99
import { set } from '@ember/object';
10-
10+
import { assert } from '@ember/debug';
1111
import {
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

1623
export 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) {

ui/admin/app/components/form/target/index.hbs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
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}}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
}

0 commit comments

Comments
 (0)