Skip to content

Commit bedab31

Browse files
committed
refactor: 💡 remove dynamic component helper from form/authenticate
1 parent 72639bd commit bedab31

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

‎addons/core/addon/components/form/authenticate/index.hbs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
}}
55

66
{{#if @model.type}}
7-
{{component
8-
(concat 'form/authenticate/' @model.type)
9-
onSubmit=@submit
10-
disabled=@disabled
11-
}}
7+
<this.authenticateFormComponent
8+
@onSubmit={{@submit}}
9+
@disabled={{@disabled}}
10+
/>
1211
{{/if}}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import Component from '@glimmer/component';
2+
import { assert } from '@ember/debug';
3+
import oidc from './oidc';
4+
import ldap from './ldap';
5+
import password from './password';
6+
7+
const modelTypeToComponent = {
8+
ldap,
9+
password,
10+
oidc,
11+
};
12+
13+
export default class FormAuthenticateIndex extends Component {
14+
get authenticateFormComponent() {
15+
const component = modelTypeToComponent[this.args.model.type];
16+
assert(
17+
`Mapped component must exist for auth method: ${this.args.model.type}`,
18+
component,
19+
);
20+
return component;
21+
}
22+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from 'core/components/form/authenticate/index';

0 commit comments

Comments
 (0)