{{#if (eq kvData.length (inc index))}}
diff --git a/ui/app/templates/components/secret-create-or-update.hbs b/ui/app/templates/components/secret-create-or-update.hbs
new file mode 100644
index 000000000..771d59b09
--- /dev/null
+++ b/ui/app/templates/components/secret-create-or-update.hbs
@@ -0,0 +1,236 @@
+{{#if (eq @mode "create")}}
+
+{{/if}}
+
+{{#if (eq @mode "edit")}}
+
+{{/if}}
diff --git a/ui/app/templates/components/secret-delete-menu.hbs b/ui/app/templates/components/secret-delete-menu.hbs
index 614f50e2e..116182eca 100644
--- a/ui/app/templates/components/secret-delete-menu.hbs
+++ b/ui/app/templates/components/secret-delete-menu.hbs
@@ -1,5 +1,5 @@
{{#unless @isV2}}
- {{#if this.canDelete}}
+ {{#if this.canDeleteSecretData}}
+ type="button"
+ class="toolbar-link"
+ {{on "click" (fn (mut this.showDeleteModal false))}}
+ data-test-delete-open-modal
+ >
{{if (and (not @modelForData.deleted) (not @modelForData.destroyed)) "Delete" "Destroy"}}
{{else}}
- {{#if (or this.canDeleteAnyVersion (and this.isLatestVersion this.canDelete))}}
+ {{#if (or this.canDeleteAnyVersion (and this.isLatestVersion this.canDeleteSecretData))}}
How would you like to proceed?
{{#unless @modelForData.destroyed}}
{{#unless @modelForData.deleted}}
- {{#if this.canDelete}}
+ {{#if this.canDeleteSecretData}}
-
- {{#each @model.fields as |attr|}}
-
- {{/each}}
-
-{{/if}}
-
-{{#if @showWriteWithoutReadWarning}}
- {{#if (and @isV2 @model.failedServerRead)}}
-
- {{else if @isV2}}
-
- {{else}}
-
- {{/if}}
-{{/if}}
-
-{{#if @showAdvancedMode}}
-
-
-
-
-{{else}}
-
-{{/if}}
diff --git a/ui/app/templates/components/secret-edit-metadata.hbs b/ui/app/templates/components/secret-edit-metadata.hbs
new file mode 100644
index 000000000..3613883a9
--- /dev/null
+++ b/ui/app/templates/components/secret-edit-metadata.hbs
@@ -0,0 +1,56 @@
+
diff --git a/ui/app/templates/components/secret-edit-toolbar.hbs b/ui/app/templates/components/secret-edit-toolbar.hbs
new file mode 100644
index 000000000..e21831140
--- /dev/null
+++ b/ui/app/templates/components/secret-edit-toolbar.hbs
@@ -0,0 +1,118 @@
+
+ {{#unless (and (eq @mode 'show') @isWriteWithoutRead)}}
+
+
+ JSON
+
+
+ {{/unless}}
+
+ {{#if (eq @mode 'show')}}
+
+ {{/if}}
+ {{#if (and (eq @mode 'show') @canUpdateSecretData)}}
+ {{#let (concat 'vault.cluster.secrets.backend.' (if (eq @mode 'show') 'edit' 'show')) as |targetRoute|}}
+ {{#unless (and @isV2 (or @isWriteWithoutRead @modelForData.destroyed @modelForData.deleted))}}
+
+
+ Copy
+
+
+
+
+
+
+ {{/unless}}
+ {{/let}}
+ {{/if}}
+
+ {{#if (and (eq @mode "show") @isV2 (not @model.failedServerRead))}}
+
+ {{/if}}
+
+ {{#if (and (eq @mode 'show') @canUpdateSecretData)}}
+ {{#let (concat 'vault.cluster.secrets.backend.' (if (eq @mode 'show') 'edit' 'show')) as |targetRoute|}}
+ {{#if @isV2}}
+
+ Create new version
+
+ {{else}}
+
+ Edit secret
+
+ {{/if}}
+ {{/let}}
+ {{/if}}
+
+
\ No newline at end of file
diff --git a/ui/app/templates/components/secret-edit.hbs b/ui/app/templates/components/secret-edit.hbs
index 585485790..0fa637ff8 100644
--- a/ui/app/templates/components/secret-edit.hbs
+++ b/ui/app/templates/components/secret-edit.hbs
@@ -16,246 +16,57 @@
-
-
- {{#unless (and (eq mode 'show') isWriteWithoutRead)}}
-
-
- JSON
-
-
- {{/unless}}
-
- {{#if (eq mode 'show')}}
-
- {{/if}}
- {{#if (and (eq mode 'show') (or canEditV2Secret canEdit))}}
- {{#let (concat 'vault.cluster.secrets.backend.' (if (eq mode 'show') 'edit' 'show')) as |targetRoute|}}
- {{#unless (and isV2 (or isWriteWithoutRead modelForData.destroyed modelForData.deleted))}}
-
-
- Copy
-
-
-
-
-
-
- {{/unless}}
- {{/let}}
- {{/if}}
-
- {{#if (and (eq @mode "show") this.isV2 (not @model.failedServerRead))}}
-
- {{/if}}
-
- {{#if (and (eq mode 'show') (or canEditV2Secret canEdit))}}
- {{#let (concat 'vault.cluster.secrets.backend.' (if (eq mode 'show') 'edit' 'show')) as |targetRoute|}}
- {{#if isV2}}
-
- Create new version
-
- {{else}}
-
- Edit secret
-
+{{!-- tabs for show only --}}
+{{#if (eq mode "show")}}
+
+
+
+{{/if}}
+
+
+
+{{#if (or (eq mode "create") (eq mode "edit"))}}
+
{{else if (eq mode "show")}}
{{else}}
- {{#if @item.canRead}}
+ {{#if (or @item.canReadSecretData @item.canRead)}}
{{/if}}
{{/if}}
- {{#if @item.canEdit}}
+ {{#if (or @item.canEditSecretData @item.canEdit)}}
{{/if}}
- {{#if @item.canDelete}}
+ {{#if (or @item.canDeleteSecretData @item.canDelete)}}
+
+
+ Edit secret metadata
+
+
+
+
+{{else}}
+
+
+ View Metadata
+
+ More here
+
+{{/if}}
diff --git a/ui/app/templates/vault/cluster/secrets/backend/metadata.hbs b/ui/app/templates/vault/cluster/secrets/backend/metadata.hbs
new file mode 100644
index 000000000..476e45126
--- /dev/null
+++ b/ui/app/templates/vault/cluster/secrets/backend/metadata.hbs
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+ {{this.model.id}}
+
+
+
+{{!-- Tabs --}}
+
+
+
+
+
+ {{#if this.model.canUpdateMetadata}}
+
+
+ Edit metadata
+
+
+ {{/if}}
+
+
+
+
+
+
+ {{#each-in this.model.customMetadata as | key value|}}
+
+ {{else}}
+
+
+ Add metadata
+
+
+ {{/each-in}}
+
+
+
+
+
+
+
+
+
diff --git a/ui/lib/core/addon/templates/components/form-field.hbs b/ui/lib/core/addon/templates/components/form-field.hbs
index 39eec6e68..246376fcc 100644
--- a/ui/lib/core/addon/templates/components/form-field.hbs
+++ b/ui/lib/core/addon/templates/components/form-field.hbs
@@ -18,21 +18,21 @@
)
)
}}
-{{#unless (eq attr.type "object")}}
+ {{#unless (eq attr.type "object")}}
+ {{#if attr.options.subText}}
+ {{attr.options.subText}} {{#if attr.options.docLink}}See our documentation for help.{{/if}}
{{/if}}
-
- {{#if attr.options.subText}}
- {{attr.options.subText}} {{#if attr.options.docLink}}See our documentation for help.{{/if}}
- {{/if}}
-{{/unless}}
+ {{/unless}}
{{/unless}}
{{#if attr.options.possibleValues}}
@@ -109,6 +109,12 @@
label=labelString
warning=attr.options.warning
helpText=attr.options.helpText
+ subText=attr.options.subText
+ small-label=(if (eq mode "create") true false )
+ formSection=(if (eq mode "customMetadata") false true )
+ name=valuePath
+ onKeyUp=onKeyUp
+ validationMessages=validationMessages
}}
{{else if (eq attr.options.editType "file")}}
{{!-- File Input --}}
@@ -305,6 +311,9 @@
{{#info-tooltip}}{{attr.options.helpText}}{{/info-tooltip}}
{{/if}}
+ {{#if attr.options.subText}}
+
{{attr.options.subText}}
+ {{/if}}
{{else if (eq attr.type "object")}}
{{json-editor
diff --git a/ui/tests/acceptance/secrets/backend/kv/secret-test.js b/ui/tests/acceptance/secrets/backend/kv/secret-test.js
index 4f8a0f825..9033044a4 100644
--- a/ui/tests/acceptance/secrets/backend/kv/secret-test.js
+++ b/ui/tests/acceptance/secrets/backend/kv/secret-test.js
@@ -48,6 +48,8 @@ module('Acceptance | secrets/secret/create', function(hooks) {
await listPage.create();
await settled();
+ await editPage.toggleMetadata();
+ await settled();
assert.ok(editPage.hasMetadataFields, 'shows the metadata form');
await editPage.createSecret(path, 'foo', 'bar');
await settled();
@@ -76,19 +78,23 @@ module('Acceptance | secrets/secret/create', function(hooks) {
await settled();
await click('[data-test-secret-create="true"]');
await fillIn('[data-test-secret-path="true"]', secretPath);
- await fillIn('[data-test-input="maxVersions"]', maxVersions);
- await click('[data-test-secret-save]');
+ await editPage.toggleMetadata();
await settled();
- await click('[data-test-secret-edit="true"]');
+ await fillIn('[data-test-input="maxVersions"]', maxVersions);
+ await settled();
+ await editPage.save();
+ await settled();
+ await editPage.metadataTab();
await settled();
// convert to number for IE11 browserstack test
- let savedMaxVersions = Number(document.querySelector('[data-test-input="maxVersions"]').value);
+ let savedMaxVersions = Number(document.querySelectorAll('[data-test-value-div]')[0].innerText);
assert.equal(
maxVersions,
savedMaxVersions,
'max_version displays the saved number set when creating the secret'
);
});
+ // ARG TOD add test here that adds custom metadata
test('it disables save when validation errors occur', async function(assert) {
let enginePath = `kv-${new Date().getTime()}`;
@@ -105,8 +111,11 @@ module('Acceptance | secrets/secret/create', function(hooks) {
'when duplicate path it shows correct error message'
);
+ await editPage.toggleMetadata();
+ await settled();
document.querySelector('#maxVersions').value = 'abc';
await triggerKeyEvent('[data-test-input="maxVersions"]', 'keyup', 65);
+ await settled();
assert
.dom('[data-test-input="maxVersions"]')
.hasClass('has-error-border', 'shows border error on input with error');
@@ -577,7 +586,6 @@ module('Acceptance | secrets/secret/create', function(hooks) {
await editPage.visitEdit({ backend, id: 'secret' });
assert.notOk(editPage.hasMetadataFields, 'hides the metadata form');
- assert.ok(editPage.showsNoCASWarning, 'shows no CAS write warning');
await editPage.editSecret('bar', 'baz');
assert.equal(currentRouteName(), 'vault.cluster.secrets.backend.show', 'redirects to the show page');
@@ -596,7 +604,6 @@ module('Acceptance | secrets/secret/create', function(hooks) {
await editPage.visitEdit({ backend, id: 'secret' });
assert.notOk(editPage.hasMetadataFields, 'hides the metadata form');
- assert.ok(editPage.showsV2WriteWarning, 'shows v2 warning');
await editPage.editSecret('bar', 'baz');
assert.equal(currentRouteName(), 'vault.cluster.secrets.backend.show', 'redirects to the show page');
@@ -614,8 +621,6 @@ module('Acceptance | secrets/secret/create', function(hooks) {
assert.ok(showPage.editIsPresent, 'shows the edit button');
await editPage.visitEdit({ backend, id: 'secret' });
- assert.ok(editPage.showsV1WriteWarning, 'shows v1 warning');
-
await editPage.editSecret('bar', 'baz');
assert.equal(currentRouteName(), 'vault.cluster.secrets.backend.show', 'redirects to the show page');
});
diff --git a/ui/tests/integration/components/secret-edit-test.js b/ui/tests/integration/components/secret-edit-test.js
index 3f92b6b9b..89c1474db 100644
--- a/ui/tests/integration/components/secret-edit-test.js
+++ b/ui/tests/integration/components/secret-edit-test.js
@@ -97,6 +97,7 @@ module('Integration | Component | secret edit', function(hooks) {
});
await render(hbs`{{secret-edit mode=mode model=model preferAdvancedEdit=true }}`);
+ await settled();
let instance = this.codeMirror.instanceFor(find('[data-test-component=json-editor]').id);
instance.setValue(JSON.stringify([{ foo: 'bar' }]));
await settled();
diff --git a/ui/tests/pages/secrets/backend/kv/edit-secret.js b/ui/tests/pages/secrets/backend/kv/edit-secret.js
index 3a7a71911..9b65e0128 100644
--- a/ui/tests/pages/secrets/backend/kv/edit-secret.js
+++ b/ui/tests/pages/secrets/backend/kv/edit-secret.js
@@ -12,10 +12,9 @@ export default create({
visitEdit: visitable('/vault/secrets/:backend/edit/:id'),
visitEditRoot: visitable('/vault/secrets/:backend/edit'),
toggleJSON: clickable('[data-test-toggle-input="json"]'),
+ toggleMetadata: clickable('[data-test-show-metadata-toggle]'),
+ metadataTab: clickable('[data-test-secret-metadata-tab]'),
hasMetadataFields: isPresent('[data-test-metadata-fields]'),
- showsNoCASWarning: isPresent('[data-test-v2-no-cas-warning]'),
- showsV2WriteWarning: isPresent('[data-test-v2-write-without-read]'),
- showsV1WriteWarning: isPresent('[data-test-v1-write-without-read]'),
editor: {
fillIn: codeFillable('[data-test-component="json-editor"]'),
},