From 5c4d4d454b7d2189faba6913b81f9dafdd5a5e00 Mon Sep 17 00:00:00 2001 From: hashishaw Date: Mon, 24 May 2021 13:34:51 -0500 Subject: [PATCH 1/7] Add optional restore default button on json form field, and use in database connections/roles --- ui/app/models/database/connection.js | 2 +- ui/app/models/database/role.js | 2 ++ .../addon/templates/components/form-field.hbs | 23 +++++++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/ui/app/models/database/connection.js b/ui/app/models/database/connection.js index aeda7b28d7b4..e82dc5904d38 100644 --- a/ui/app/models/database/connection.js +++ b/ui/app/models/database/connection.js @@ -198,10 +198,10 @@ export default Model.extend({ port: attr('string', {}), write_concern: attr('string', { subText: 'Optional. Must be in JSON. See our documentation for help.', + allowReset: true, editType: 'json', theme: 'hashi short', defaultShown: 'Default', - // defaultValue: '# For example: { "wmode": "majority", "wtimeout": 5000 }', }), username_template: attr('string', { editType: 'optionalText', diff --git a/ui/app/models/database/role.js b/ui/app/models/database/role.js index 06416ba98575..18f2b9572bf4 100644 --- a/ui/app/models/database/role.js +++ b/ui/app/models/database/role.js @@ -69,11 +69,13 @@ export default Model.extend({ }), creation_statement: attr('string', { editType: 'json', + allowReset: true, theme: 'hashi short', defaultShown: 'Default', }), revocation_statement: attr('string', { editType: 'json', + allowReset: true, theme: 'hashi short', defaultShown: 'Default', }), diff --git a/ui/lib/core/addon/templates/components/form-field.hbs b/ui/lib/core/addon/templates/components/form-field.hbs index ac2118aa4b8d..5e2e8eeb1f43 100644 --- a/ui/lib/core/addon/templates/components/form-field.hbs +++ b/ui/lib/core/addon/templates/components/form-field.hbs @@ -213,9 +213,6 @@ @spellcheck="false" /> {{else if (eq attr.options.editType "json")}} {{!-- JSON Editor --}} - {{#if attr.options.subText}} -

{{attr.options.subText}} {{#if attr.options.docLink}}See our documentation for help.{{/if}}

- {{/if}} + > + {{#if attr.options.allowReset}} + + {{/if}} + + {{#if attr.options.subText}} +

{{attr.options.subText}} {{#if attr.options.docLink}}See our documentation for help.{{/if}}

+ {{/if}} {{else}} {{!-- Regular Text Input --}} Date: Wed, 26 May 2021 13:10:38 -0500 Subject: [PATCH 2/7] Update language on JSON button to clear --- ui/lib/core/addon/templates/components/form-field.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/lib/core/addon/templates/components/form-field.hbs b/ui/lib/core/addon/templates/components/form-field.hbs index 5e2e8eeb1f43..3dfb3e242a1c 100644 --- a/ui/lib/core/addon/templates/components/form-field.hbs +++ b/ui/lib/core/addon/templates/components/form-field.hbs @@ -237,7 +237,7 @@ null }} > - Restore default + Clear