File tree Expand file tree Collapse file tree 2 files changed +40
-8
lines changed
ui/admin/app/components/form/credential-library Expand file tree Collapse file tree 2 files changed +40
-8
lines changed Original file line number Diff line number Diff line change 44}}
55
66{{ #if @model.type }}
7- {{ component
8- (concat ' form/credential-library/' @model.type )
9- model = @model
10- submit = @submit
11- cancel = @cancel
12- changeType = @changeType
13- edit = @edit
14- }}
7+ <this .credentialLibraryFormComponent
8+ @model ={{ @model }}
9+ @submit ={{ @submit }}
10+ @cancel ={{ @cancel }}
11+ @changeType ={{ @changeType }}
12+ @edit ={{ @edit }}
13+ />
1514{{ /if }}
Original file line number Diff line number Diff line change 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_LIBRARY_VAULT_GENERIC ,
10+ TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE ,
11+ TYPE_CREDENTIAL_LIBRARY_VAULT_LDAP ,
12+ } from 'api/models/credential-library' ;
13+ import VaultGenericFormComponent from './vault-generic' ;
14+ import VaultSshCertificateFormComponent from './vault-ssh-certificate' ;
15+ import VaultLdapFormComponent from './vault-ldap' ;
16+
17+ const modelTypeToComponent = {
18+ [ TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC ] : VaultGenericFormComponent ,
19+ [ TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE ] :
20+ VaultSshCertificateFormComponent ,
21+ [ TYPE_CREDENTIAL_LIBRARY_VAULT_LDAP ] : VaultLdapFormComponent ,
22+ } ;
23+
24+ export default class FormCredentialLibraryIndex extends Component {
25+ get credentialLibraryFormComponent ( ) {
26+ const component = modelTypeToComponent [ this . args . model . type ] ;
27+ assert (
28+ `Mapped component must exist for credential library type: ${ this . args . model . type } ` ,
29+ component ,
30+ ) ;
31+ return component ;
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments