Skip to content

Commit 1d08ddb

Browse files
authored
chore: 🤖 migrate component helper usage for storage bucket form (#3081)
1 parent 824427b commit 1d08ddb

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
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) {

0 commit comments

Comments
 (0)