Fix applying filter from Advanced Search in My Services #4645
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=1627078
There is a problem in My Services page while applying filter from Advanced Search: error occurs and the filter is not applied.
Steps to reproduce:
=> error:
How reproducible:
not always, I have figured out that it also depends on which fields we choose in expression editor in Adv Search or how the expression looks like (sometimes we have more options to choose or more fields to set up, sometimes we choose only true/false for some specific fields)
Before:
After:
Note:
The problem happens here https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/application_controller.rb#L1517 where we set the
filter
which is about to be applied, and@edit[:adv_search_applied][:exp]
contains:token
key which is unnecessary here and it only causes problems here: https://github.com/ManageIQ/manageiq/blob/master/app/models/miq_report/search.rb#L108 becauseoptions
contain the expression with the:token
key (and its value). The solution is to set@edit[:adv_search_applied][:exp]
properly by usingcopy_hash
to make a proper copy of@edit[:new][@expkey]
, otherwise if@edit[:new][@expkey]
changes (token is added inexp_build_table
method),@edit[:adv_search_applied][:exp]
changes, too, so that it also contains unnecessary token.