chore: 🤖 use statically defined credential store components (#3071)
* chore: 🤖 use statically defined cred store components
* Add missing copyright headers
This commit is contained in:
1 parent
dd0c5df25c
commit
f9a9f677ca
2 files changed
+35
-7
No files matched your search
@@ -4,11 +4,10 @@
|
||||
}}
|
||||
|
||||
{{#if @model.type}}
|
||||
{{component
|
||||
(concat 'form/credential-store/' @model.type)
|
||||
model=@model
|
||||
submit=@submit
|
||||
cancel=@cancel
|
||||
changeType=@changeType
|
||||
}}
|
||||
<this.credentialStoreFormComponent
|
||||
@model={{@model}}
|
||||
@submit={{@submit}}
|
||||
@cancel={{@cancel}}
|
||||
@changeType={{@changeType}}
|
||||
/>
|
||||
{{/if}}
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Component from '@glimmer/component';
|
||||
import { assert } from '@ember/debug';
|
||||
import {
|
||||
TYPE_CREDENTIAL_STORE_STATIC,
|
||||
TYPE_CREDENTIAL_STORE_VAULT,
|
||||
} from 'api/models/credential-store';
|
||||
import staticCredentialStoreComponent from './static';
|
||||
import vaultCredentialStoreComponent from './vault';
|
||||
|
||||
const modelTypeToComponent = {
|
||||
[TYPE_CREDENTIAL_STORE_STATIC]: staticCredentialStoreComponent,
|
||||
[TYPE_CREDENTIAL_STORE_VAULT]: vaultCredentialStoreComponent,
|
||||
};
|
||||
|
||||
export default class FormCredentialStoreIndex extends Component {
|
||||
get credentialStoreFormComponent() {
|
||||
const component = modelTypeToComponent[this.args.model.type];
|
||||
assert(
|
||||
`Mapped component must exist for credential store type: ${this.args.model.type}`,
|
||||
component,
|
||||
);
|
||||
return component;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user