open-consul/ui/packages/consul-ui/app/modifiers/disabled.js
John Cowen 5ff1897070
ui: Adds warning icon to side menu when ACLs are disabled (#9864)
* ui: Adds warning icon to side menu when ACLs are are disabled
2021-03-17 11:23:00 +00:00

18 lines
487 B
JavaScript

import { modifier } from 'ember-modifier';
export default modifier(function enabled($element, [bool = true], hash) {
if (['input', 'textarea', 'select', 'button'].includes($element.nodeName.toLowerCase())) {
if (bool) {
$element.disabled = bool;
} else {
$element.dataset.disabled = false;
}
return;
}
for (const $el of $element.querySelectorAll('input,textarea')) {
if ($el.dataset.disabled !== 'false') {
$el.disabled = bool;
}
}
});