diff --git a/ui/admin/app/components/form/credential-store/index.hbs b/ui/admin/app/components/form/credential-store/index.hbs
index c887438f1..84c5d2b23 100644
--- a/ui/admin/app/components/form/credential-store/index.hbs
+++ b/ui/admin/app/components/form/credential-store/index.hbs
@@ -1,279 +1,7 @@
-
- {{#if (feature-flag 'static-credentials')}}
-
- <:title>{{t 'form.type.label'}}
- <:body>
- {{#if @model.isNew}}
- {{! Code to allow option to select between cred. store types (vault or static) when it is first created goes here}}
-
- {{else}}
-
-
-
- {{/if}}
-
-
- {{else}}
-
- {{/if}}
-
-
- {{#if @model.errors.name}}
-
- {{#each @model.errors.name as |error|}}
- {{error.message}}
- {{/each}}
-
- {{/if}}
-
-
-
- {{#if @model.errors.description}}
-
- {{#each @model.errors.description as |error|}}
- {{error.message}}
- {{/each}}
-
- {{/if}}
-
-
-
- {{#if @model.errors.address}}
-
- {{#each @model.errors.address as |error|}}
- {{error.message}}
- {{/each}}
-
- {{/if}}
-
-
-
- {{#if @model.errors.token}}
-
- {{#each @model.errors.token as |error|}}
- {{error.message}}
- {{/each}}
-
- {{/if}}
-
-
- {{#unless @model.isNew}}
-
- {{/unless}}
-
-
- {{#if @model.errors.namespace}}
-
- {{#each @model.errors.namespace as |error|}}
- {{error.message}}
- {{/each}}
-
- {{/if}}
-
-
-
- {{#if @model.errors.tls_server_name}}
-
- {{#each @model.errors.tls_server_name as |error|}}
- {{error.message}}
- {{/each}}
-
- {{/if}}
-
-
-
- {{#if @model.errors.tls_skip_verify}}
-
- {{#each @model.errors.tls_skip_verify as |error|}}
- {{error.message}}
- {{/each}}
-
- {{/if}}
-
-
-
- {{#if @model.errors.client_certificate}}
-
- {{#each @model.errors.client_certificate as |error|}}
- {{error.message}}
- {{/each}}
-
- {{/if}}
-
-
-
- {{#if @model.errors.client_certificate_key}}
-
- {{#each @model.errors.client_certificate_key as |error|}}
- {{error.message}}
- {{/each}}
-
- {{/if}}
-
-
- {{#unless @model.isNew}}
-
- {{/unless}}
-
-
- {{#if @model.errors.ca_cert}}
-
- {{#each @model.errors.ca_cert as |error|}}
- {{error.message}}
- {{/each}}
-
- {{/if}}
-
- {{#if (can 'save model' @model)}}
-
- {{/if}}
-
\ No newline at end of file
+{{component
+ (concat 'form/credential-store/' @model.type)
+ model=@model
+ submit=@submit
+ cancel=@cancel
+ changeType=@changeType
+}}
\ No newline at end of file
diff --git a/ui/admin/app/components/form/credential-store/static/index.hbs b/ui/admin/app/components/form/credential-store/static/index.hbs
new file mode 100644
index 000000000..85cd00832
--- /dev/null
+++ b/ui/admin/app/components/form/credential-store/static/index.hbs
@@ -0,0 +1,104 @@
+
+
+ {{#if @model.errors.name}}
+
+ {{#each @model.errors.name as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+
+ {{#if @model.errors.description}}
+
+ {{#each @model.errors.description as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+ {{#if (feature-flag 'static-credentials')}}
+
+ <:title>{{t 'form.type.label'}}
+ <:body>
+ {{#if @model.isNew}}
+
+
+
+
+ {{else}}
+
+
+
+ {{/if}}
+
+
+ {{/if}}
+
+ {{#if (can 'save model' @model)}}
+
+ {{/if}}
+
\ No newline at end of file
diff --git a/ui/admin/app/components/form/credential-store/vault/index.hbs b/ui/admin/app/components/form/credential-store/vault/index.hbs
new file mode 100644
index 000000000..f3d713ae8
--- /dev/null
+++ b/ui/admin/app/components/form/credential-store/vault/index.hbs
@@ -0,0 +1,309 @@
+
+
+ {{#if @model.errors.name}}
+
+ {{#each @model.errors.name as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+
+ {{#if @model.errors.description}}
+
+ {{#each @model.errors.description as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+ {{#if (feature-flag 'static-credentials')}}
+
+ <:title>{{t 'form.type.label'}}
+ <:body>
+ {{#if @model.isNew}}
+
+
+
+
+ {{else}}
+
+
+
+ {{/if}}
+
+
+ {{else}}
+
+ <:title>{{t 'form.type.label'}}
+ <:body>
+
+
+
+
+
+ {{/if}}
+
+
+ {{#if @model.errors.address}}
+
+ {{#each @model.errors.address as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+
+ {{#if @model.errors.token}}
+
+ {{#each @model.errors.token as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+ {{#unless @model.isNew}}
+
+ {{/unless}}
+
+
+ {{#if @model.errors.namespace}}
+
+ {{#each @model.errors.namespace as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+
+ {{#if @model.errors.tls_server_name}}
+
+ {{#each @model.errors.tls_server_name as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+
+ {{#if @model.errors.tls_skip_verify}}
+
+ {{#each @model.errors.tls_skip_verify as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+
+ {{#if @model.errors.client_certificate}}
+
+ {{#each @model.errors.client_certificate as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+
+ {{#if @model.errors.client_certificate_key}}
+
+ {{#each @model.errors.client_certificate_key as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+ {{#unless @model.isNew}}
+
+ {{/unless}}
+
+
+ {{#if @model.errors.ca_cert}}
+
+ {{#each @model.errors.ca_cert as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+ {{#if (can 'save model' @model)}}
+
+ {{/if}}
+
\ No newline at end of file
diff --git a/ui/admin/app/controllers/scopes/scope/credential-stores/new.js b/ui/admin/app/controllers/scopes/scope/credential-stores/new.js
index 3f50abb13..41db0548b 100644
--- a/ui/admin/app/controllers/scopes/scope/credential-stores/new.js
+++ b/ui/admin/app/controllers/scopes/scope/credential-stores/new.js
@@ -7,7 +7,7 @@ export default class ScopesScopeCredentialStoresNewController extends Controller
@service intl;
// =attributes
-
+ queryParams = ['type'];
/**
* Breadcrumb for new route
* @type {string}
diff --git a/ui/admin/app/routes/scopes/scope/credential-stores/new.js b/ui/admin/app/routes/scopes/scope/credential-stores/new.js
index e8bc7e431..80fc0e355 100644
--- a/ui/admin/app/routes/scopes/scope/credential-stores/new.js
+++ b/ui/admin/app/routes/scopes/scope/credential-stores/new.js
@@ -1,15 +1,51 @@
import Route from '@ember/routing/route';
+import { action } from '@ember/object';
+import { inject as service } from '@ember/service';
export default class ScopesScopeCredentialStoresNewRoute extends Route {
+ // =services
+
+ @service router;
+ @service features;
+ // =attributes
+
+ queryParams = {
+ type: {
+ refreshModel: true,
+ },
+ };
+
// =methods
/**
* Creates a new unsaved credential-store
+ * Also rollback/destroy any new, unsaved instances from this route before
+ * creating another, but reuse name/description if available.
*/
- model() {
+ model({ type = 'static' }) {
const scopeModel = this.modelFor('scopes.scope');
+ let name, description;
+ if (this.currentModel?.isNew) {
+ ({ name, description } = this.currentModel);
+ this.currentModel.rollbackAttributes();
+ }
+ //hide static type credential stores if the feature flag isn't enabled
+ if (!this.features.isEnabled('static-credentials')) {
+ type = 'vault';
+ }
return this.store.createRecord('credential-store', {
- type: 'vault',
+ type,
scopeModel,
+ name,
+ description,
});
}
+
+ /**
+ * Update type of credential store
+ * @param {string} type
+ */
+ @action
+ changeType(type) {
+ this.router.replaceWith({ queryParams: { type } });
+ }
}
diff --git a/ui/admin/app/templates/scopes/scope/credential-stores/new.hbs b/ui/admin/app/templates/scopes/scope/credential-stores/new.hbs
index cb38701d9..f6d81d7ba 100644
--- a/ui/admin/app/templates/scopes/scope/credential-stores/new.hbs
+++ b/ui/admin/app/templates/scopes/scope/credential-stores/new.hbs
@@ -14,6 +14,7 @@
@model={{@model}}
@submit={{route-action 'save' @model}}
@cancel={{route-action 'cancel' @model}}
+ @changeType={{route-action 'changeType'}}
/>