-
Notifications
You must be signed in to change notification settings - Fork 896
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
Refactor toolbar builder #12025
Refactor toolbar builder #12025
Conversation
a0b8a9f
to
f70406b
Compare
eeffc44
to
5bed11a
Compare
fb15c81
to
3b919e6
Compare
3b919e6
to
648fc60
Compare
A lot of methods still has prefix from time, when these methods were in application controller. In this commit I'm changing method names to be more specific and also trying to provide at least basic description of what does the methods do
Don't call methods for setting buttons properties in '#skipped?' method, where we check if the button should be rendered.
Call '#skipped?' method that determines if the buttons should be rendered earlier in the code
@@ -58,8 +58,7 @@ def all_instance_variables_set | |||
def skipped? | |||
return true unless role_allows_feature? | |||
return true unless all_instance_variables_set | |||
calculate_properties | |||
!visible? | |||
return !visible? |
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.
extra return
nil | ||
else | ||
apply_common_props(button, inputs) | ||
end |
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.
button.skipped? ? nil : apply_common_props(button, inputs)
or early return:
return nil if button.skipped?
apply_common_props(button, inputs)
any of the 2 is more readable than the above imho
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.
@martinpovolny updated, thanks!
Looks good. My only concern: are you sure that none of the |
@PanSpagetka @jzigmund @vecerek: can you check the |
@martinpovolny I've checked all current |
648fc60
to
410399c
Compare
Checked commits romanblanco/manageiq@db53fee~...410399c with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 app/helpers/application_helper/button/basic.rb
app/helpers/application_helper/toolbar_builder.rb
|
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.
@martinpovolny we checked the visible
methods with @romanblanco and the changes seem to be fine. No problem encountered.
end | ||
end | ||
|
||
context "build_toolbar" do | ||
context "loolbar_class" do |
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.
@romanblanco here you have a typo
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.
@vecerek lool
😄 nice catch! 👍 I'll fix it in another PR, thanks
We need to chane control flow, so we don't need to evaluate procs of toolbars for buttons that are going to be skipped, and avoid situations like this
/cc @PanSpagetka @martinpovolny @jzigmund @vecerek