Skip to content

Commit f9a9f67

Browse files
authored
chore: 🤖 use statically defined credential store components (#3071)
* chore: 🤖 use statically defined cred store components * Add missing copyright headers
1 parent dd0c5df commit f9a9f67

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

ui/admin/app/components/form/credential-store/index.hbs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
}}
55

66
{{#if @model.type}}
7-
{{component
8-
(concat 'form/credential-store/' @model.type)
9-
model=@model
10-
submit=@submit
11-
cancel=@cancel
12-
changeType=@changeType
13-
}}
7+
<this.credentialStoreFormComponent
8+
@model={{@model}}
9+
@submit={{@submit}}
10+
@cancel={{@cancel}}
11+
@changeType={{@changeType}}
12+
/>
1413
{{/if}}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 {
9+
TYPE_CREDENTIAL_STORE_STATIC,
10+
TYPE_CREDENTIAL_STORE_VAULT,
11+
} from 'api/models/credential-store';
12+
import staticCredentialStoreComponent from './static';
13+
import vaultCredentialStoreComponent from './vault';
14+
15+
const modelTypeToComponent = {
16+
[TYPE_CREDENTIAL_STORE_STATIC]: staticCredentialStoreComponent,
17+
[TYPE_CREDENTIAL_STORE_VAULT]: vaultCredentialStoreComponent,
18+
};
19+
20+
export default class FormCredentialStoreIndex extends Component {
21+
get credentialStoreFormComponent() {
22+
const component = modelTypeToComponent[this.args.model.type];
23+
assert(
24+
`Mapped component must exist for credential store type: ${this.args.model.type}`,
25+
component,
26+
);
27+
return component;
28+
}
29+
}

0 commit comments

Comments
 (0)