Commit 66d1c270 authored by Denys Mishunov's avatar Denys Mishunov

Merge branch 'xanf-fix-saml-settings-form' into 'master'

Resolve "SAML/SSO/GMA toggles appear disabled when they're not"

Closes #211695

See merge request gitlab-org/gitlab!28126
parents 135b7d0f d1f0275a
...@@ -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