-
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
Expose Custom Buttons for GenericObjects #2636
Expose Custom Buttons for GenericObjects #2636
Conversation
4b71981
to
f039fcf
Compare
3f4d095
to
4ab0602
Compare
b5ec5e6
to
2d165d4
Compare
@miq-bot add_label enhancement, gaprindashvili/yes |
2d165d4
to
311b49a
Compare
@h-kataria - please review |
if id.present? | ||
@lastaction = "generic_object" | ||
@item = @record.generic_objects.find(from_cid(id)).first | ||
drop_breadcrumb(:name => "#{@record.name} (All Generic Objects)", |
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.
:name => _("%{name} (All Generic Objects)") % {:name => @record.name}
311b49a
to
37e908a
Compare
@miq-bot assign @h-kataria |
In my test the custom button is not showing. The policy menu is not showing either. |
37e908a
to
165c5e9
Compare
f1acdd4
to
1cb14f8
Compare
1cb14f8
to
d358336
Compare
Checked commits lgalis/manageiq-ui-classic@adb1ba9~...d358336 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 |
The visibility_text was fixed in the API PR #206 mentioned above and the non-group custom buttons are added to the toolbar - screenshot shows both the groups and single custom buttons. |
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 am late for the show. But there are numerous issues with this new code :-(
def generic_object | ||
return unless init_show_variables | ||
|
||
id = params[:show] || params[:x_show] |
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.
do we need both?
return unless init_show_variables | ||
|
||
id = params[:show] || params[:x_show] | ||
if id.present? |
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.
This whole block is surely repeated in places. I am quite sure there's a method or even methods that do this.
@item = @record.generic_objects.find(from_cid(id)).first | ||
drop_breadcrumb(:name => _("%{name} (All Generic Objects)") % {:name => @record.name}, | ||
:url => show_link(@record, :display => @display)) | ||
drop_breadcrumb(:name => @item.name, :url => "/#{controller_name}/show/#{@record.id}?display=generic_objects/show=#{id}") |
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.
We really should use methods for generating URLs. At least in new code. I we don't then things like restful routes will bite us again and again.
:url => show_link(@record, :display => @display)) | ||
drop_breadcrumb(:name => @item.name, :url => "/#{controller_name}/show/#{@record.id}?display=generic_objects/show=#{id}") | ||
@view = get_db_view(GenericObject) | ||
@sb[:rec_id] = id |
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.
why is this needed? so we really need sesssion here?
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 see it used above in button
by why is the normal mechanism used in all the buttons used here?
By doing this it seems there's a new place where opening multiple windows would break the app.
@@ -354,6 +354,11 @@ def view_to_url(view, parent = nil) | |||
if controller == "ems_network" && action == "show" | |||
return ems_networks_path | |||
end | |||
if request[:controller] == 'service' && view.db == 'GenericObject' | |||
controller = "service" |
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.
why is this line here? the variable is never used
@@ -237,22 +237,43 @@ def group_skipped?(name) | |||
x_edit_view_tb history_main ems_container_dashboard ems_infra_dashboard).include?(name) | |||
end | |||
|
|||
def cb_send_checked_list | |||
return true if %w(generic_objects).include?(@display) | |||
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.
the return true if
should be removed from the line
end | ||
|
||
def cb_enabled_for_nested | ||
return true if %w(generic_objects).include?(@display) |
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.
and here
if @display == 'generic_objects' | ||
return false if @lastaction == 'generic_objects' | ||
return true if @lastaction == 'generic_object' | ||
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.
This condition can be written in much nicer way.
Btw what is the expected result of the method if @display != 'generic_objects'
?
@@ -466,6 +466,8 @@ def center_toolbar_filename_classic | |||
elsif to_display_center.include?(@display) | |||
return "#{@display}_center" | |||
end | |||
elsif @display == 'generic_objects' | |||
return "#{@display}_center" |
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.
why the interpolation when we know the value?
do we want to prevent people grepping for generic_objects_center
?
@@ -24,6 +24,8 @@ def custom_toolbar_simple | |||
Mixins::CustomButtons::Result.new(:single) | |||
elsif @lastaction == "show_list" | |||
Mixins::CustomButtons::Result.new(:list) | |||
elsif @display == 'generic_objects' |
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.
So this is something that is going to be generic? This is a generic method used in many controllers.
If the generic objects are to be used on many places than ok. Otherwise the changes should be done in a redefined method in a controller class.
@martinpovolny - I'll address your comments in a follow-up PR, I'll cc you on that when it's ready. |
…tons_on_service Expose Custom Buttons for GenericObjects (cherry picked from commit 94a378d)
Gaprindashvili backport details:
|
@@ -385,7 +420,13 @@ def replace_right_cell(options = {}) | |||
elsif params[:display] | |||
r[:partial => 'layouts/x_gtl', :locals => {:controller => "vm", :action_url => @lastaction}] | |||
elsif record_showing | |||
r[:partial => "service/svcs_show", :locals => {:controller => "service"}] | |||
if action | |||
partial_locals[:item_id] = @item.id |
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.
Links
https://www.pivotaltracker.com/story/show/150933586