-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix deletion of Default Container Image Rate #3215
Fix deletion of Default Container Image Rate #3215
Conversation
@miq-bot add_label bug, gaprindashvili/yes |
d547bed
to
5b993ef
Compare
357d30e
to
52574c2
Compare
6d281ac
to
994031a
Compare
@gtanzillo @h-kataria @zeari @lpichler Could you check also this PR, if you will have some time? :) This PR is related to ManageIQ/manageiq#16792 which is already merged. The bug https://bugzilla.redhat.com/show_bug.cgi?id=1486658 will be completely fixed only after reviewing and merging also this PR. Merging only ManageIQ/manageiq#16792 does not fix the bug completely. Thanks! |
|
||
cb_rates_list | ||
@right_cell_text = _("%<typ>s Chargeback Rates") % {:typ => x_node.split('-').last} | ||
replace_right_cell(:replace_trees => [:cb_rates]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hstastna i have not tested this in UI but wondering why this was moved out of if/else block, i don't think we need to call cb_rates_list
and replace_right_cell methods if there were flash errors such as "no records selected for deletion" in that case we should simply render flash message partial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I remember, this was the best option to fix another issues (and to not break anything else) which came with fixing the bug: I came to the situation when I needed to render flash message if some error occurs AND to display remaining rates properly (which were not deleted or which shouldn't have been deleted). Because if we check more than one rate in the list and try to delete them, some of them are successfully deleted and some of them not (like Default rates) and we need to show error message AND the actual list of the rates (if/else block did not allow us to do it properly). We need to update the list after deleting. It was not the best that the if/else block came after deleting the rates. So this PR also allows us to delete the rates which can be deleted and to display error message if there was some error during deletion (for example if one rate was not able to be deleted, like default rate).
end | ||
else # showing 1 rate, delete it | ||
cb_rate = ChargebackRate.find_by_id(params[:id]) | ||
cb_rate = ChargebackRate.find_by(:id => params[:id]) | ||
self.x_node = x_node.split('_').first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hstastna same here, i think we don't need to reset value of x_node if cb_rate is nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed this for cb_rates_list
and replace_right_cell
methods which come after this block.
@hstastna verified in UI, you think you can add spec test around this? |
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1486658 Fix deletion of Default Container Image Rate in Cloud Intel -> Chargeback -> Rates so that the Rate can't be deleted and error message is displayed.
Add a spec test for fix for deletion of Default Container Image Rate in Cloud Intel -> Chargeback -> Rates so that the Rate can't be deleted and error message is displayed. The test covers all of the possibilities of deleting the rate (from the list or details page) when cb_rates_list method should be called (which was not like that before the fix). It also checks setting the right cell text which sometimes can cause another errors if it is not set properly. The test is extensible.
994031a
to
821c3d5
Compare
Checked commits hstastna/manageiq-ui-classic@8b05f8b~...821c3d5 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 |
@h-kataria @dclarizio This is ready to merge, I think :) |
…elete Fix deletion of Default Container Image Rate (cherry picked from commit 8806d61) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1552260
Gaprindashvili backport details:
|
@miq-bot add_label test |
@hstastna Can this and the dependent PR ManageIQ/manageiq#16792 be |
@simaishi I'm not sure. It depends on flags or target release in the BZ. Doesn't it? |
@hstastna The BZ has the 5.8.z flag, which is why I asked 😄 I just can't tell if you need to create a separate PR or that PRs can just be |
@simaishi I can't tell, too. Today I'm on sickday and I have access only to emails, github. Let's try to backport it and if some complicated conflicts occur, I will create a new PR asap. |
@miq-bot add_label fine/yes |
…elete Fix deletion of Default Container Image Rate (cherry picked from commit 8806d61) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1568084
Fine backport details:
|
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1486658
Depends on ManageIQ/manageiq#16792 [MERGED]
Fix deletion of Default Container Image Rate in Cloud Intel -> Chargeback
-> Rates so that the Rate can't be deleted and error message is displayed.
Also the spec tests were added to this PR.
Explanation:
Originally, checking if the selected rate is default (before its deletion), did not work well only if deleting rate(s) from a list of the rates. This was because of missing part of the condition for checking default rates here:
https://github.com/ManageIQ/manageiq/blob/master/app/models/chargeback_rate.rb#L153
Checking if the rate is default, worked only from rate details page. This was because of
https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/helpers/application_helper/button/chargeback_rate_remove.rb#L12
So I added the missing part of the condition here: https://github.com/ManageIQ/manageiq/compare/master...hstastna:Default_Container_Image_Rate_delete_description?expand=1#diff-7c998acd3d11c70ed830e216754f4b6bR153
I also edited
cb_rates_delete
method in chargeback controller (in this PR) to be able to properly delete nondefault rates and also to show error messages about deleting default rates - in a one step! I simplified some parts of the method to prevent issues with rendering flash messages in some special cases (if no rates were selected or if the rate no longer exists) or with showing the rates list after deleting the rates (if some of the all selected rates were successfully deleted but some of them not - and this is why I had to remove if-else condition at the end ofcb_rates_delete
method and to changerender_flash
toadd_flash
in the method to prevent multiple rendering issues.. this also required properly settingx_node
if deleting a rate from its details page - to properly show the list of remaining rates after the deletion, including the error messages, if there are some).The bug is related to Compute Chargeback rates.