Commit d1f0275a authored by Illya Klymov's avatar Illya Klymov

Fix toggles not removing is-disabled class

parent 258ea127
...@@ -114,16 +114,16 @@ export default class SamlSettingsForm { ...@@ -114,16 +114,16 @@ export default class SamlSettingsForm {
.filter(setting => setting.dependsOn) .filter(setting => setting.dependsOn)
.forEach(setting => { .forEach(setting => {
const { helperText, callout, toggle } = setting; const { helperText, callout, toggle } = setting;
const dependentToggleValue = this.getValueWithDeps(setting.dependsOn); const isRelatedToggleOn = this.getValueWithDeps(setting.dependsOn);
if (helperText) { if (helperText) {
helperText.style.display = dependentToggleValue ? 'none' : 'block'; helperText.style.display = isRelatedToggleOn ? 'none' : 'block';
} }
toggle.classList.toggle('is-disabled', dependentToggleValue); toggle.classList.toggle('is-disabled', !isRelatedToggleOn);
toggle.disabled = !dependentToggleValue; toggle.disabled = !isRelatedToggleOn;
if (callout) { if (callout) {
callout.style.display = setting.value && dependentToggleValue ? 'block' : 'none'; callout.style.display = setting.value && isRelatedToggleOn ? 'block' : 'none';
} }
}); });
} }
......
...@@ -54,12 +54,14 @@ describe('SamlSettingsForm', () => { ...@@ -54,12 +54,14 @@ describe('SamlSettingsForm', () => {
samlSettingsForm.updateSAMLSettings(); samlSettingsForm.updateSAMLSettings();
samlSettingsForm.updateView(); samlSettingsForm.updateView();
expect(findProhibitForksSetting().toggle.hasAttribute('disabled')).toBe(false); expect(findProhibitForksSetting().toggle.hasAttribute('disabled')).toBe(false);
expect(findProhibitForksSetting().toggle.classList.contains('is-disabled')).toBe(false);
findEnforcedGroupManagedAccountSetting().input.value = false; findEnforcedGroupManagedAccountSetting().input.value = false;
samlSettingsForm.updateSAMLSettings(); samlSettingsForm.updateSAMLSettings();
samlSettingsForm.updateView(); samlSettingsForm.updateView();
expect(findProhibitForksSetting().toggle.hasAttribute('disabled')).toBe(true); expect(findProhibitForksSetting().toggle.hasAttribute('disabled')).toBe(true);
expect(findProhibitForksSetting().toggle.classList.contains('is-disabled')).toBe(true);
expect(findProhibitForksSetting().value).toBe(true); expect(findProhibitForksSetting().value).toBe(true);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment