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

fix find_checked_items #4355

Closed

Conversation

matheuscmelo
Copy link
Contributor

if :miq_grid_checks is not present in params, this method only returns 1 or no ids.
this PR fixes it.

@miq-bot
Copy link
Member

miq-bot commented Jul 25, 2018

Checked commit matheuscmelo@d22aeba with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. 🏆

@martinpovolny
Copy link
Member

ping @romanblanco , @PanSpagetka

@PanSpagetka
Copy link
Contributor

With @romanblanco we are trying to verify this change, but we are having some troubles with reproducing it. This else branch is related to legacy code so I wonder where you have encountered issue which lead you to this change. Could you please describe situation when this fix does help you?

@romanblanco
Copy link
Member

With @romanblanco we are trying to verify this change, but we are having some troubles with reproducing it. This else branch is related to legacy code so I wonder where you have encountered issue which lead you to this change. Could you please describe situation when this fix does help you?

@matheuscmelo I've tried the temporary fix you've mentioned in a chat:

:klass => ApplicationHelper::Button::PhysicalServerProvision

changing this class to ApplicationHelper::Button::ConfiguredSystemProvision should fix this for a while

but this takes me just to a routing error

@himdel
Copy link
Contributor

himdel commented Jul 30, 2018

Testing:

[11] pry(#<EmsCloudController>)> @_params[:check_1234] = "1"                             
=> "1"                                                                                   
[12] pry(#<EmsCloudController>)> @_params[:check_10r25] = "1"                            
=> "1"                                                                                   
[13] pry(#<EmsCloudController>)> @_params[:check_11_12_13] = "1"                         
=> "1"                                                                                   
[14] pry(#<EmsCloudController>)> params                                                  
=> <ActionController::Parameters {"controller"=>"ems_cloud", "action"=>"show", "id"=>"38", "check_11_12_13"=>"1", "check_1234"=>"1", "check_10r25"=>"1"} permitted: false>

> find_checked_items                                      
=> ["11_12_13", "1234", "10r25"]

Verified that the method works as intended.

(Accepting a value different than "1" would mean all legacy checkboxes are considered checked.)

@matheuscmelo
Copy link
Contributor Author

The issue I'm trying to fix is this:
peek 2018-07-30 13-11
It appears in the Physical Servers page. To access the provision screen I'm changing the class of the button from this page because of another bug we're trying to fix, it looks like this:
(In manageiq-ui-classic/app/helpers/application_helper/toolbar/physical_servers_center.rb, from line 232)

select(
        :physical_server_lifecycle_choice,
        'fa fa-recycle fa-lg',
        t = N_('Lifecycle'),
        t,
        :enabled => true,
        :items   => [
          button(
            :physical_server_provision,
            'pficon pficon-add-circle-o fa-lg',
            t = N_('Provision Physical Server'),
            t,
            :url       => "provision",
            :url_parms => "main_div",
            :onwhen    => "1+",
            :klass     => ApplicationHelper::Button::ConfiguredSystemProvision
          )
        ]
      )

@himdel
Copy link
Contributor

himdel commented Jul 31, 2018

@matheuscmelo and what's in params when that happens?

@matheuscmelo
Copy link
Contributor Author

@himdel {"check_1"=>"1", "check_2"=>"2", "controller"=>"physical_server", "action"=>"provision"}

@matheuscmelo
Copy link
Contributor Author

@romanblanco @PanSpagetka @himdel any news?

@himdel
Copy link
Contributor

himdel commented Aug 7, 2018

@matheuscmelo Ah, sorry about that...

So.. I don't think we can change the behaviour of find_checked_items, this may still break some older checkboxes. (Or we need to finish the GTL cleanup to be sure there are no older checkboxes remaining.) ((GTL = grid/table/list .. the component to display multiple items))

The reason you're getting those check_123 => 123 values is that the new GTL really uses those values, so we could make sure GTL sends the right value - that would be https://github.com/ManageIQ/ui-components/blob/master/src/gtl/components/data-table/data-table.html#L45-L46 .
(Fixing this there should not break anything as far as I'm aware.)

But... however much I'm trying, I can't reproduce your problem...
Any chance I'm missing a step?:

Go to Compute > Physical Infrastructure > Providers (url = /ems_physical_infra/show_list)
Select 2 items in the list
Click a toolbar button

... what I'm seeing in the request:

miq_grid_checks: 25,54
check_25: 25
check_54: 54

So.. while those check_* are indeed wrong, you should never be hitting that code path in the first place, as miq_grid_checks is available.

TLDR: check_* is obsolete, make sure miq_grid_checks is available instead.

@matheuscmelo
Copy link
Contributor Author

@himdel actually it only occurs in Lifecycle > Provision button. If you select the first and others servers, it only indicates the first. If you don't select the first and select others, it blows a error.

@douglasgabriel
Copy link
Member

I've just analyze a little bit the problem and I think that we can solve this issue by adding :send_checked => true property on button definition. Like this:

button(
    :physical_server_provision,
    'pficon pficon-add-circle-o fa-lg',
    t = N_('Provision Physical Server'),
    t,
    :url       => "provision",
    :send_checked => true,
    :url_parms => "main_div",
    :klass     => ApplicationHelper::Button::PhysicalServerProvision
)

This way the miq_grid_checks is filled.

@martinpovolny
Copy link
Member

👍

I've just analyze a little bit the problem and I think that we can solve this issue by adding :send_checked => true property on button definition. Like this:

yes, that should be set

@matheuscmelo
Copy link
Contributor Author

Thanks @douglasgabriel for the answer and @himdel @PanSpagetka @martinpovolny @romanblanco for the help. I'll open another PR and close this one.

@matheuscmelo matheuscmelo deleted the fix_find_checked_items branch August 8, 2018 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants