Skip to content

Commit bf13407

Browse files
authored
refactor: 💡 migrate away from component helper for auth-method (#3011)
* refactor: 💡 migrate away from component helper for auth-method component * Add missing copyright headers
1 parent 0bd152e commit bf13407

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

‎ui/admin/app/components/form/auth-method/index.hbs‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
Copyright (c) HashiCorp, Inc.
33
SPDX-License-Identifier: BUSL-1.1
44
}}
5-
65
{{#if @model.type}}
7-
{{component
8-
(concat 'form/auth-method/' @model.type)
9-
model=@model
10-
edit=@edit
11-
submit=@submit
12-
cancel=@cancel
13-
removeItemByIndex=@removeItemByIndex
14-
addStringItem=@addStringItem
15-
addAccountMapItem=@addAccountMapItem
16-
}}
6+
<this.authMethodFormComponent
7+
@model={{@model}}
8+
@edit={{@edit}}
9+
@submit={{@submit}}
10+
@cancel={{@cancel}}
11+
@removeItemByIndex={{@removeItemByIndex}}
12+
@addStringItem={{@addStringItem}}
13+
@addAccountMapItem={{@addAccountMapItem}}
14+
/>
1715
{{/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 oidc from './oidc';
9+
import ldap from './ldap';
10+
import password from './password';
11+
12+
const modelTypeToComponent = {
13+
ldap,
14+
password,
15+
oidc,
16+
};
17+
18+
export default class FormAuthMethodIndex extends Component {
19+
get authMethodFormComponent() {
20+
const component = modelTypeToComponent[this.args.model.type];
21+
assert(
22+
`Mapped component must exist for auth method: ${this.args.model.type}`,
23+
component,
24+
);
25+
return component;
26+
}
27+
}

0 commit comments

Comments
 (0)