From 675ec0aae6b51e3f372b0bb768859cdb17a2eea6 Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Thu, 7 Oct 2021 10:58:04 -0700 Subject: [PATCH 01/17] adds note --- ui/app/serializers/database/connection.js | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ui/app/serializers/database/connection.js b/ui/app/serializers/database/connection.js index 20982af03568a..935a920a0b977 100644 --- a/ui/app/serializers/database/connection.js +++ b/ui/app/serializers/database/connection.js @@ -45,4 +45,28 @@ export default RESTSerializer.extend({ } return this._super(store, primaryModelClass, transformedPayload, id, requestType); }, + + // add serialize function this._super + // serialize(snapshot, requestType) { + // let data = this._super(snapshot, requestType); + // if (data.database) { + // const db = data.database[0]; + // data.db_name = db; + // delete data.database; + // } + // // This is necessary because the input for MongoDB is a json string + // // rather than an array, so we transpose that here + // if (data.creation_statement) { + // const singleStatement = data.creation_statement; + // data.creation_statements = [singleStatement]; + // delete data.creation_statement; + // } + // if (data.revocation_statement) { + // const singleStatement = data.revocation_statement; + // data.revocation_statements = [singleStatement]; + // delete data.revocation_statement; + // } + + // return data; + // }, }); From 5659155a7887536a4ee6fb14b1ef7ffa8b727e42 Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Thu, 7 Oct 2021 17:31:55 -0700 Subject: [PATCH 02/17] creates serializer and moves available plugin types constant to util --- ui/app/models/database/connection.js | 140 +--------------------- ui/app/serializers/database/connection.js | 37 +++--- ui/app/utils/database-role-fields.js | 139 +++++++++++++++++++++ 3 files changed, 155 insertions(+), 161 deletions(-) diff --git a/ui/app/models/database/connection.js b/ui/app/models/database/connection.js index 86ba691e0feea..3887663198bd7 100644 --- a/ui/app/models/database/connection.js +++ b/ui/app/models/database/connection.js @@ -3,145 +3,7 @@ import { computed } from '@ember/object'; import { alias, or } from '@ember/object/computed'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; import fieldToAttrs, { expandAttributeMeta } from 'vault/utils/field-to-attrs'; - -const AVAILABLE_PLUGIN_TYPES = [ - { - value: 'mongodb-database-plugin', - displayName: 'MongoDB', - fields: [ - { attr: 'plugin_name' }, - { attr: 'name' }, - { attr: 'connection_url' }, - { attr: 'verify_connection' }, - { attr: 'password_policy' }, - { attr: 'username', group: 'pluginConfig', show: false }, - { attr: 'password', group: 'pluginConfig', show: false }, - { attr: 'write_concern', group: 'pluginConfig' }, - { attr: 'username_template', group: 'pluginConfig' }, - { attr: 'tls', group: 'pluginConfig', subgroup: 'TLS options' }, - { attr: 'tls_ca', group: 'pluginConfig', subgroup: 'TLS options' }, - { attr: 'root_rotation_statements', group: 'statements' }, - ], - }, - { - value: 'mssql-database-plugin', - displayName: 'MSSQL', - fields: [ - { attr: 'plugin_name' }, - { attr: 'name' }, - { attr: 'connection_url' }, - { attr: 'verify_connection' }, - { attr: 'password_policy' }, - { attr: 'username', group: 'pluginConfig', show: false }, - { attr: 'password', group: 'pluginConfig', show: false }, - { attr: 'username_template', group: 'pluginConfig' }, - { attr: 'max_open_connections', group: 'pluginConfig' }, - { attr: 'max_idle_connections', group: 'pluginConfig' }, - { attr: 'max_connection_lifetime', group: 'pluginConfig' }, - { attr: 'root_rotation_statements', group: 'statements' }, - ], - }, - { - value: 'mysql-database-plugin', - displayName: 'MySQL/MariaDB', - fields: [ - { attr: 'plugin_name' }, - { attr: 'name' }, - { attr: 'verify_connection' }, - { attr: 'password_policy' }, - { attr: 'connection_url', group: 'pluginConfig' }, - { attr: 'username', group: 'pluginConfig', show: false }, - { attr: 'password', group: 'pluginConfig', show: false }, - { attr: 'max_open_connections', group: 'pluginConfig' }, - { attr: 'max_idle_connections', group: 'pluginConfig' }, - { attr: 'max_connection_lifetime', group: 'pluginConfig' }, - { attr: 'username_template', group: 'pluginConfig' }, - { attr: 'tls', group: 'pluginConfig', subgroup: 'TLS options' }, - { attr: 'tls_ca', group: 'pluginConfig', subgroup: 'TLS options' }, - { attr: 'root_rotation_statements', group: 'statements' }, - ], - }, - { - value: 'mysql-aurora-database-plugin', - displayName: 'MySQL (Aurora)', - fields: [ - { attr: 'plugin_name' }, - { attr: 'name' }, - { attr: 'verify_connection' }, - { attr: 'password_policy' }, - { attr: 'connection_url', group: 'pluginConfig' }, - { attr: 'username', group: 'pluginConfig', show: false }, - { attr: 'password', group: 'pluginConfig', show: false }, - { attr: 'max_open_connections', group: 'pluginConfig' }, - { attr: 'max_idle_connections', group: 'pluginConfig' }, - { attr: 'max_connection_lifetime', group: 'pluginConfig' }, - { attr: 'username_template', group: 'pluginConfig' }, - { attr: 'tls', group: 'pluginConfig', subgroup: 'TLS options' }, - { attr: 'tls_ca', group: 'pluginConfig', subgroup: 'TLS options' }, - { attr: 'root_rotation_statements', group: 'statements' }, - ], - }, - { - value: 'mysql-rds-database-plugin', - displayName: 'MySQL (RDS)', - fields: [ - { attr: 'plugin_name' }, - { attr: 'name' }, - { attr: 'verify_connection' }, - { attr: 'password_policy' }, - { attr: 'connection_url', group: 'pluginConfig' }, - { attr: 'username', group: 'pluginConfig', show: false }, - { attr: 'password', group: 'pluginConfig', show: false }, - { attr: 'max_open_connections', group: 'pluginConfig' }, - { attr: 'max_idle_connections', group: 'pluginConfig' }, - { attr: 'max_connection_lifetime', group: 'pluginConfig' }, - { attr: 'username_template', group: 'pluginConfig' }, - { attr: 'tls', group: 'pluginConfig', subgroup: 'TLS options' }, - { attr: 'tls_ca', group: 'pluginConfig', subgroup: 'TLS options' }, - { attr: 'root_rotation_statements', group: 'statements' }, - ], - }, - { - value: 'mysql-legacy-database-plugin', - displayName: 'MySQL (Legacy)', - fields: [ - { attr: 'plugin_name' }, - { attr: 'name' }, - { attr: 'verify_connection' }, - { attr: 'password_policy' }, - { attr: 'connection_url', group: 'pluginConfig' }, - { attr: 'username', group: 'pluginConfig', show: false }, - { attr: 'password', group: 'pluginConfig', show: false }, - { attr: 'max_open_connections', group: 'pluginConfig' }, - { attr: 'max_idle_connections', group: 'pluginConfig' }, - { attr: 'max_connection_lifetime', group: 'pluginConfig' }, - { attr: 'username_template', group: 'pluginConfig' }, - { attr: 'tls', group: 'pluginConfig', subgroup: 'TLS options' }, - { attr: 'tls_ca', group: 'pluginConfig', subgroup: 'TLS options' }, - { attr: 'root_rotation_statements', group: 'statements' }, - ], - }, - { - value: 'elasticsearch-database-plugin', - displayName: 'Elasticsearch', - fields: [ - { attr: 'plugin_name' }, - { attr: 'name' }, - { attr: 'verify_connection' }, - { attr: 'password_policy' }, - { attr: 'url', group: 'pluginConfig' }, - { attr: 'username', group: 'pluginConfig', show: false }, - { attr: 'password', group: 'pluginConfig', show: false }, - { attr: 'ca_cert', group: 'pluginConfig' }, - { attr: 'ca_path', group: 'pluginConfig' }, - { attr: 'client_cert', group: 'pluginConfig' }, - { attr: 'client_key', group: 'pluginConfig' }, - { attr: 'tls_server_name', group: 'pluginConfig' }, - { attr: 'insecure', group: 'pluginConfig' }, - { attr: 'username_template', group: 'pluginConfig' }, - ], - }, -]; +import { AVAILABLE_PLUGIN_TYPES } from '../../utils/database-role-fields'; /** * fieldsToGroups helper fn diff --git a/ui/app/serializers/database/connection.js b/ui/app/serializers/database/connection.js index 935a920a0b977..ed0970f94b0e6 100644 --- a/ui/app/serializers/database/connection.js +++ b/ui/app/serializers/database/connection.js @@ -1,4 +1,5 @@ import RESTSerializer from '@ember-data/serializer/rest'; +import { AVAILABLE_PLUGIN_TYPES } from '../../utils/database-role-fields'; export default RESTSerializer.extend({ primaryKey: 'name', @@ -46,27 +47,19 @@ export default RESTSerializer.extend({ return this._super(store, primaryModelClass, transformedPayload, id, requestType); }, - // add serialize function this._super - // serialize(snapshot, requestType) { - // let data = this._super(snapshot, requestType); - // if (data.database) { - // const db = data.database[0]; - // data.db_name = db; - // delete data.database; - // } - // // This is necessary because the input for MongoDB is a json string - // // rather than an array, so we transpose that here - // if (data.creation_statement) { - // const singleStatement = data.creation_statement; - // data.creation_statements = [singleStatement]; - // delete data.creation_statement; - // } - // if (data.revocation_statement) { - // const singleStatement = data.revocation_statement; - // data.revocation_statements = [singleStatement]; - // delete data.revocation_statement; - // } + serialize(snapshot, requestType) { + let data = this._super(snapshot, requestType); + let pluginAttributes = AVAILABLE_PLUGIN_TYPES.find(plugin => plugin.value === data.plugin_name) + .fields.map(fields => fields.attr) + .concat('backend'); - // return data; - // }, + // filter data to only allow plugin specific attrs + let allowedAttributes = Object.keys(data).filter(dataAttrs => pluginAttributes.includes(dataAttrs)); + for (const key in data) { + if (!allowedAttributes.includes(key)) { + delete data[key]; + } + } + return data; + }, }); diff --git a/ui/app/utils/database-role-fields.js b/ui/app/utils/database-role-fields.js index b420644bf6440..5f888782fa158 100644 --- a/ui/app/utils/database-role-fields.js +++ b/ui/app/utils/database-role-fields.js @@ -1,3 +1,142 @@ +export const AVAILABLE_PLUGIN_TYPES = [ + { + value: 'mongodb-database-plugin', + displayName: 'MongoDB', + fields: [ + { attr: 'plugin_name' }, + { attr: 'name' }, + { attr: 'connection_url' }, + { attr: 'verify_connection' }, + { attr: 'password_policy' }, + { attr: 'username', group: 'pluginConfig', show: false }, + { attr: 'password', group: 'pluginConfig', show: false }, + { attr: 'write_concern', group: 'pluginConfig' }, + { attr: 'username_template', group: 'pluginConfig' }, + { attr: 'tls', group: 'pluginConfig', subgroup: 'TLS options' }, + { attr: 'tls_ca', group: 'pluginConfig', subgroup: 'TLS options' }, + { attr: 'root_rotation_statements', group: 'statements' }, + ], + }, + { + value: 'mssql-database-plugin', + displayName: 'MSSQL', + fields: [ + { attr: 'plugin_name' }, + { attr: 'name' }, + { attr: 'connection_url' }, + { attr: 'verify_connection' }, + { attr: 'password_policy' }, + { attr: 'username', group: 'pluginConfig', show: false }, + { attr: 'password', group: 'pluginConfig', show: false }, + { attr: 'username_template', group: 'pluginConfig' }, + { attr: 'max_open_connections', group: 'pluginConfig' }, + { attr: 'max_idle_connections', group: 'pluginConfig' }, + { attr: 'max_connection_lifetime', group: 'pluginConfig' }, + { attr: 'root_rotation_statements', group: 'statements' }, + ], + }, + { + value: 'mysql-database-plugin', + displayName: 'MySQL/MariaDB', + fields: [ + { attr: 'plugin_name' }, + { attr: 'name' }, + { attr: 'verify_connection' }, + { attr: 'password_policy' }, + { attr: 'connection_url', group: 'pluginConfig' }, + { attr: 'username', group: 'pluginConfig', show: false }, + { attr: 'password', group: 'pluginConfig', show: false }, + { attr: 'max_open_connections', group: 'pluginConfig' }, + { attr: 'max_idle_connections', group: 'pluginConfig' }, + { attr: 'max_connection_lifetime', group: 'pluginConfig' }, + { attr: 'username_template', group: 'pluginConfig' }, + { attr: 'tls', group: 'pluginConfig', subgroup: 'TLS options' }, + { attr: 'tls_ca', group: 'pluginConfig', subgroup: 'TLS options' }, + { attr: 'root_rotation_statements', group: 'statements' }, + ], + }, + { + value: 'mysql-aurora-database-plugin', + displayName: 'MySQL (Aurora)', + fields: [ + { attr: 'plugin_name' }, + { attr: 'name' }, + { attr: 'verify_connection' }, + { attr: 'password_policy' }, + { attr: 'connection_url', group: 'pluginConfig' }, + { attr: 'username', group: 'pluginConfig', show: false }, + { attr: 'password', group: 'pluginConfig', show: false }, + { attr: 'max_open_connections', group: 'pluginConfig' }, + { attr: 'max_idle_connections', group: 'pluginConfig' }, + { attr: 'max_connection_lifetime', group: 'pluginConfig' }, + { attr: 'username_template', group: 'pluginConfig' }, + { attr: 'tls', group: 'pluginConfig', subgroup: 'TLS options' }, + { attr: 'tls_ca', group: 'pluginConfig', subgroup: 'TLS options' }, + { attr: 'root_rotation_statements', group: 'statements' }, + ], + }, + { + value: 'mysql-rds-database-plugin', + displayName: 'MySQL (RDS)', + fields: [ + { attr: 'plugin_name' }, + { attr: 'name' }, + { attr: 'verify_connection' }, + { attr: 'password_policy' }, + { attr: 'connection_url', group: 'pluginConfig' }, + { attr: 'username', group: 'pluginConfig', show: false }, + { attr: 'password', group: 'pluginConfig', show: false }, + { attr: 'max_open_connections', group: 'pluginConfig' }, + { attr: 'max_idle_connections', group: 'pluginConfig' }, + { attr: 'max_connection_lifetime', group: 'pluginConfig' }, + { attr: 'username_template', group: 'pluginConfig' }, + { attr: 'tls', group: 'pluginConfig', subgroup: 'TLS options' }, + { attr: 'tls_ca', group: 'pluginConfig', subgroup: 'TLS options' }, + { attr: 'root_rotation_statements', group: 'statements' }, + ], + }, + { + value: 'mysql-legacy-database-plugin', + displayName: 'MySQL (Legacy)', + fields: [ + { attr: 'plugin_name' }, + { attr: 'name' }, + { attr: 'verify_connection' }, + { attr: 'password_policy' }, + { attr: 'connection_url', group: 'pluginConfig' }, + { attr: 'username', group: 'pluginConfig', show: false }, + { attr: 'password', group: 'pluginConfig', show: false }, + { attr: 'max_open_connections', group: 'pluginConfig' }, + { attr: 'max_idle_connections', group: 'pluginConfig' }, + { attr: 'max_connection_lifetime', group: 'pluginConfig' }, + { attr: 'username_template', group: 'pluginConfig' }, + { attr: 'tls', group: 'pluginConfig', subgroup: 'TLS options' }, + { attr: 'tls_ca', group: 'pluginConfig', subgroup: 'TLS options' }, + { attr: 'root_rotation_statements', group: 'statements' }, + ], + }, + { + value: 'elasticsearch-database-plugin', + displayName: 'Elasticsearch', + fields: [ + { attr: 'plugin_name' }, + { attr: 'name' }, + { attr: 'verify_connection' }, + { attr: 'password_policy' }, + { attr: 'url', group: 'pluginConfig' }, + { attr: 'username', group: 'pluginConfig', show: false }, + { attr: 'password', group: 'pluginConfig', show: false }, + { attr: 'ca_cert', group: 'pluginConfig' }, + { attr: 'ca_path', group: 'pluginConfig' }, + { attr: 'client_cert', group: 'pluginConfig' }, + { attr: 'client_key', group: 'pluginConfig' }, + { attr: 'tls_server_name', group: 'pluginConfig' }, + { attr: 'insecure', group: 'pluginConfig' }, + { attr: 'username_template', group: 'pluginConfig' }, + ], + }, +]; + export const ROLE_FIELDS = { static: ['username', 'rotation_period'], dynamic: ['ttl', 'max_ttl'], From ba810b24a948640c0626191abf69334d252b8a33 Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Fri, 8 Oct 2021 10:24:14 -0700 Subject: [PATCH 03/17] adds if block catch if no plugin_type, renames util file --- ui/app/models/database/role.js | 2 +- ui/app/serializers/database/connection.js | 3 +++ ui/app/utils/{database-role-fields.js => database-helpers.js} | 0 3 files changed, 4 insertions(+), 1 deletion(-) rename ui/app/utils/{database-role-fields.js => database-helpers.js} (100%) diff --git a/ui/app/models/database/role.js b/ui/app/models/database/role.js index 3ed255a062034..2f9e11a2a9142 100644 --- a/ui/app/models/database/role.js +++ b/ui/app/models/database/role.js @@ -3,7 +3,7 @@ import { computed } from '@ember/object'; import { alias } from '@ember/object/computed'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -import { getRoleFields } from '../../utils/database-role-fields'; +import { getRoleFields } from '../../utils/database-helpers'; export default Model.extend({ idPrefix: 'role/', diff --git a/ui/app/serializers/database/connection.js b/ui/app/serializers/database/connection.js index ed0970f94b0e6..e3b4188ed7c5d 100644 --- a/ui/app/serializers/database/connection.js +++ b/ui/app/serializers/database/connection.js @@ -49,6 +49,9 @@ export default RESTSerializer.extend({ serialize(snapshot, requestType) { let data = this._super(snapshot, requestType); + if (!data.plugin_name) { + return data; + } let pluginAttributes = AVAILABLE_PLUGIN_TYPES.find(plugin => plugin.value === data.plugin_name) .fields.map(fields => fields.attr) .concat('backend'); diff --git a/ui/app/utils/database-role-fields.js b/ui/app/utils/database-helpers.js similarity index 100% rename from ui/app/utils/database-role-fields.js rename to ui/app/utils/database-helpers.js From 983840f572f85d3e7ba763e777b7f23232e5074b Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Fri, 8 Oct 2021 10:25:17 -0700 Subject: [PATCH 04/17] updates imports --- ui/app/components/database-role-setting-form.js | 2 +- ui/app/models/database/connection.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/app/components/database-role-setting-form.js b/ui/app/components/database-role-setting-form.js index e7d9f6b4d3113..d7504de1272cf 100644 --- a/ui/app/components/database-role-setting-form.js +++ b/ui/app/components/database-role-setting-form.js @@ -14,7 +14,7 @@ */ import Component from '@glimmer/component'; -import { getStatementFields, getRoleFields } from '../utils/database-role-fields'; +import { getStatementFields, getRoleFields } from '../utils/database-helpers'; export default class DatabaseRoleSettingForm extends Component { get settingFields() { diff --git a/ui/app/models/database/connection.js b/ui/app/models/database/connection.js index 3887663198bd7..8adac6dd0da5c 100644 --- a/ui/app/models/database/connection.js +++ b/ui/app/models/database/connection.js @@ -3,7 +3,7 @@ import { computed } from '@ember/object'; import { alias, or } from '@ember/object/computed'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; import fieldToAttrs, { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -import { AVAILABLE_PLUGIN_TYPES } from '../../utils/database-role-fields'; +import { AVAILABLE_PLUGIN_TYPES } from '../../utils/database-helpers'; /** * fieldsToGroups helper fn From 87bc1af0f099d50bd2056186fb5cdaeb0de6b978 Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Fri, 8 Oct 2021 10:26:04 -0700 Subject: [PATCH 05/17] last import --- ui/app/serializers/database/connection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/serializers/database/connection.js b/ui/app/serializers/database/connection.js index e3b4188ed7c5d..c43096767131a 100644 --- a/ui/app/serializers/database/connection.js +++ b/ui/app/serializers/database/connection.js @@ -1,5 +1,5 @@ import RESTSerializer from '@ember-data/serializer/rest'; -import { AVAILABLE_PLUGIN_TYPES } from '../../utils/database-role-fields'; +import { AVAILABLE_PLUGIN_TYPES } from '../../utils/database-helpers'; export default RESTSerializer.extend({ primaryKey: 'name', From 5f9f1a11cede333393a0ca63ced49d9a52ec2f75 Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Fri, 8 Oct 2021 10:31:24 -0700 Subject: [PATCH 06/17] adds changelog --- changelog/12770.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/12770.txt diff --git a/changelog/12770.txt b/changelog/12770.txt new file mode 100644 index 0000000000000..46d99f4b097bb --- /dev/null +++ b/changelog/12770.txt @@ -0,0 +1,3 @@ +```release-note:improvement +ui: Filter DB connection attributes so only relevant attrs POST to backend +``` \ No newline at end of file From 62620d1c9c8fb86549eb8ecd3f9e94c151f68873 Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Fri, 8 Oct 2021 12:54:35 -0700 Subject: [PATCH 07/17] fixes rendering of default attrs" --- ui/app/models/database/connection.js | 2 +- ui/app/templates/components/database-connection.hbs | 12 ++++++------ ui/lib/core/addon/components/info-table-row.js | 11 +++++++++++ .../addon/templates/components/info-table-row.hbs | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ui/app/models/database/connection.js b/ui/app/models/database/connection.js index 8adac6dd0da5c..83f66d029391f 100644 --- a/ui/app/models/database/connection.js +++ b/ui/app/models/database/connection.js @@ -119,8 +119,8 @@ export default Model.extend({ defaultValue: '0s', }), insecure: attr('boolean', { - defaultValue: false, label: 'Disable SSL verification', + defaultValue: false, }), tls: attr('string', { label: 'TLS Certificate Key', diff --git a/ui/app/templates/components/database-connection.hbs b/ui/app/templates/components/database-connection.hbs index c8231368e632f..19aee380418fc 100644 --- a/ui/app/templates/components/database-connection.hbs +++ b/ui/app/templates/components/database-connection.hbs @@ -307,20 +307,20 @@ {{else}} {{#each @model.showAttrs as |attr|}} - {{#let attr.options.defaultDisplay as |defaultDisplay|}} + {{#let attr.options.defaultShown as |defaultDisplay|}} {{#if (eq attr.type "object")}} {{else if (eq attr.type "array")}} {{/if}} {{/let}} diff --git a/ui/lib/core/addon/components/info-table-row.js b/ui/lib/core/addon/components/info-table-row.js index 2ab9083e82af4..dbadd9d1010df 100644 --- a/ui/lib/core/addon/components/info-table-row.js +++ b/ui/lib/core/addon/components/info-table-row.js @@ -44,4 +44,15 @@ export default Component.extend({ valueIsBoolean: computed('value', function() { return typeOf(this.value) === 'boolean'; }), + + valueIsEmpty: computed('value', function() { + let value = this.value; + if (typeOf(value) === 'array' && value.length === 0) { + return true; + } else if (value === undefined) { + return true; + } else { + return false; + } + }), }); diff --git a/ui/lib/core/addon/templates/components/info-table-row.hbs b/ui/lib/core/addon/templates/components/info-table-row.hbs index 7fcf0801811ac..0f3bfb2ae4107 100644 --- a/ui/lib/core/addon/templates/components/info-table-row.hbs +++ b/ui/lib/core/addon/templates/components/info-table-row.hbs @@ -34,7 +34,7 @@ {{!-- alwaysRender is still true --}} {{else if (and (not value) defaultShown)}} {{defaultShown}} - {{else if (eq value "")}} + {{else if valueIsEmpty}} {{else}} {{#if (eq type 'array')}} From 7b39348eaec9100b6e8a813607ce61490567452f Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Fri, 8 Oct 2021 14:45:45 -0700 Subject: [PATCH 08/17] checks that plugin exists --- ui/app/serializers/database/connection.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/app/serializers/database/connection.js b/ui/app/serializers/database/connection.js index c43096767131a..34d750b4b0e0a 100644 --- a/ui/app/serializers/database/connection.js +++ b/ui/app/serializers/database/connection.js @@ -52,9 +52,11 @@ export default RESTSerializer.extend({ if (!data.plugin_name) { return data; } - let pluginAttributes = AVAILABLE_PLUGIN_TYPES.find(plugin => plugin.value === data.plugin_name) - .fields.map(fields => fields.attr) - .concat('backend'); + let pluginType = AVAILABLE_PLUGIN_TYPES.find(plugin => plugin.value === data.plugin_name); + if (!pluginType) { + return data; + } + let pluginAttributes = pluginType.fields.map(fields => fields.attr).concat('backend'); // filter data to only allow plugin specific attrs let allowedAttributes = Object.keys(data).filter(dataAttrs => pluginAttributes.includes(dataAttrs)); From a9aa790cdbe37d3943490ca1b4f9668947a8886c Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Fri, 8 Oct 2021 15:20:16 -0700 Subject: [PATCH 09/17] use destructuring --- ui/lib/core/addon/components/info-table-row.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/lib/core/addon/components/info-table-row.js b/ui/lib/core/addon/components/info-table-row.js index dbadd9d1010df..f3dd7d385ea8b 100644 --- a/ui/lib/core/addon/components/info-table-row.js +++ b/ui/lib/core/addon/components/info-table-row.js @@ -46,7 +46,7 @@ export default Component.extend({ }), valueIsEmpty: computed('value', function() { - let value = this.value; + let { value } = this; if (typeOf(value) === 'array' && value.length === 0) { return true; } else if (value === undefined) { From d39ee313a486288b0230eaa3cbf81206ee8cf411 Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Mon, 11 Oct 2021 11:40:33 -0700 Subject: [PATCH 10/17] adds oracle to availabe_plugin_types --- ui/app/utils/database-helpers.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ui/app/utils/database-helpers.js b/ui/app/utils/database-helpers.js index 923a43e6b4082..2702912fd90bd 100644 --- a/ui/app/utils/database-helpers.js +++ b/ui/app/utils/database-helpers.js @@ -135,6 +135,24 @@ export const AVAILABLE_PLUGIN_TYPES = [ { attr: 'username_template', group: 'pluginConfig' }, ], }, + { + value: 'oracle-database-plugin', + displayName: 'Oracle', + fields: [ + { attr: 'plugin_name' }, + { attr: 'name' }, + { attr: 'verify_connection' }, + { attr: 'password_policy' }, + { attr: 'connection_url', group: 'pluginConfig' }, + { attr: 'username', group: 'pluginConfig', show: false }, + { attr: 'password', group: 'pluginConfig', show: false }, + { attr: 'max_open_connections', group: 'pluginConfig' }, + { attr: 'max_idle_connections', group: 'pluginConfig' }, + { attr: 'max_connection_lifetime', group: 'pluginConfig' }, + { attr: 'username_template', group: 'pluginConfig' }, + { attr: 'root_rotation_statements', group: 'statements' }, + ], + }, ]; export const ROLE_FIELDS = { From e32977173bb87644421fbdf84c91608d89077b77 Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Mon, 11 Oct 2021 11:42:41 -0700 Subject: [PATCH 11/17] updates edit hbs file --- ui/app/templates/components/database-role-edit.hbs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/app/templates/components/database-role-edit.hbs b/ui/app/templates/components/database-role-edit.hbs index 408b6a0833c0d..06f49c2a59475 100644 --- a/ui/app/templates/components/database-role-edit.hbs +++ b/ui/app/templates/components/database-role-edit.hbs @@ -55,20 +55,20 @@ {{#each @model.showFields as |attr|}} - {{#let attr.options.defaultDisplay as |defaultDisplay|}} + {{#let attr.options.defaultShown as |defaultDisplay|}} {{#if (eq attr.type "object")}} {{else}} {{/if}} From fd7744ee3b3d88aa3bd040a0f76c878abd0a1157 Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Mon, 11 Oct 2021 11:44:03 -0700 Subject: [PATCH 12/17] adds check for if value is null or empty string --- ui/lib/core/addon/components/info-table-row.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/lib/core/addon/components/info-table-row.js b/ui/lib/core/addon/components/info-table-row.js index f3dd7d385ea8b..8debe588c3455 100644 --- a/ui/lib/core/addon/components/info-table-row.js +++ b/ui/lib/core/addon/components/info-table-row.js @@ -47,9 +47,10 @@ export default Component.extend({ valueIsEmpty: computed('value', function() { let { value } = this; + console.log('value', value); if (typeOf(value) === 'array' && value.length === 0) { return true; - } else if (value === undefined) { + } else if (value === undefined || null || '') { return true; } else { return false; From 784a0d9b42d3fd9a250a3bd1d641adfb8a19fc75 Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Mon, 11 Oct 2021 13:07:25 -0700 Subject: [PATCH 13/17] Revert "adds check for if value is null or empty string" This reverts commit fd7744ee3b3d88aa3bd040a0f76c878abd0a1157. --- ui/lib/core/addon/components/info-table-row.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/lib/core/addon/components/info-table-row.js b/ui/lib/core/addon/components/info-table-row.js index 8debe588c3455..f3dd7d385ea8b 100644 --- a/ui/lib/core/addon/components/info-table-row.js +++ b/ui/lib/core/addon/components/info-table-row.js @@ -47,10 +47,9 @@ export default Component.extend({ valueIsEmpty: computed('value', function() { let { value } = this; - console.log('value', value); if (typeOf(value) === 'array' && value.length === 0) { return true; - } else if (value === undefined || null || '') { + } else if (value === undefined) { return true; } else { return false; From 66612dd2d466173f4fb1c2759e912887de8e9075 Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Mon, 11 Oct 2021 13:25:55 -0700 Subject: [PATCH 14/17] check plugin exists --- ui/app/serializers/database/connection.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/app/serializers/database/connection.js b/ui/app/serializers/database/connection.js index c43096767131a..34d750b4b0e0a 100644 --- a/ui/app/serializers/database/connection.js +++ b/ui/app/serializers/database/connection.js @@ -52,9 +52,11 @@ export default RESTSerializer.extend({ if (!data.plugin_name) { return data; } - let pluginAttributes = AVAILABLE_PLUGIN_TYPES.find(plugin => plugin.value === data.plugin_name) - .fields.map(fields => fields.attr) - .concat('backend'); + let pluginType = AVAILABLE_PLUGIN_TYPES.find(plugin => plugin.value === data.plugin_name); + if (!pluginType) { + return data; + } + let pluginAttributes = pluginType.fields.map(fields => fields.attr).concat('backend'); // filter data to only allow plugin specific attrs let allowedAttributes = Object.keys(data).filter(dataAttrs => pluginAttributes.includes(dataAttrs)); From 8acdafc8d2ecbaa7934e04abd260bffb2bc62e17 Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Mon, 11 Oct 2021 13:28:40 -0700 Subject: [PATCH 15/17] remove valueIsEmpty method --- ui/lib/core/addon/components/info-table-row.js | 11 ----------- .../addon/templates/components/info-table-row.hbs | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/ui/lib/core/addon/components/info-table-row.js b/ui/lib/core/addon/components/info-table-row.js index f3dd7d385ea8b..2ab9083e82af4 100644 --- a/ui/lib/core/addon/components/info-table-row.js +++ b/ui/lib/core/addon/components/info-table-row.js @@ -44,15 +44,4 @@ export default Component.extend({ valueIsBoolean: computed('value', function() { return typeOf(this.value) === 'boolean'; }), - - valueIsEmpty: computed('value', function() { - let { value } = this; - if (typeOf(value) === 'array' && value.length === 0) { - return true; - } else if (value === undefined) { - return true; - } else { - return false; - } - }), }); diff --git a/ui/lib/core/addon/templates/components/info-table-row.hbs b/ui/lib/core/addon/templates/components/info-table-row.hbs index 0f3bfb2ae4107..63ddefb46f3f4 100644 --- a/ui/lib/core/addon/templates/components/info-table-row.hbs +++ b/ui/lib/core/addon/templates/components/info-table-row.hbs @@ -34,7 +34,7 @@ {{!-- alwaysRender is still true --}} {{else if (and (not value) defaultShown)}} {{defaultShown}} - {{else if valueIsEmpty}} + {{else if (eq value "")}} {{else}} {{#if (eq type 'array')}} From eda13a9c4137e7d07825d21affacb9ba9e671d35 Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Mon, 11 Oct 2021 13:29:39 -0700 Subject: [PATCH 16/17] removes extra space --- ui/lib/core/addon/templates/components/info-table-row.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/lib/core/addon/templates/components/info-table-row.hbs b/ui/lib/core/addon/templates/components/info-table-row.hbs index 63ddefb46f3f4..37ab0029838f6 100644 --- a/ui/lib/core/addon/templates/components/info-table-row.hbs +++ b/ui/lib/core/addon/templates/components/info-table-row.hbs @@ -34,7 +34,7 @@ {{!-- alwaysRender is still true --}} {{else if (and (not value) defaultShown)}} {{defaultShown}} - {{else if (eq value "")}} + {{else if (eq value "")}} {{else}} {{#if (eq type 'array')}} From 02e38077c7f00356eb42349b1a8077ba03eb2e5b Mon Sep 17 00:00:00 2001 From: Claire Bontempo Date: Mon, 11 Oct 2021 13:30:08 -0700 Subject: [PATCH 17/17] match original --- ui/lib/core/addon/templates/components/info-table-row.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/lib/core/addon/templates/components/info-table-row.hbs b/ui/lib/core/addon/templates/components/info-table-row.hbs index 37ab0029838f6..7fcf0801811ac 100644 --- a/ui/lib/core/addon/templates/components/info-table-row.hbs +++ b/ui/lib/core/addon/templates/components/info-table-row.hbs @@ -34,7 +34,7 @@ {{!-- alwaysRender is still true --}} {{else if (and (not value) defaultShown)}} {{defaultShown}} - {{else if (eq value "")}} + {{else if (eq value "")}} {{else}} {{#if (eq type 'array')}}