From 5908b2959c749b4763995c83d78f93efd8b14a79 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Mon, 25 Oct 2021 10:18:51 -0600 Subject: [PATCH 1/8] alert banner --- ui/app/components/secret-create-or-update.js | 11 +++++++++++ ui/app/models/secret-engine.js | 2 +- ui/app/styles/core/alert-banner.scss | 4 ++++ .../templates/components/secret-create-or-update.hbs | 7 +++++++ ui/lib/core/addon/components/alert-banner.js | 3 ++- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ui/app/components/secret-create-or-update.js b/ui/app/components/secret-create-or-update.js index 0afbad0b99024..23da15b638d0c 100644 --- a/ui/app/components/secret-create-or-update.js +++ b/ui/app/components/secret-create-or-update.js @@ -44,6 +44,7 @@ export default class SecretCreateOrUpdate extends Component { @tracked codemirrorString = null; @tracked error = null; @tracked secretPaths = null; + @tracked pathWhiteSpaceWarning = false; @tracked validationErrorCount = 0; @tracked validationMessages = null; @@ -82,6 +83,8 @@ export default class SecretCreateOrUpdate extends Component { } checkValidation(name, value) { if (name === 'path') { + // check for whitespace + this.pathHasWhiteSpace(value); !value ? set(this.validationMessages, name, `${name} can't be blank.`) : set(this.validationMessages, name, ''); @@ -106,6 +109,14 @@ export default class SecretCreateOrUpdate extends Component { this.transitionToRoute(LIST_ROOT_ROUTE); } } + pathHasWhiteSpace(value) { + let validation = new RegExp('\\s', 'g'); // search for whitespace + if (validation.test(value)) { + this.pathWhiteSpaceWarning = true; + } else { + this.pathWhiteSpaceWarning = false; + } + } // successCallback is called in the context of the component persistKey(successCallback) { let secret = this.args.model; diff --git a/ui/app/models/secret-engine.js b/ui/app/models/secret-engine.js index c40e6b0b83344..ffb31428847d1 100644 --- a/ui/app/models/secret-engine.js +++ b/ui/app/models/secret-engine.js @@ -52,7 +52,7 @@ export default Model.extend(Validations, { defaultValue: 0, label: 'Maximum number of versions', subText: - 'The number of versions to keep per key. Once the number of keys exceeds the maximum number set here, the oldest version will be permanently deleted. This value applies to all keys, but a key’s metadata settings can overwrite this value.', + 'The number of versions to keep per key. Once the number of keys exceeds the maximum number set here, the oldest version will be permanently deleted. This value applies to all keys, but a key’s metadata settings can overwrite this value. When 0 is used or the value is unset, Vault will keep 10 versions.', }), casRequired: attr('boolean', { defaultValue: false, diff --git a/ui/app/styles/core/alert-banner.scss b/ui/app/styles/core/alert-banner.scss index 9ab82281c1f2b..ac17fa2151a8e 100644 --- a/ui/app/styles/core/alert-banner.scss +++ b/ui/app/styles/core/alert-banner.scss @@ -4,3 +4,7 @@ color: $black; } + +.margin-top { + margin-top: $spacing-xs; +} diff --git a/ui/app/templates/components/secret-create-or-update.hbs b/ui/app/templates/components/secret-create-or-update.hbs index 357ecce3e7555..074b63ede62d8 100644 --- a/ui/app/templates/components/secret-create-or-update.hbs +++ b/ui/app/templates/components/secret-create-or-update.hbs @@ -28,6 +28,13 @@ The secret path may not end in /

{{/if}} + {{#if this.pathWhiteSpaceWarning}} + + {{/if}} {{#if @showAdvancedMode}}
diff --git a/ui/lib/core/addon/components/alert-banner.js b/ui/lib/core/addon/components/alert-banner.js index d6970c97383b8..a9062163809fe 100644 --- a/ui/lib/core/addon/components/alert-banner.js +++ b/ui/lib/core/addon/components/alert-banner.js @@ -17,6 +17,7 @@ import layout from '../templates/components/alert-banner'; * @param {Object} [progressBar=null] - An object containing a value and maximum for a progress bar. Will be displayed next to the message title. * @param {String} [message=null] - The message to display within the banner. * @param {String} [title=null] - A title to show above the message. If this is not provided, there are default values for each type of alert. + * @param [marginTop=false]{Boolean} - Whether or not to add margin above component. * */ @@ -29,7 +30,7 @@ export default Component.extend({ progressBar: null, yieldWithoutColumn: false, marginless: false, - classNameBindings: ['containerClass'], + classNameBindings: ['containerClass', 'marginTop:margin-top'], containerClass: computed('type', 'marginless', function() { const base = this.marginless ? 'message message-marginless ' : 'message '; From 408a3742c84f133622c64d77d0390cadce6c5053 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Mon, 25 Oct 2021 10:34:39 -0600 Subject: [PATCH 2/8] changelog --- changelog/12921.txt | 3 +++ ui/app/templates/components/secret-create-or-update.hbs | 1 + 2 files changed, 4 insertions(+) create mode 100644 changelog/12921.txt diff --git a/changelog/12921.txt b/changelog/12921.txt new file mode 100644 index 0000000000000..77bb465c67661 --- /dev/null +++ b/changelog/12921.txt @@ -0,0 +1,3 @@ +```release-note:improvement +ui: Adds warning about white space in KV secret engine. +``` diff --git a/ui/app/templates/components/secret-create-or-update.hbs b/ui/app/templates/components/secret-create-or-update.hbs index 074b63ede62d8..3ad2d9be86498 100644 --- a/ui/app/templates/components/secret-create-or-update.hbs +++ b/ui/app/templates/components/secret-create-or-update.hbs @@ -33,6 +33,7 @@ @type="warning" @message="Your secret path contains whitespace. If this is desired, you'll need to encode it with %20 in API calls and you will not be able to use the CLI." @marginTop=true + data-test-whitespace-warning /> {{/if}}
From 95ccce4a2d5db62117dc65f80153e9a7b6c8ff27 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Mon, 25 Oct 2021 10:51:10 -0600 Subject: [PATCH 3/8] test coverage --- ui/tests/acceptance/secrets/backend/kv/secret-test.js | 10 ++++++++-- ui/tests/pages/secrets/backend/kv/edit-secret.js | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ui/tests/acceptance/secrets/backend/kv/secret-test.js b/ui/tests/acceptance/secrets/backend/kv/secret-test.js index dd8b856f0615b..be9c9b890a9bc 100644 --- a/ui/tests/acceptance/secrets/backend/kv/secret-test.js +++ b/ui/tests/acceptance/secrets/backend/kv/secret-test.js @@ -440,7 +440,7 @@ module('Acceptance | secrets/secret/create', function(hooks) { } }); - test('create secret with space shows version data', async function(assert) { + test('create secret with space shows version data and shows space warning', async function(assert) { let enginePath = `kv-${new Date().getTime()}`; let secretPath = 'space space'; // mount version 2 @@ -452,7 +452,13 @@ module('Acceptance | secrets/secret/create', function(hooks) { .submit(); await settled(); await listPage.create(); - await editPage.createSecret(secretPath, 'foo', 'bar'); + await editPage.createSecretDontSave(secretPath, 'foo', 'bar'); + // to trigger warning need to hit keyup on the secret path + await triggerKeyEvent('[data-test-secret-path="true"]', 'keyup', 65); + await settled(); + assert.dom('[data-test-whitespace-warning]').exists('renders warning about their being a space'); + await settled(); + await click('[data-test-secret-save="true"]'); await settled(); await click('[data-test-popup-menu-trigger="version"]'); 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 a5de4f320ddc8..794979b48446f 100644 --- a/ui/tests/pages/secrets/backend/kv/edit-secret.js +++ b/ui/tests/pages/secrets/backend/kv/edit-secret.js @@ -29,6 +29,11 @@ export default create({ .secretValue(value) .save(); }, + createSecretDontSave: async function(path, key, value) { + return this.path(path) + .secretKey(key) + .secretValue(value); + }, createSecretWithMetadata: async function(path, key, value, maxVersion) { return this.path(path) .secretKey(key) From 26adc01cc47698372207ea051a2fe7c41e0dab5e Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Mon, 25 Oct 2021 10:53:21 -0600 Subject: [PATCH 4/8] amend message --- ui/app/templates/components/secret-create-or-update.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/templates/components/secret-create-or-update.hbs b/ui/app/templates/components/secret-create-or-update.hbs index 3ad2d9be86498..e1a7c217ab0ba 100644 --- a/ui/app/templates/components/secret-create-or-update.hbs +++ b/ui/app/templates/components/secret-create-or-update.hbs @@ -31,7 +31,7 @@ {{#if this.pathWhiteSpaceWarning}} From fda90a69fff2cb75c43dd968ed8bfe7edb0fcc3e Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Thu, 28 Oct 2021 09:57:50 -0600 Subject: [PATCH 5/8] address pr comments --- ui/app/components/secret-create-or-update.js | 6 +----- ui/app/styles/core/alert-banner.scss | 4 ---- .../components/secret-create-or-update.hbs | 13 +++++++------ ui/lib/core/addon/components/alert-banner.js | 3 +-- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/ui/app/components/secret-create-or-update.js b/ui/app/components/secret-create-or-update.js index 23da15b638d0c..310996389b9cb 100644 --- a/ui/app/components/secret-create-or-update.js +++ b/ui/app/components/secret-create-or-update.js @@ -111,11 +111,7 @@ export default class SecretCreateOrUpdate extends Component { } pathHasWhiteSpace(value) { let validation = new RegExp('\\s', 'g'); // search for whitespace - if (validation.test(value)) { - this.pathWhiteSpaceWarning = true; - } else { - this.pathWhiteSpaceWarning = false; - } + this.pathWhiteSpaceWarning = validation.test(value); } // successCallback is called in the context of the component persistKey(successCallback) { diff --git a/ui/app/styles/core/alert-banner.scss b/ui/app/styles/core/alert-banner.scss index ac17fa2151a8e..9ab82281c1f2b 100644 --- a/ui/app/styles/core/alert-banner.scss +++ b/ui/app/styles/core/alert-banner.scss @@ -4,7 +4,3 @@ color: $black; } - -.margin-top { - margin-top: $spacing-xs; -} diff --git a/ui/app/templates/components/secret-create-or-update.hbs b/ui/app/templates/components/secret-create-or-update.hbs index e1a7c217ab0ba..3858cad341db3 100644 --- a/ui/app/templates/components/secret-create-or-update.hbs +++ b/ui/app/templates/components/secret-create-or-update.hbs @@ -29,12 +29,13 @@

{{/if}} {{#if this.pathWhiteSpaceWarning}} - +
+ +
{{/if}} {{#if @showAdvancedMode}} diff --git a/ui/lib/core/addon/components/alert-banner.js b/ui/lib/core/addon/components/alert-banner.js index a9062163809fe..d6970c97383b8 100644 --- a/ui/lib/core/addon/components/alert-banner.js +++ b/ui/lib/core/addon/components/alert-banner.js @@ -17,7 +17,6 @@ import layout from '../templates/components/alert-banner'; * @param {Object} [progressBar=null] - An object containing a value and maximum for a progress bar. Will be displayed next to the message title. * @param {String} [message=null] - The message to display within the banner. * @param {String} [title=null] - A title to show above the message. If this is not provided, there are default values for each type of alert. - * @param [marginTop=false]{Boolean} - Whether or not to add margin above component. * */ @@ -30,7 +29,7 @@ export default Component.extend({ progressBar: null, yieldWithoutColumn: false, marginless: false, - classNameBindings: ['containerClass', 'marginTop:margin-top'], + classNameBindings: ['containerClass'], containerClass: computed('type', 'marginless', function() { const base = this.marginless ? 'message message-marginless ' : 'message '; From ac832542f031fe2fcce5ec65d6c41c94114cc19d Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Thu, 28 Oct 2021 10:24:06 -0600 Subject: [PATCH 6/8] whoops --- ui/app/json-example.json | 7 + ui/app/modifiers/code-mirror.js | 79 ++++++++ ui/app/services/code-mirror.js | 20 +++ ui/app/styles/components/json-editor.scss | 169 ++++++++++++++++++ .../components/secret-create-or-update.hbs | 3 +- 5 files changed, 277 insertions(+), 1 deletion(-) create mode 100644 ui/app/json-example.json create mode 100644 ui/app/modifiers/code-mirror.js create mode 100644 ui/app/services/code-mirror.js create mode 100644 ui/app/styles/components/json-editor.scss diff --git a/ui/app/json-example.json b/ui/app/json-example.json new file mode 100644 index 0000000000000..6a00b999b71bf --- /dev/null +++ b/ui/app/json-example.json @@ -0,0 +1,7 @@ +{ + "languages": { + "+2": "blah", + "_t": "a", + "_2": "b" + } +} \ No newline at end of file diff --git a/ui/app/modifiers/code-mirror.js b/ui/app/modifiers/code-mirror.js new file mode 100644 index 0000000000000..b6355269ab0b6 --- /dev/null +++ b/ui/app/modifiers/code-mirror.js @@ -0,0 +1,79 @@ +import { getOwner } from '@ember/application'; +import { guidFor } from '@ember/object/internals'; +import Modifier from 'ember-modifier'; +import codemirror from 'codemirror'; +import 'codemirror/addon/edit/matchbrackets'; +import 'codemirror/addon/selection/active-line'; +import 'codemirror/mode/javascript/javascript'; +import 'codemirror/mode/ruby/ruby'; +// import '@hashicorp/sentinel-codemirror/sentinel'; +import 'codemirror/keymap/sublime'; +import 'codemirror/addon/search/search'; +import 'codemirror/addon/search/searchcursor'; +import 'codemirror/addon/dialog/dialog'; + +export default class CodeMirrorModifier extends Modifier { + get cmService() { + return getOwner(this).lookup('service:code-mirror'); + } + + didInstall() { + this._setup(); + } + + willRemove() { + this._cleanup(); + } + + didUpdateArguments() { + if (this._editor.getValue() !== this.args.named.value) { + this._editor.setValue(this.args.named.value); + } + } + + _onChange(editor) { + if (this.args.named.valueUpdated) { + this.args.named.valueUpdated(editor.getValue()); + } + } + + _setup() { + if (!this.element) { + throw new Error('CodeMirror modifier has no element'); + } + + // Assign an ID to this element if there is none. This is to + // ensure that there are unique IDs in the code-mirror service + // registry. + if (!this.element.id) { + this.element.id = guidFor(this.element); + } + + let editor = codemirror( + this.element, + Object.assign( + { + value: this.args.named.value ? this.args.named.value : '', + inputStyle: 'contenteditable', + }, + this.args.named.options + ) + ); + + editor.on('change', editor => { + this._onChange(editor); + }); + + if (this.cmService) { + this.cmService.registerInstance(this.element.id, editor); + } + + this._editor = editor; + } + + _cleanup() { + if (this.cmService) { + this.cmService.unregisterInstance(this.element.id); + } + } +} diff --git a/ui/app/services/code-mirror.js b/ui/app/services/code-mirror.js new file mode 100644 index 0000000000000..52f0ec78eb354 --- /dev/null +++ b/ui/app/services/code-mirror.js @@ -0,0 +1,20 @@ +import Service from '@ember/service'; + +// This service chiefly exists now for testing purposes. +export default class CodeMirror extends Service { + _instances = Object.create(null); + + instanceFor(id) { + return this._instances[id]; + } + + registerInstance(id, instance) { + this._instances[id] = instance; + + return instance; + } + + unregisterInstance(id) { + delete this._instances[id]; + } +} diff --git a/ui/app/styles/components/json-editor.scss b/ui/app/styles/components/json-editor.scss new file mode 100644 index 0000000000000..effac581dad19 --- /dev/null +++ b/ui/app/styles/components/json-editor.scss @@ -0,0 +1,169 @@ +// Prevent jsondiffpatch output from expanding its container +.jsondiffpatch-node { + pre, + .jsondiffpatch-textdiff-deleted, + .jsondiffpatch-textdiff-added { + white-space: pre-wrap; + word-break: break-all; + } +} + +// Standardize on the same monospace font used elsewhere +.jsondiffpatch-delta, +.jsondiffpatch-delta pre { + font: 1rem/1.4 $family-monospace !important; +} + +.json-editor-toolbar { + background-color: blue; +} + +.jsondiffpatch-delta { + font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Courier, monospace; + font-size: 12px; + margin: 0; + padding: 0 0 0 12px; + display: inline-block; +} +.jsondiffpatch-delta pre { + font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Courier, monospace; + font-size: 12px; + margin: 0; + padding: 0; + display: inline-block; +} +ul.jsondiffpatch-delta { + list-style-type: none; + padding: 0 0 0 20px; + margin: 0; +} +.jsondiffpatch-delta ul { + list-style-type: none; + padding: 0 0 0 20px; + margin: 0; +} +.jsondiffpatch-added .jsondiffpatch-property-name, +.jsondiffpatch-added .jsondiffpatch-value pre, +.jsondiffpatch-modified .jsondiffpatch-right-value pre, +.jsondiffpatch-textdiff-added { + background: #bbffbb; +} +.jsondiffpatch-deleted .jsondiffpatch-property-name, +.jsondiffpatch-deleted pre, +.jsondiffpatch-modified .jsondiffpatch-left-value pre, +.jsondiffpatch-textdiff-deleted { + background: #ffbbbb; + text-decoration: line-through; +} +.jsondiffpatch-unchanged, +.jsondiffpatch-movedestination { + color: gray; +} +.jsondiffpatch-unchanged, +.jsondiffpatch-movedestination > .jsondiffpatch-value { + transition: all 0.5s; + -webkit-transition: all 0.5s; + overflow-y: hidden; +} +.jsondiffpatch-unchanged-showing .jsondiffpatch-unchanged, +.jsondiffpatch-unchanged-showing .jsondiffpatch-movedestination > .jsondiffpatch-value { + max-height: 100px; +} +.jsondiffpatch-unchanged-hidden .jsondiffpatch-unchanged, +.jsondiffpatch-unchanged-hidden .jsondiffpatch-movedestination > .jsondiffpatch-value { + max-height: 0; +} +.jsondiffpatch-unchanged-hiding .jsondiffpatch-movedestination > .jsondiffpatch-value, +.jsondiffpatch-unchanged-hidden .jsondiffpatch-movedestination > .jsondiffpatch-value { + display: block; +} +.jsondiffpatch-unchanged-visible .jsondiffpatch-unchanged, +.jsondiffpatch-unchanged-visible .jsondiffpatch-movedestination > .jsondiffpatch-value { + max-height: 100px; +} +.jsondiffpatch-unchanged-hiding .jsondiffpatch-unchanged, +.jsondiffpatch-unchanged-hiding .jsondiffpatch-movedestination > .jsondiffpatch-value { + max-height: 0; +} +.jsondiffpatch-unchanged-showing .jsondiffpatch-arrow, +.jsondiffpatch-unchanged-hiding .jsondiffpatch-arrow { + display: none; +} +.jsondiffpatch-value { + display: inline-block; +} +.jsondiffpatch-property-name { + display: inline-block; + padding-right: 5px; + vertical-align: top; +} +.jsondiffpatch-property-name:after { + content: ': '; +} +.jsondiffpatch-child-node-type-array > .jsondiffpatch-property-name:after { + content: ': ['; +} +.jsondiffpatch-child-node-type-array:after { + content: '],'; +} +div.jsondiffpatch-child-node-type-array:before { + content: '['; +} +div.jsondiffpatch-child-node-type-array:after { + content: ']'; +} +.jsondiffpatch-child-node-type-object > .jsondiffpatch-property-name:after { + content: ': {'; +} +.jsondiffpatch-child-node-type-object:after { + content: '},'; +} +div.jsondiffpatch-child-node-type-object:before { + content: '{'; +} +div.jsondiffpatch-child-node-type-object:after { + content: '}'; +} +.jsondiffpatch-value pre:after { + content: ','; +} +li:last-child > .jsondiffpatch-value pre:after, +.jsondiffpatch-modified > .jsondiffpatch-left-value pre:after { + content: ''; +} +.jsondiffpatch-modified .jsondiffpatch-value { + display: inline-block; +} +.jsondiffpatch-modified .jsondiffpatch-right-value { + margin-left: 5px; +} +.jsondiffpatch-moved .jsondiffpatch-value { + display: none; +} +.jsondiffpatch-moved .jsondiffpatch-moved-destination { + display: inline-block; + background: #ffffbb; + color: #888; +} +.jsondiffpatch-moved .jsondiffpatch-moved-destination:before { + content: ' => '; +} +ul.jsondiffpatch-textdiff { + padding: 0; +} +.jsondiffpatch-textdiff-location { + color: #bbb; + display: inline-block; + min-width: 60px; +} +.jsondiffpatch-textdiff-line { + display: inline-block; +} +.jsondiffpatch-textdiff-line-number:after { + content: ','; +} +.jsondiffpatch-error { + background: red; + color: white; + font-weight: bold; +} diff --git a/ui/app/templates/components/secret-create-or-update.hbs b/ui/app/templates/components/secret-create-or-update.hbs index 3858cad341db3..965a4039371aa 100644 --- a/ui/app/templates/components/secret-create-or-update.hbs +++ b/ui/app/templates/components/secret-create-or-update.hbs @@ -33,7 +33,8 @@ {{/if}} From 4cb7e69fc48092436c5ba8dfb5e28b976e9b6ba7 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Thu, 28 Oct 2021 10:25:23 -0600 Subject: [PATCH 7/8] Revert "whoops" This reverts commit ac832542f031fe2fcce5ec65d6c41c94114cc19d. --- ui/app/json-example.json | 7 - ui/app/modifiers/code-mirror.js | 79 -------- ui/app/services/code-mirror.js | 20 --- ui/app/styles/components/json-editor.scss | 169 ------------------ .../components/secret-create-or-update.hbs | 3 +- 5 files changed, 1 insertion(+), 277 deletions(-) delete mode 100644 ui/app/json-example.json delete mode 100644 ui/app/modifiers/code-mirror.js delete mode 100644 ui/app/services/code-mirror.js delete mode 100644 ui/app/styles/components/json-editor.scss diff --git a/ui/app/json-example.json b/ui/app/json-example.json deleted file mode 100644 index 6a00b999b71bf..0000000000000 --- a/ui/app/json-example.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "languages": { - "+2": "blah", - "_t": "a", - "_2": "b" - } -} \ No newline at end of file diff --git a/ui/app/modifiers/code-mirror.js b/ui/app/modifiers/code-mirror.js deleted file mode 100644 index b6355269ab0b6..0000000000000 --- a/ui/app/modifiers/code-mirror.js +++ /dev/null @@ -1,79 +0,0 @@ -import { getOwner } from '@ember/application'; -import { guidFor } from '@ember/object/internals'; -import Modifier from 'ember-modifier'; -import codemirror from 'codemirror'; -import 'codemirror/addon/edit/matchbrackets'; -import 'codemirror/addon/selection/active-line'; -import 'codemirror/mode/javascript/javascript'; -import 'codemirror/mode/ruby/ruby'; -// import '@hashicorp/sentinel-codemirror/sentinel'; -import 'codemirror/keymap/sublime'; -import 'codemirror/addon/search/search'; -import 'codemirror/addon/search/searchcursor'; -import 'codemirror/addon/dialog/dialog'; - -export default class CodeMirrorModifier extends Modifier { - get cmService() { - return getOwner(this).lookup('service:code-mirror'); - } - - didInstall() { - this._setup(); - } - - willRemove() { - this._cleanup(); - } - - didUpdateArguments() { - if (this._editor.getValue() !== this.args.named.value) { - this._editor.setValue(this.args.named.value); - } - } - - _onChange(editor) { - if (this.args.named.valueUpdated) { - this.args.named.valueUpdated(editor.getValue()); - } - } - - _setup() { - if (!this.element) { - throw new Error('CodeMirror modifier has no element'); - } - - // Assign an ID to this element if there is none. This is to - // ensure that there are unique IDs in the code-mirror service - // registry. - if (!this.element.id) { - this.element.id = guidFor(this.element); - } - - let editor = codemirror( - this.element, - Object.assign( - { - value: this.args.named.value ? this.args.named.value : '', - inputStyle: 'contenteditable', - }, - this.args.named.options - ) - ); - - editor.on('change', editor => { - this._onChange(editor); - }); - - if (this.cmService) { - this.cmService.registerInstance(this.element.id, editor); - } - - this._editor = editor; - } - - _cleanup() { - if (this.cmService) { - this.cmService.unregisterInstance(this.element.id); - } - } -} diff --git a/ui/app/services/code-mirror.js b/ui/app/services/code-mirror.js deleted file mode 100644 index 52f0ec78eb354..0000000000000 --- a/ui/app/services/code-mirror.js +++ /dev/null @@ -1,20 +0,0 @@ -import Service from '@ember/service'; - -// This service chiefly exists now for testing purposes. -export default class CodeMirror extends Service { - _instances = Object.create(null); - - instanceFor(id) { - return this._instances[id]; - } - - registerInstance(id, instance) { - this._instances[id] = instance; - - return instance; - } - - unregisterInstance(id) { - delete this._instances[id]; - } -} diff --git a/ui/app/styles/components/json-editor.scss b/ui/app/styles/components/json-editor.scss deleted file mode 100644 index effac581dad19..0000000000000 --- a/ui/app/styles/components/json-editor.scss +++ /dev/null @@ -1,169 +0,0 @@ -// Prevent jsondiffpatch output from expanding its container -.jsondiffpatch-node { - pre, - .jsondiffpatch-textdiff-deleted, - .jsondiffpatch-textdiff-added { - white-space: pre-wrap; - word-break: break-all; - } -} - -// Standardize on the same monospace font used elsewhere -.jsondiffpatch-delta, -.jsondiffpatch-delta pre { - font: 1rem/1.4 $family-monospace !important; -} - -.json-editor-toolbar { - background-color: blue; -} - -.jsondiffpatch-delta { - font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Courier, monospace; - font-size: 12px; - margin: 0; - padding: 0 0 0 12px; - display: inline-block; -} -.jsondiffpatch-delta pre { - font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Courier, monospace; - font-size: 12px; - margin: 0; - padding: 0; - display: inline-block; -} -ul.jsondiffpatch-delta { - list-style-type: none; - padding: 0 0 0 20px; - margin: 0; -} -.jsondiffpatch-delta ul { - list-style-type: none; - padding: 0 0 0 20px; - margin: 0; -} -.jsondiffpatch-added .jsondiffpatch-property-name, -.jsondiffpatch-added .jsondiffpatch-value pre, -.jsondiffpatch-modified .jsondiffpatch-right-value pre, -.jsondiffpatch-textdiff-added { - background: #bbffbb; -} -.jsondiffpatch-deleted .jsondiffpatch-property-name, -.jsondiffpatch-deleted pre, -.jsondiffpatch-modified .jsondiffpatch-left-value pre, -.jsondiffpatch-textdiff-deleted { - background: #ffbbbb; - text-decoration: line-through; -} -.jsondiffpatch-unchanged, -.jsondiffpatch-movedestination { - color: gray; -} -.jsondiffpatch-unchanged, -.jsondiffpatch-movedestination > .jsondiffpatch-value { - transition: all 0.5s; - -webkit-transition: all 0.5s; - overflow-y: hidden; -} -.jsondiffpatch-unchanged-showing .jsondiffpatch-unchanged, -.jsondiffpatch-unchanged-showing .jsondiffpatch-movedestination > .jsondiffpatch-value { - max-height: 100px; -} -.jsondiffpatch-unchanged-hidden .jsondiffpatch-unchanged, -.jsondiffpatch-unchanged-hidden .jsondiffpatch-movedestination > .jsondiffpatch-value { - max-height: 0; -} -.jsondiffpatch-unchanged-hiding .jsondiffpatch-movedestination > .jsondiffpatch-value, -.jsondiffpatch-unchanged-hidden .jsondiffpatch-movedestination > .jsondiffpatch-value { - display: block; -} -.jsondiffpatch-unchanged-visible .jsondiffpatch-unchanged, -.jsondiffpatch-unchanged-visible .jsondiffpatch-movedestination > .jsondiffpatch-value { - max-height: 100px; -} -.jsondiffpatch-unchanged-hiding .jsondiffpatch-unchanged, -.jsondiffpatch-unchanged-hiding .jsondiffpatch-movedestination > .jsondiffpatch-value { - max-height: 0; -} -.jsondiffpatch-unchanged-showing .jsondiffpatch-arrow, -.jsondiffpatch-unchanged-hiding .jsondiffpatch-arrow { - display: none; -} -.jsondiffpatch-value { - display: inline-block; -} -.jsondiffpatch-property-name { - display: inline-block; - padding-right: 5px; - vertical-align: top; -} -.jsondiffpatch-property-name:after { - content: ': '; -} -.jsondiffpatch-child-node-type-array > .jsondiffpatch-property-name:after { - content: ': ['; -} -.jsondiffpatch-child-node-type-array:after { - content: '],'; -} -div.jsondiffpatch-child-node-type-array:before { - content: '['; -} -div.jsondiffpatch-child-node-type-array:after { - content: ']'; -} -.jsondiffpatch-child-node-type-object > .jsondiffpatch-property-name:after { - content: ': {'; -} -.jsondiffpatch-child-node-type-object:after { - content: '},'; -} -div.jsondiffpatch-child-node-type-object:before { - content: '{'; -} -div.jsondiffpatch-child-node-type-object:after { - content: '}'; -} -.jsondiffpatch-value pre:after { - content: ','; -} -li:last-child > .jsondiffpatch-value pre:after, -.jsondiffpatch-modified > .jsondiffpatch-left-value pre:after { - content: ''; -} -.jsondiffpatch-modified .jsondiffpatch-value { - display: inline-block; -} -.jsondiffpatch-modified .jsondiffpatch-right-value { - margin-left: 5px; -} -.jsondiffpatch-moved .jsondiffpatch-value { - display: none; -} -.jsondiffpatch-moved .jsondiffpatch-moved-destination { - display: inline-block; - background: #ffffbb; - color: #888; -} -.jsondiffpatch-moved .jsondiffpatch-moved-destination:before { - content: ' => '; -} -ul.jsondiffpatch-textdiff { - padding: 0; -} -.jsondiffpatch-textdiff-location { - color: #bbb; - display: inline-block; - min-width: 60px; -} -.jsondiffpatch-textdiff-line { - display: inline-block; -} -.jsondiffpatch-textdiff-line-number:after { - content: ','; -} -.jsondiffpatch-error { - background: red; - color: white; - font-weight: bold; -} diff --git a/ui/app/templates/components/secret-create-or-update.hbs b/ui/app/templates/components/secret-create-or-update.hbs index 965a4039371aa..3858cad341db3 100644 --- a/ui/app/templates/components/secret-create-or-update.hbs +++ b/ui/app/templates/components/secret-create-or-update.hbs @@ -33,8 +33,7 @@ {{/if}} From 95f6025c7b1e182f6910118b8b3eec28bbb452ec Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Thu, 28 Oct 2021 10:25:59 -0600 Subject: [PATCH 8/8] whoops again --- ui/app/templates/components/secret-create-or-update.hbs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/app/templates/components/secret-create-or-update.hbs b/ui/app/templates/components/secret-create-or-update.hbs index 3858cad341db3..965a4039371aa 100644 --- a/ui/app/templates/components/secret-create-or-update.hbs +++ b/ui/app/templates/components/secret-create-or-update.hbs @@ -33,7 +33,8 @@ {{/if}}