feat: 🎸 Update the credentials route to support both types (#1263)

Add query param to the credential route in order to support the new ssh
private key type

✅ Closes: ICU-5649

Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com>
This commit is contained in:
lisbet-alvarezandCameron Perera authored and GitHub committed 2022-08-17 14:48:52 -07:00
1 parent 53eef5caeb
commit dae5174d2f
4 files changed
+28 -2

No files matched your search

@@ -51,6 +51,7 @@
<form.radioGroup
@name='types'
@selectedValue='username_password'
@changed={{@changeType}}
as |radioGroup|
>
<radioGroup.card
@@ -8,6 +8,8 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialsNewCon
// =attributes
queryParams = ['type'];
/**
* Translated new credentials breadcrumb
* @type {string}
@@ -1,14 +1,28 @@
import Route from '@ember/routing/route';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
export default class ScopesScopeCredentialStoresCredentialStoreCredentialsNewRoute extends Route {
// =services
@service router;
// =attributes
queryParams = {
type: {
refreshModel: true,
},
};
// =methods
/**
* Creates a new unsaved credential in current credential store.
* @return {CredentialModel}
*/
model() {
const { id: credential_store_id, type } = this.modelFor(
model({ type = 'username_password' }) {
const { id: credential_store_id } = this.modelFor(
'scopes.scope.credential-stores.credential-store'
);
return this.store.createRecord('credential', {
@@ -16,4 +30,12 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialsNewRou
credential_store_id,
});
}
/**
* Update type of credential
* @param {string} type
*/
@action
changeType(type) {
this.router.replaceWith({ queryParams: { type } });
}
}
@@ -18,6 +18,7 @@
@model={{@model}}
@submit={{route-action 'save' @model}}
@cancel={{route-action 'cancel' @model}}
@changeType={{route-action 'changeType'}}
/>
</page.body>
</Rose::Layout::Page>