Merge branch '32408-enable-disable-all-restricted-visibility-levels' into 'master'
Resolve "Unable to disable all restricted visibility levels" Closes #32408 See merge request !12649
This commit is contained in:
commit
aa66e539f1
|
@ -71,6 +71,8 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
|
|||
params[:application_setting][:disabled_oauth_sign_in_sources] =
|
||||
AuthHelper.button_based_providers.map(&:to_s) -
|
||||
Array(enabled_oauth_sign_in_sources)
|
||||
|
||||
params[:application_setting][:restricted_visibility_levels]&.delete("")
|
||||
params.delete(:domain_blacklist_raw) if params[:domain_blacklist_file]
|
||||
|
||||
params.require(:application_setting).permit(
|
||||
|
|
|
@ -34,17 +34,17 @@ module ApplicationSettingsHelper
|
|||
|
||||
# Return a group of checkboxes that use Bootstrap's button plugin for a
|
||||
# toggle button effect.
|
||||
def restricted_level_checkboxes(help_block_id)
|
||||
def restricted_level_checkboxes(help_block_id, checkbox_name)
|
||||
Gitlab::VisibilityLevel.options.map do |name, level|
|
||||
checked = restricted_visibility_levels(true).include?(level)
|
||||
css_class = checked ? 'active' : ''
|
||||
checkbox_name = "application_setting[restricted_visibility_levels][]"
|
||||
tag_name = "application_setting_visibility_level_#{level}"
|
||||
|
||||
label_tag(name, class: css_class) do
|
||||
label_tag(tag_name, class: css_class) do
|
||||
check_box_tag(checkbox_name, level, checked,
|
||||
autocomplete: 'off',
|
||||
'aria-describedby' => help_block_id,
|
||||
id: name) + visibility_level_icon(level) + name
|
||||
id: tag_name) + visibility_level_icon(level) + name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
.form-group
|
||||
= f.label :restricted_visibility_levels, class: 'control-label col-sm-2'
|
||||
.col-sm-10
|
||||
- restricted_level_checkboxes('restricted-visibility-help').each do |level|
|
||||
- checkbox_name = 'application_setting[restricted_visibility_levels][]'
|
||||
= hidden_field_tag(checkbox_name)
|
||||
- restricted_level_checkboxes('restricted-visibility-help', checkbox_name).each do |level|
|
||||
.checkbox
|
||||
= level
|
||||
%span.help-block#restricted-visibility-help
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Allow admins to disable all restricted visibility levels
|
||||
merge_request: 12649
|
||||
author:
|
|
@ -16,6 +16,19 @@ feature 'Admin updates settings', feature: true do
|
|||
expect(page).to have_content "Application settings saved successfully"
|
||||
end
|
||||
|
||||
scenario 'Uncheck all restricted visibility levels' do
|
||||
find('#application_setting_visibility_level_0').set(false)
|
||||
find('#application_setting_visibility_level_10').set(false)
|
||||
find('#application_setting_visibility_level_20').set(false)
|
||||
|
||||
click_button 'Save'
|
||||
|
||||
expect(page).to have_content "Application settings saved successfully"
|
||||
expect(find('#application_setting_visibility_level_0')).not_to be_checked
|
||||
expect(find('#application_setting_visibility_level_10')).not_to be_checked
|
||||
expect(find('#application_setting_visibility_level_20')).not_to be_checked
|
||||
end
|
||||
|
||||
scenario 'Change application settings' do
|
||||
uncheck 'Gravatar enabled'
|
||||
fill_in 'Home page URL', with: 'https://about.gitlab.com/'
|
||||
|
|
Loading…
Reference in New Issue