Skip to content

Commit 48e48f6

Browse files
hashiccDhariniJeeva
authored andcommitted
chore: 🤖 migrate away from component helper for target form (#3080)
* chore: 🤖 migrate away from component helper for target form * Add missing copyright headers
1 parent c2c291d commit 48e48f6

File tree

2 files changed

+34
-8
lines changed

2 files changed

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

0 commit comments

Comments
 (0)