Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions ui/admin/app/components/form/credential-store/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
29 changes: 29 additions & 0 deletions ui/admin/app/components/form/credential-store/index.js
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading