mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Adds getAriaName function and applies it to advanced settings (#13448)
This commit is contained in:
parent
c4c6ea1565
commit
0920a99a15
4 changed files with 45 additions and 0 deletions
|
@ -131,6 +131,7 @@
|
|||
ng-click="edit(conf)"
|
||||
class="kuiMenuButton kuiMenuButton--basic kuiMenuButton--iconText"
|
||||
ng-disabled="conf.tooComplex"
|
||||
aria-label="Edit {{conf.ariaName}}"
|
||||
data-test-subj="advancedSetting-{{conf.name}}-editButton"
|
||||
>
|
||||
<span
|
||||
|
@ -146,6 +147,7 @@
|
|||
ng-click="save(conf)"
|
||||
class="kuiMenuButton kuiMenuButton--primary kuiMenuButton--iconText"
|
||||
ng-disabled="conf.loading || conf.tooComplex || forms.configEdit.$invalid"
|
||||
aria-label="Save edit"
|
||||
data-test-subj="advancedSetting-{{conf.name}}-saveButton"
|
||||
>
|
||||
<span
|
||||
|
@ -166,6 +168,7 @@
|
|||
ng-if="!conf.editing"
|
||||
ng-click="clear(conf)"
|
||||
ng-hide="isDefaultValue(conf)"
|
||||
aria-label="Clear {{conf.ariaName}}"
|
||||
class="kuiMenuButton kuiMenuButton--danger kuiMenuButton--iconText"
|
||||
>
|
||||
<span
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
import { getAriaName } from '../get_aria_name';
|
||||
import expect from 'expect.js';
|
||||
|
||||
describe('Settings', function () {
|
||||
describe('Advanced', function () {
|
||||
describe('getAriaName(name)', function () {
|
||||
it('should be a function', function () {
|
||||
expect(getAriaName).to.be.a(Function);
|
||||
});
|
||||
|
||||
it('should return a space delimited lower-case string with no special characters', function () {
|
||||
expect(getAriaName('xPack:defaultAdminEmail')).to.be('x pack default admin email');
|
||||
expect(getAriaName('search:queryLanguage:switcher:enable')).to.be('search query language switcher enable');
|
||||
expect(getAriaName('doc_table:highlight')).to.be('doc table highlight');
|
||||
expect(getAriaName('foo')).to.be('foo');
|
||||
});
|
||||
|
||||
it('should return an empty string if passed undefined or null', function () {
|
||||
expect(getAriaName()).to.be('');
|
||||
expect(getAriaName(undefined)).to.be('');
|
||||
expect(getAriaName(null)).to.be('');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
import { words } from 'lodash';
|
||||
|
||||
/**
|
||||
* @name {string} the name of the configuration object
|
||||
* @returns {string} a space demimited, lowercase string with
|
||||
* special characters removed.
|
||||
*
|
||||
* Example: 'xPack:fooBar:foo_bar_baz' -> 'x pack foo bar foo bar baz'
|
||||
*/
|
||||
export function getAriaName(name) {
|
||||
return words(name).map(word => word.toLowerCase()).join(' ');
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import { getValType } from './get_val_type';
|
||||
import { getEditorType } from './get_editor_type';
|
||||
import { getAriaName } from './get_aria_name';
|
||||
|
||||
/**
|
||||
* @param {object} advanced setting definition object
|
||||
|
@ -13,6 +14,7 @@ export function toEditableConfig({ def, name, value, isCustom }) {
|
|||
}
|
||||
const conf = {
|
||||
name,
|
||||
ariaName: getAriaName(name),
|
||||
value,
|
||||
isCustom,
|
||||
readonly: !!def.readonly,
|
||||
|
@ -33,3 +35,4 @@ export function toEditableConfig({ def, name, value, isCustom }) {
|
|||
|
||||
return conf;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue