Enable to add a new Group after first unsuccessful adding #3164
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1523214
Enable to add a new Group after first unsuccessful adding of the Group because
of missing Name, in Administrator > Configuration, Access Control tab > Groups.
Explanation:
The two simple conditions were added to prevent the error (see the BZ above), which was caused here:
https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/ops_controller/ops_rbac.rb#L1425
@edit[:new][:filter_expression]
wasnil
, so the error occurred. It was set tonil
here:https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/ops_controller/ops_rbac.rb#L1252
The method
rbac_group_set_record_vars
is called right after the validation (see https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/ops_controller/ops_rbac.rb#L728) and even if it is not known if the validation was successful, the group record variables are set to new values, which is good only after successful validation (because of the if-else conditions inrbac_group_set_record_vars
which are very specific). So the condition https://github.com/ManageIQ/manageiq-ui-classic/compare/master...hstastna:Add_Group_empty_name_validate?expand=1#diff-8078c760e06b820719715450b2a112e0R729 was added and also validation was extended by adding one simple line https://github.com/ManageIQ/manageiq-ui-classic/compare/master...hstastna:Add_Group_empty_name_validate?expand=1#diff-8078c760e06b820719715450b2a112e0R1424 to consider also the name of a new group.This solution is simple and we don't have to reset variables
@edit[:new][:filters]
and@edit[:new][:filter_expression]
(changed inrbac_group_set_record_vars
method), if validation is not successful or if anything else breaks when creating/adding a new group (and we don't have to remember their values: we had to remember/save them, if we wanted to reset the variables after unsuccessful adding a group). And also none of the variables in the method are set (using fix in this PR) ifrbac_group_validate?
returnsfalse
, which is good. They are still set in the next try of adding a new group, after successful validation.Before:
After: