Skip to content
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

Conversation

lgalis
Copy link
Contributor

@lgalis lgalis commented Nov 6, 2017

  • Display the Generic objects from within the service controller
  • Display associated custom buttons for generic objects in the service controller

Links

https://www.pivotaltracker.com/story/show/150933586

screenshot from 2017-11-13 18-02-23
screenshot from 2017-11-13 18-02-29

@miq-bot miq-bot added the wip label Nov 6, 2017
@lgalis lgalis force-pushed the expose_generic_object_custom_buttons_on_service branch 4 times, most recently from 4b71981 to f039fcf Compare November 7, 2017 14:20
@lgalis lgalis requested a review from martinpovolny as a code owner November 7, 2017 14:20
@lgalis lgalis force-pushed the expose_generic_object_custom_buttons_on_service branch 4 times, most recently from 3f4d095 to 4ab0602 Compare November 7, 2017 15:12
@lgalis lgalis force-pushed the expose_generic_object_custom_buttons_on_service branch 7 times, most recently from b5ec5e6 to 2d165d4 Compare November 7, 2017 17:05
@lgalis
Copy link
Contributor Author

lgalis commented Nov 7, 2017

@miq-bot add_label enhancement, gaprindashvili/yes

@lgalis lgalis force-pushed the expose_generic_object_custom_buttons_on_service branch from 2d165d4 to 311b49a Compare November 7, 2017 19:39
@lgalis lgalis changed the title [WIP] Expose Custom Buttons for GenericObjects Expose Custom Buttons for GenericObjects Nov 7, 2017
@lgalis
Copy link
Contributor Author

lgalis commented Nov 7, 2017

@h-kataria - please review

@miq-bot miq-bot removed the wip label Nov 7, 2017
if id.present?
@lastaction = "generic_object"
@item = @record.generic_objects.find(from_cid(id)).first
drop_breadcrumb(:name => "#{@record.name} (All Generic Objects)",
Copy link
Contributor

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}

@lgalis lgalis force-pushed the expose_generic_object_custom_buttons_on_service branch from 311b49a to 37e908a Compare November 8, 2017 11:39
@lgalis
Copy link
Contributor Author

lgalis commented Nov 9, 2017

@miq-bot assign @h-kataria

@bzwei
Copy link
Contributor

bzwei commented Nov 10, 2017

In my test the custom button is not showing. The policy menu is not showing either.

@lgalis lgalis force-pushed the expose_generic_object_custom_buttons_on_service branch from 37e908a to 165c5e9 Compare November 13, 2017 13:44
@bzwei
Copy link
Contributor

bzwei commented Nov 13, 2017

@lgalis Another test showed that custom buttons created for the GenericObjectDefinition class through automation/automate/customize are showing, but not the ones created for GenericObjectDefinition instances created through #2569.

@lgalis lgalis force-pushed the expose_generic_object_custom_buttons_on_service branch 2 times, most recently from f1acdd4 to 1cb14f8 Compare November 13, 2017 16:59
@miq-bot
Copy link
Member

miq-bot commented Nov 13, 2017

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
10 files checked, 0 offenses detected
Everything looks fine. 🏆

@lgalis
Copy link
Contributor Author

lgalis commented Nov 13, 2017

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.

@dclarizio dclarizio merged commit 94a378d into ManageIQ:master Nov 13, 2017
@dclarizio dclarizio added this to the Sprint 73 Ending Nov 13, 2017 milestone Nov 13, 2017
Copy link
Member

@martinpovolny martinpovolny left a 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]
Copy link
Member

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?
Copy link
Member

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}")
Copy link
Member

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
Copy link
Member

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?

Copy link
Member

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"
Copy link
Member

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
Copy link
Member

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)
Copy link
Member

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
Copy link
Member

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"
Copy link
Member

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'
Copy link
Member

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.

@lgalis
Copy link
Contributor Author

lgalis commented Nov 14, 2017

@martinpovolny - I'll address your comments in a follow-up PR, I'll cc you on that when it's ready.

simaishi pushed a commit that referenced this pull request Nov 15, 2017
…tons_on_service

Expose Custom Buttons for GenericObjects
(cherry picked from commit 94a378d)
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit b443a8a144d9b91f13d78c18aa2c55e1f24ed263
Author: Dan Clarizio <[email protected]>
Date:   Mon Nov 13 15:50:56 2017 -0800

    Merge pull request #2636 from lgalis/expose_generic_object_custom_buttons_on_service
    
    Expose Custom Buttons for GenericObjects
    (cherry picked from commit 94a378dfe5cf0c62885f5cfe33bf2fe8101ec988)

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partial_locals is not defined here (broken on master)

don't know about Gaprindashvili

ping @lgalis

@lgalis lgalis deleted the expose_generic_object_custom_buttons_on_service branch March 16, 2018 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants