diff --git a/changelog/11500.txt b/changelog/11500.txt new file mode 100644 index 000000000..e242c6f18 --- /dev/null +++ b/changelog/11500.txt @@ -0,0 +1,3 @@ +```release-note:improvement +ui: Updated ivy code mirror component for consistency +``` \ No newline at end of file diff --git a/ui/app/components/json-editor.js b/ui/app/components/json-editor.js index 48cea1bc6..e77f41b73 100644 --- a/ui/app/components/json-editor.js +++ b/ui/app/components/json-editor.js @@ -1,5 +1,5 @@ -import { assign } from '@ember/polyfills'; -import IvyCodemirrorComponent from './ivy-codemirror'; +import Component from '@ember/component'; + const JSON_EDITOR_DEFAULTS = { // IMPORTANT: `gutters` must come before `lint` since the presence of // `gutters` is cached internally when `lint` is toggled @@ -13,19 +13,41 @@ const JSON_EDITOR_DEFAULTS = { showCursorWhenSelecting: true, }; -export default IvyCodemirrorComponent.extend({ - 'data-test-component': 'json-editor', - updateCodeMirrorOptions() { - const options = assign({}, JSON_EDITOR_DEFAULTS, this.options); - if (options.autoHeight) { - options.viewportMargin = Infinity; - delete options.autoHeight; - } +export default Component.extend({ + showToolbar: true, + title: null, + subTitle: null, + helpText: null, + value: null, + options: null, + valueUpdated: null, + onFocusOut: null, + readOnly: false, - if (options) { - Object.keys(options).forEach(function(option) { - this.updateCodeMirrorOption(option, options[option]); - }, this); + init() { + this._super(...arguments); + this.options = { ...JSON_EDITOR_DEFAULTS, ...this.options }; + if (this.options.autoHeight) { + this.options.viewportMargin = Infinity; + delete this.options.autoHeight; + } + if (this.options.readOnly) { + this.options.readOnly = 'nocursor'; + this.options.lineNumbers = false; + delete this.options.gutters; } }, + + actions: { + updateValue(...args) { + if (this.valueUpdated) { + this.valueUpdated(...args); + } + }, + onFocus(...args) { + if (this.onFocusOut) { + this.onFocusOut(...args); + } + }, + }, }); diff --git a/ui/app/models/role-aws.js b/ui/app/models/role-aws.js index 422499b5a..6e5c425d7 100644 --- a/ui/app/models/role-aws.js +++ b/ui/app/models/role-aws.js @@ -49,6 +49,8 @@ export default Model.extend({ }), policyDocument: attr('string', { editType: 'json', + helpText: + 'A policy is an object in AWS that, when associated with an identity or resource, defines their permissions.', }), fields: computed('credentialType', function() { let credentialType = this.credentialType; diff --git a/ui/app/templates/components/console/log-json.hbs b/ui/app/templates/components/console/log-json.hbs index 36f94cb68..a923ea025 100644 --- a/ui/app/templates/components/console/log-json.hbs +++ b/ui/app/templates/components/console/log-json.hbs @@ -1,5 +1,5 @@
+{{/if}} +{{ivy-codemirror + data-test-component="json-editor" + value=value + options=options + valueUpdated=(action "updateValue") + onFocusOut=(action "onFocus") +}} +{{#if helpText }} +{{ helpText }}
+You can decrypt ciphertext using {{key.name}}
as the encryption key.
Check whether the provided signature is valid for the given data.
- You can use Alt+Tab (Option+Tab on MacOS) in the code editor to skip to the next field -
-