-
Notifications
You must be signed in to change notification settings - Fork 357
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
Use copy_params_if_present in report, miq_policy and pxe controllers #6155
Use copy_params_if_present in report, miq_policy and pxe controllers #6155
Conversation
@miq-bot add_label technical debt |
@miq-bot add_reviewer @romanblanco Roman, this should be all the remaining possible changes regarding using |
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 changes look good!
found some more places where we can use copy_param(s)_if_present
targets = Rbac.filtered(params[:target_class]).select(:id, *columns_for_klass(params[:target_class])) if params[:target_class].present? | ||
unless targets.nil? | ||
@resolve[:targets] = targets.sort_by { |t| t.name.downcase }.collect { |t| [t.name, t.id.to_s] } | ||
@resolve[:new][:target_id] = nil | ||
end | ||
end | ||
@resolve[:new][:target_id] = nil if params[:target_class] == "" | ||
@resolve[:new][:target_id] = params[:target_id] if params.key?(:target_id) | ||
@resolve[:new][:target_id] = nil unless params[:target_class] | ||
@resolve[:button_text] = params[:button_text] if params.key?(:button_text) | ||
@resolve[:button_number] = params[:button_number] if params.key?(:button_number) |
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.
- @resolve[:button_text] = params[:button_text] if params.key?(:button_text)
- @resolve[:button_number] = params[:button_number] if params.key?(:button_number)
+ copy_params_if_present(@resolve, params, %i[button_text button_number])
ApplicationController::AE_MAX_RESOLUTION_FIELDS.times do |i| | ||
f = ("attribute_" + (i + 1).to_s) | ||
v = ("value_" + (i + 1).to_s) | ||
@resolve[:new][:attrs][i][0] = params[f] if params[f.to_sym] | ||
@resolve[:new][:attrs][i][1] = params[v] if params[v.to_sym] | ||
end | ||
@resolve[:new][:target_class] = params[:target_class] if params[:target_class] | ||
# @resolve[:new][:target_attr_name] = params[:target_attr_name] if params.has_key?(:target_attr_name) |
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.
the commented code can be removed
@@ -86,18 +86,14 @@ def action_field_changed | |||
@action = @edit[:action_id] ? MiqAction.find(@edit[:action_id]) : MiqAction.new | |||
|
|||
@edit[:new][:description] = params[:description].presence if params[:description] |
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.
- @edit[:new][:description] = params[:description].presence if params[:description]
+ copy_param_if_present(@edit[:new], params, %i[description])
2da9a2b
to
56fa533
Compare
56fa533
to
6735efd
Compare
Checked commit hstastna@6735efd with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
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.
LGTM 👍
Issue: #6105
This is another PR with use of
copy_params_if_present
method in some controllers.With
copy_params_if_present
, we improve functionality (remove""
vsnil
issues and bad response of Add/Save buttons) or we simplify the code.Similar PRs/changes:
#6152
#6139
#5815
d3c3878#diff-956e46b33fb5307990c4e1a4b5fd86ccR1267