vault/ui/app/components/database-role-setting-form.js
claire bontempo 3400fd33a3
UI/Add Elasticsearch DB (#12672)
* displays empty state if database is not supported in the UI

* adds elasticsearch db plugin

* adds changelog

* updates elasticsearch attrs

* move tls_server_name to pluginConfig group

* move role setting fields to util

* updates comments and refactors using util function

* adds tests for elasticsearch

* fixes indentation

* when local host needs https

* adds line at bottom of hbs file
2021-10-07 14:00:42 -07:00

38 lines
1.4 KiB
JavaScript

/**
* @module DatabaseRoleSettingForm
* DatabaseRoleSettingForm components are used to handle the role settings section on the database/role form
*
* @example
* ```js
* <DatabaseRoleSettingForm @requiredParam={requiredParam} @optionalParam={optionalParam} @param1={{param1}}/>
* ```
* @param {Array<object>} attrs - all available attrs from the model to iterate over
* @param {object} model - ember data model which should be updated on change
* @param {string} [roleType] - role type controls which attributes are shown
* @param {string} [mode=create] - mode of the form (eg. create or edit)
* @param {string} [dbType=default] - type of database, eg 'mongodb-database-plugin'
*/
import Component from '@glimmer/component';
import { getStatementFields, getRoleFields } from '../utils/database-role-fields';
export default class DatabaseRoleSettingForm extends Component {
get settingFields() {
if (!this.args.roleType) return null;
let dbValidFields = getRoleFields(this.args.roleType);
return this.args.attrs.filter(a => {
return dbValidFields.includes(a.name);
});
}
get statementFields() {
const type = this.args.roleType;
const plugin = this.args.dbType;
if (!type) return null;
let dbValidFields = getStatementFields(type, plugin);
return this.args.attrs.filter(a => {
return dbValidFields.includes(a.name);
});
}
}