Skip to content

Commit 6c63fbe

Browse files
committed
chore: 🤖 migrate component helper usage for storage bucket form
1 parent b3f8d33 commit 6c63fbe

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-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: 20 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,18 @@ 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 = modelCompositeTypeToComponent[this.args.model.type];
39+
assert(
40+
`Mapped component must exist for storage bucket composite type: ${this.args.model.compositeType}`,
41+
component,
42+
);
43+
return component;
44+
}
45+
2746
// =actions
2847
@action
2948
updateScope(event) {

0 commit comments

Comments
 (0)