Skip to content

Commit b3f8d33

Browse files
committed
chore: 🤖 migrate away from component helper for target form
1 parent 2bf0901 commit b3f8d33

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

‎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: 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 rdpTargetForm from './rdp';
4+
import sshTargetForm from './ssh';
5+
import tcpTargetForm from './tcp';
6+
7+
const modelTypeToComponent = {
8+
rdp: rdpTargetForm,
9+
ssh: sshTargetForm,
10+
tcp: tcpTargetForm,
11+
};
12+
13+
export default class FormTargetIndex extends Component {
14+
get targetFormComponent() {
15+
const component = modelTypeToComponent[this.args.model.type];
16+
assert(
17+
`Mapped component must exist for target type: ${this.args.model.type}`,
18+
component,
19+
);
20+
return component;
21+
}
22+
}

0 commit comments

Comments
 (0)