From 08eaac1ac0a8b7ba04c59904915a001be3f96130 Mon Sep 17 00:00:00 2001 From: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:50:22 -0600 Subject: [PATCH 1/8] UI: KV version 2 advanced secret updates (#25235) * Add obfuscation for JSON values on KV data view * Show JSON editor by default if secret data is complex, but do not disable JSON toggle * Add text object warning to kv object editor * a11y fix: do not disable show diff toggle * test and language cleanup * update language * Update tests for expected behavior * language! * Add changelog --- changelog/25235.txt | 3 + ui/lib/core/addon/components/json-editor.hbs | 8 ++ ui/lib/core/addon/components/json-editor.js | 11 ++ .../addon/components/kv-object-editor.hbs | 12 +- .../core/addon/components/kv-object-editor.js | 30 ++--- ui/lib/core/addon/utils/advanced-secret.js | 20 +++ ui/lib/kv/addon/components/kv-data-fields.hbs | 2 + .../addon/components/page/secret/details.hbs | 5 +- .../addon/components/page/secret/details.js | 6 +- .../kv/addon/components/page/secret/edit.hbs | 12 +- .../kv/addon/components/page/secret/edit.js | 6 +- .../kv/kv-v2-workflow-edge-cases-test.js | 2 +- ui/tests/helpers/kv/kv-selectors.js | 1 + .../components/json-editor-test.js | 21 +++ .../components/kv-object-editor-test.js | 13 ++ .../components/kv/kv-data-fields-test.js | 6 +- .../kv/page/kv-page-secret-details-test.js | 6 +- .../kv/page/kv-page-secret-edit-test.js | 2 +- ui/tests/unit/utils/advanced-secret-test.js | 124 ++++++++++++++---- 19 files changed, 227 insertions(+), 63 deletions(-) create mode 100644 changelog/25235.txt diff --git a/changelog/25235.txt b/changelog/25235.txt new file mode 100644 index 000000000000..d4df23ebf49b --- /dev/null +++ b/changelog/25235.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Do not disable JSON display toggle for KV version 2 secrets +``` \ No newline at end of file diff --git a/ui/lib/core/addon/components/json-editor.hbs b/ui/lib/core/addon/components/json-editor.hbs index c92b5dd3f2d2..b9ac08404543 100644 --- a/ui/lib/core/addon/components/json-editor.hbs +++ b/ui/lib/core/addon/components/json-editor.hbs @@ -27,6 +27,14 @@ {{/if}} + {{#if (and @allowObscure @readOnly)}} + {{! For safety we only use obscured values in readonly mode }} +
+ + Reveal values + +
+ {{/if}}
@@ -71,7 +70,7 @@ {{/if}} - {{#if (includes index this.whitespaceWarningRows)}} + {{#if (this.showWhitespaceWarning row.name)}}
{{/if}} + {{#if (this.showNonStringWarning row.value)}} +
+ +
+ {{/if}} {{/each}} {{#if this.hasDuplicateKeys}} diff --git a/ui/lib/core/addon/components/kv-object-editor.js b/ui/lib/core/addon/components/kv-object-editor.js index 40d0f3974f56..7fd7d17234ec 100644 --- a/ui/lib/core/addon/components/kv-object-editor.js +++ b/ui/lib/core/addon/components/kv-object-editor.js @@ -9,7 +9,6 @@ import { isNone } from '@ember/utils'; import { assert } from '@ember/debug'; import { action } from '@ember/object'; import { guidFor } from '@ember/object/internals'; -import { A } from '@ember/array'; import KVObject from 'vault/lib/kv-object'; /** @@ -26,7 +25,7 @@ import KVObject from 'vault/lib/kv-object'; * ``` * @param {string} value - the value is captured from the model. * @param {function} onChange - function that captures the value on change - * @param {boolean} [isMasked = false] - when true the renders instead of the default