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

Search fixes for VmInfra #2842

Merged
merged 5 commits into from
Dec 4, 2017
Merged

Conversation

martinpovolny
Copy link
Member

@martinpovolny martinpovolny commented Nov 27, 2017

Fixing:
https://bugzilla.redhat.com/show_bug.cgi?id=1517392

I believe that earlier the @explorer branch worked for vm_infra. #2556 the added @layout test but that works just in some cases (as shown in https://bugzilla.redhat.com/show_bug.cgi?id=1517392).
So I am removing that.

Also the test for 'miq_policy' == @layout seems duplicate to testing @explorer because under Control/Explorer/Policies accordion where this holds true @explorer is also set.

But the root clause here is the improperly set @explorer variable -- added a .to_s to the check. I am not sure why params[:explorer] is a bool so that is the safest.

I am removing a strangeness with unless @display being only tested only if ::Settings.server.case_sensitive_name_search that seems to be a bug.

I am moving the session[:menu_click] condition to the front because if chart pop-up menu click we want the filtering disabled and no matter with branch of the condition passes.

I need more eyes and I need a list of screens where search is expected to work.

I can still break the search if I keep the search on and dive deep enough following the relations. But that is not to be fixed here. That might need changes not suitable for Gaprindashvili at this point.

Added specs for VmInfra search and Host search. More can be added following the pattern but I need to move forward.

Ping @mzazrivec, @himdel, @hstastna . Please, review.

If we would be able to make a list of places where search should work, it woud be nice.

Ping @dclarizio, @h-kataria : please, chime in if you have inputs on this.

TODO

  • WIP: fixing the search breaks nested list under VM such as VM --> {processes,files}. Working on that by passing @display throught the GTL.

Related problem

  • Seems to me that: Clear Search box text #1893 breaks "clear search button" functionality in Hosts. Actually It can be worker around by filling in an empty string instead of using the (broken) button. So no need to fix that here. Actually the PR did not break it. It just fixed only the non-explorer ones.

@martinpovolny martinpovolny changed the title [WI] Search fixes [WIP] Search fixes Nov 27, 2017
@martinpovolny martinpovolny self-assigned this Nov 28, 2017
@martinpovolny martinpovolny force-pushed the search_fixes branch 3 times, most recently from 770a5a1 to 384270f Compare November 28, 2017 15:10
@martinpovolny martinpovolny changed the title [WIP] Search fixes Search fixes for VmInfra Nov 28, 2017
@martinpovolny martinpovolny removed the wip label Nov 28, 2017
@martinpovolny martinpovolny changed the title Search fixes for VmInfra [WIP] Search fixes for VmInfra Nov 29, 2017
@karelhala
Copy link
Contributor

Since this PR has @explorer = params[:explorer].to_s == "true" it also fixes this bug https://bugzilla.redhat.com/show_bug.cgi?id=1516629
FYI @skateman

Fixing the root cause -- the @explorer not being set properly.
Then cleaning up the conditions (some seem to be workarounds around
@explorer not being set).

Also fixing a strange difference between
::Settings.server.case_sensitive_name_search true/false
@diplay is getting passed through the session already. But the 'null'
value never get's through due to:

 def set_session_data
   ..
   session["#{prefix}_display".to_sym]    = @display unless @display.nil?

I dare not change that as it might break just anything.

Yet for the GTL I need also the nil value for @display. Specificaly
@display is used to check if @search_test shall be applied as a filter
to data in the GTL grid. This a very broken way of doing things but
fixing that is no a task for Gaprindashvili.

So I am just adding code to pass @display through the grid and restore
it in /report_data.
@martinpovolny martinpovolny changed the title [WIP] Search fixes for VmInfra Search fixes for VmInfra Nov 29, 2017
@miq-bot miq-bot removed the wip label Nov 29, 2017
@martinpovolny
Copy link
Member Author

martinpovolny commented Nov 29, 2017

Note:

When I click [x] in Hosts I get:
Request URL:http://localhost:3000/host/adv_search_text_clear?in_explorer=

adv_search_text_clear is the newly added method here #1893

and there's no else branch for non-explorers there. So this could never work.

I am not fixing that here.

@himdel
Copy link
Contributor

himdel commented Dec 1, 2017

Code looks good, but I still can't figure out when params[:explorer].to_s == "true" would be different from the old version - where does this come from? Can params[:anything] ever be a bool?

(Also not quite seeing a relation between that line, and the removal of %w(miq_policy vm_infra).include?(@layout)), but will test that it's there :).)

(Yet to test..)

@hstastna
Copy link

hstastna commented Dec 1, 2017

I am not sure about the other things but I agree with removal of
%w(miq_policy vm_infra).include?(@layout)
In the past, when I was fixing Search in vm infra, I was afraid to break things so I fixed that the simplest way and didn't know about more Search places which need fixing. Now it looks like this was not enough because more screens have problems with Search so it it obvious that it was not the best fix. I like the way you deal with it here. It looks good to me. I just want to test this on some more screens where I have found problems with Search, screens where it does not work at all (not just in some specific scenario).

)
results = assert_report_data_response
expect(results['data']['rows'].length).to eq(1)
expect(results['data']['rows'][0]['long_id']).to eq(h1.id)
Copy link
Contributor

@himdel himdel Dec 1, 2017

Choose a reason for hiding this comment

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

This will need to eq(h1.id.to_s) - #2902

(depending on which one is merged first :))

)
results = assert_report_data_response
expect(results['data']['rows'].length).to eq(1)
expect(results['data']['rows'][0]['long_id']).to eq(vm1.id)
Copy link
Contributor

Choose a reason for hiding this comment

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

This will need to eq(h1.id.to_s) - #2902

(depending on which one is merged first :))

@himdel
Copy link
Contributor

himdel commented Dec 1, 2017

I am not sure about the other things but I agree with removal of
%w(miq_policy vm_infra).include?(@layout)

Perfect, do you know why it's no longer needed then? :)

@martinpovolny
Copy link
Member Author

martinpovolny commented Dec 1, 2017

  1. params[:explorer] was a bool
  2. therefore @explorer was not true
  3. therefore that part of the condition did not pass and
  4. therefore @hstastna 's fix partly fixed the problem

@hstastna
Copy link

hstastna commented Dec 1, 2017

yes, I haven't seen it before (when I was fixing it some time ago). Simply, true is not the same as "true".

@himdel
Copy link
Contributor

himdel commented Dec 1, 2017

@martinpovolny I'm trying to find out how it happens that params[:explorer] is bool.

AFAIK params is rails magic and should always be just strings from the query string, shouldn't it? (Or strings from POST data.)
(Maybe if we had some POST requests which post json data, but I'm not aware of any such.)

therefore @hstastna 's fix partly fixed the problem

So.. there's some context in some other PR?

@skateman
Copy link
Member

skateman commented Dec 1, 2017

@himdel if you set the content type to JSON in a POST request and send it with the following body:

{
  "explorer": true,
  "exploder": "true"
}

Then the params will ✨ ✨ look like this:

params = { 'explorer' => true, 'exploder' => 'true' }

@himdel
Copy link
Contributor

himdel commented Dec 1, 2017

Oh ok, so I just didn't know we ever do a JSON POST 👍.

Asuming this comes from the GTL component?

Great, now only to test it :)

@martinpovolny
Copy link
Member Author

So.. there's some context in some other PR?

f0861de

Asuming this comes from the GTL component?

yes

@martinpovolny
Copy link
Member Author

@skateman, @hstastna, @himdel : if you happen to know where else in the application we have search, please, make a note into this PR.

I'd like to have test coverage for all the searches and actually have a list of the places for furute refactorings. Thx!

@hstastna
Copy link

hstastna commented Dec 1, 2017

@martinpovolny I have tested that this PR fixes Search also in Configuration Management Configured Systems page. It also works together with my PR #2424. I will continue with testing on some more pages.
This PR also fixes https://bugzilla.redhat.com/show_bug.cgi?id=1509318 . Should I mark it as a dup of yours or not?

@martinpovolny
Copy link
Member Author

@hstastna: if this PR fixes another BZ then please, mark it as DUP. Thank you!

@skateman
Copy link
Member

skateman commented Dec 1, 2017

@martinpovolny as @karelhala mentioned above, this also fixes an issue with catalog grid view change, but it's not quite a duplicate.

@martinpovolny
Copy link
Member Author

martinpovolny commented Dec 4, 2017

We should merge this one ASAP.

  • For one, it's fixing a number of BZs and
  • for two it changes a frequent codepath and If we merge it right before the build we will have no chance to catch any possible regressions.

@miq-bot
Copy link
Member

miq-bot commented Dec 4, 2017

Some comments on commits martinpovolny/manageiq-ui-classic@60a16a1~...d9835ed

spec/controllers/host_controller_spec.rb

  • ⚠️ - 360 - Detected expect_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.

spec/controllers/vm_infra_controller_spec.rb

  • ⚠️ - 545 - Detected expect_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.

@miq-bot
Copy link
Member

miq-bot commented Dec 4, 2017

Checked commits martinpovolny/manageiq-ui-classic@60a16a1~...d9835ed with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0
5 files checked, 1 offense detected

app/controllers/application_controller.rb

@himdel
Copy link
Contributor

himdel commented Dec 4, 2017

Note:

#2842 (comment)

is also happening in Control > Explorer

@himdel himdel merged commit e4e87c6 into ManageIQ:master Dec 4, 2017
@himdel
Copy link
Contributor

himdel commented Dec 4, 2017

Code looks good, not seeing any breakage around miq policy either.. merged :).

@himdel himdel added this to the Sprint 75 Ending Dec 11, 2017 milestone Dec 4, 2017
@simaishi
Copy link
Contributor

simaishi commented Dec 4, 2017

Gaprindashvili backport details:

$ git log -1
commit ed8d48c7071c4538ea275abe30272f448f1a7eee
Author: Martin Hradil <himdel@seznam.cz>
Date:   Mon Dec 4 15:00:11 2017 +0000

    Merge pull request #2842 from martinpovolny/search_fixes
    
    Search fixes for VmInfra
    (cherry picked from commit e4e87c6bb321642acaa1f475bddd17fd3361cad3)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1520667
    https://bugzilla.redhat.com/show_bug.cgi?id=1520553

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.

None yet

7 participants