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

Custom buttons for list views #796

Merged
merged 20 commits into from
Apr 13, 2017

Conversation

martinpovolny
Copy link
Member

@martinpovolny martinpovolny commented Mar 24, 2017

Adding custom button support for lists.

  • adding options when editing custom buttons
  • displaying custom toolbar or list screens
  • handling selection of multiple items by custom buttons
  • passing list of items to automate (partly, backend work needed to make all options work)

pivotal: https://www.pivotaltracker.com/story/show/140944305

I have disabled the "submit all" option in the UI as it is not (yet) supported by the backend.

cust-butt-list

cut-butt2

@miq-bot miq-bot removed the wip label Mar 24, 2017
@martinpovolny martinpovolny changed the title [WIP Custom buttons for list views [WIP] Custom buttons for list views Mar 25, 2017
@miq-bot miq-bot added the wip label Mar 25, 2017
@martinpovolny martinpovolny force-pushed the custom_buttons_list branch 2 times, most recently from f26b61f to 8c6ee08 Compare March 31, 2017 08:31
@martinpovolny martinpovolny force-pushed the custom_buttons_list branch 2 times, most recently from 33b39f1 to b5aab53 Compare April 10, 2017 11:55
@martinpovolny martinpovolny changed the title [WIP] Custom buttons for list views Custom buttons for list views Apr 10, 2017
@martinpovolny martinpovolny removed the wip label Apr 10, 2017
@@ -1484,6 +1484,10 @@ function miqToolbarOnClick(_e) {
} else {
params = miqSerializeForm(button.data('url_parms'));
}
} else if (button.data('url_parms').match("id=LIST")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@vecerek You will need to handle this case in #642 :)

(The id=LIST is needed by backend, but doesn't have to imply miq_grid_checks in general, just for the buttons touched here..)

@@ -239,62 +245,68 @@ def create_custom_button_hash(input, record, options = {})
:enabled => options[:enabled],
:klass => ApplicationHelper::Button::ButtonWithoutRbacCheck,
:url => "button",
:url_parms => "?id=#{record.id}&button_id=#{button_id}&cls=#{record.class}&pressed=custom_button&desc=#{button_name}"
:url_parms => "?id=#{record_id}&button_id=#{button_id}&cls=#{model}&pressed=custom_button&desc=#{button_name}"
Copy link
Contributor

Choose a reason for hiding this comment

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

@vecerek .. Aand this will need send_checked (#642)

@@ -8,20 +8,23 @@ def custom_toolbar?
end

def custom_toolbar_explorer?
Copy link
Contributor

@himdel himdel Apr 10, 2017

Choose a reason for hiding this comment

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

Should probably no longer have the question mark in the name, since it returns nil or a string :)

@himdel
Copy link
Contributor

himdel commented Apr 11, 2017

Verified in the UI checklist:

@himdel
Copy link
Contributor

himdel commented Apr 11, 2017

When multiple items are selected (and for=list or both) it shows Error executing: "both" Not implemented. .. maybe something like Actions on multiple entities are not implemented.?

EDIT: aah, fixed when cb.options[:submit_how] = "one"

@himdel
Copy link
Contributor

himdel commented Apr 11, 2017

When no items are selected (and for=list or both), it dies with undefined method 'name' for nil:NilClass [cloud_tenant/button]

[NoMethodError] undefined method `name' for nil:NilClass
/home/himdel/manageiq-ui-classic/app/controllers/application_controller/buttons.rb:292:in `custom_buttons'
/home/himdel/manageiq-ui-classic/app/controllers/cloud_tenant_controller.rb:24:in `button'

EDIT: fixed, No item was selected.

@himdel
Copy link
Contributor

himdel commented Apr 11, 2017

@martinpovolny Looks like you may have missed Storage > {Block, Object} Storage > Managers - you can see the Provider custom buttons in detail view, but not in list view.

@martinpovolny
Copy link
Member Author

@himdel : Do you think that this mergeable w/o those added? I'll follow up with a PR making sure that the buttons are displayed there too.

@himdel
Copy link
Contributor

himdel commented Apr 11, 2017

@martinpovolny Sure, no problem with that :).

Another bug..

  1. Go to Compute > Clouds > Instances
  2. accordion Images by Provider or Images
  3. pick one in the list, click a list or both button
  4. Error executing custom button: No item was selected.

(Works in the detail for the same thing.)

The same happens in Compute > Infrastructure > Virtual Machines, accordion Templates, and also happens in the "VMs & Templates" accordion when a Template is selected.

... so, any templates or images in list view.

(Not sure if it makes sense to merge without this one..?)

@martinpovolny
Copy link
Member Author

Looking into it. I am not sure what is the desired behavior here. It's probably not going to be a quick fix.

@martinpovolny
Copy link
Member Author

martinpovolny commented Apr 11, 2017

  def toolbar_class(toolbar_name)                                                                   
    if Mixins::CustomButtons::Result === toolbar_name                                               
      model = @record ? @record.class : controller.class.model                                      
      custom_....

Holy crappa. This is much complex, because for the explorer-based controller and lists being displayed the class of the elements displayed depends on the node selected in the tree. Not just simply controller.class.model :-(

There needs to be some logic that will tell the class of the stuff being shown in the GTL and that needs to be called for the custom toolbar.

@martinpovolny
Copy link
Member Author

@martinpovolny Looks like you may have missed Storage > {Block, Object} Storage > Managers - you can see the Provider custom buttons in detail view, but not in list view.

@himdel : as for these: I don't have data to test or debug this, do you?
But reading the code: neither app/controllers/ems_object_storage_controller.rb nor app/controllers/ems_block_storage_controller.rb include has_custom_buttons line so there should be no custom toolbars. Of course unless there's some crazy exception logic somehwere that I have not found.

There's has_custom_buttons in ems_storage_controller however. But I have no idea, how to access that controller :-(

To the point: I think I have fixed the issue that you have found and that has been a blocker here. For the issues about storages I think I need more input from the managers. I have no idea how that is supposed to work :-(

@miq-bot
Copy link
Member

miq-bot commented Apr 12, 2017

Checked commits martinpovolny/manageiq-ui-classic@5fd1d21~...19f4fe9 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
11 files checked, 4 offenses detected

app/helpers/application_helper/toolbar_builder.rb

app/views/shared/buttons/_ab_form.html.haml

  • ⚠️ - Line 59 - Line is too long. [169/160]

app/views/shared/buttons/_ab_show.html.haml

  • ⚠️ - Line 41 - Comment should have a space after the #
  • ⚠️ - Line 41 - Missing space after #.

@himdel himdel added this to the Sprint 59 Ending Apr 24, 2017 milestone Apr 13, 2017
@himdel himdel merged commit 631a325 into ManageIQ:master Apr 13, 2017
@himdel
Copy link
Contributor

himdel commented Apr 13, 2017

LGTM, tested in the UI 👍.

The only screen this does not work on (except for the separate issues linked above), is the VMs & Templates accordion in infra.. but.. well, we have no custom buttons for VmOrTemplate, so it makes sense :). And it does work in the VMs and Templates accorddions, and in single-item views in VMs & Templates.

@himdel
Copy link
Contributor

himdel commented Apr 13, 2017

@martinpovolny is this fine/yes?

simaishi pushed a commit that referenced this pull request Apr 13, 2017
Custom buttons for list views
(cherry picked from commit 631a325)
@simaishi
Copy link
Contributor

Fine backport details:

$ git log -1
commit 5765bd9c0decf6140a3a06c18db2c048428bbe67
Author: Martin Hradil <[email protected]>
Date:   Thu Apr 13 13:04:42 2017 +0000

    Merge pull request #796 from martinpovolny/custom_buttons_list
    
    Custom buttons for list views
    (cherry picked from commit 631a3259f26d2a6b0aa38cc5d14f17fbe3ac56e2)

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.

4 participants