Resolve "Unable to disable all restricted visibility levels"
What does this MR do?
Allows admin to disable all restricted visibility levels
Are there points in the code the reviewer needs to double check?
The problem was that when we disabled all radio buttons the param was not sent to the controller so the application settings did not know they had to update the resricted_visibility_levels
attribute.
I tried using collection_radio_buttons
but failed to do so because the second parameter expects a single value and restricted_visibility_levels
is a collection (Array).
I also tried to replicate the same behaviour as the collection_radio_buttons
by adding a hidden_field with an empty value when the radio_button was unchecked but it failed as well since using both ''
and nil
would result in the restricted_visibility_levels
being updated to [0, 0, 0]
and 0
is a valid visibility level which would result in always having that option checked.
I then ended up adding a default value to that parameter inside ApplicationSetting::UpdateService
so that if the parameter is not specified it will be updated to []
. Although I am not entirely confident in this solution and will gladly take opinions on this.
Why was this MR needed?
The form was not letting admins disable all visibility levels at once and was forcing one visibility level being forced at all times.
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated -
API support added - Tests
-
Added for this feature/bug -
All builds are passing
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Branch has no merge conflicts with master
(if it does - rebase it please) -
Squashed related commits together
What are the relevant issue numbers?
Closes #32408 (closed)