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 displaying services after applying a filter (2) #3654

Conversation

hstastna
Copy link

@hstastna hstastna commented Mar 20, 2018

fixing issue: #3261
more info: #3395

Fix displaying services after applying a filter and clicking on an other node in tree (Active/Retired Services folder), in Services > My Services page so that Active/Retired services without filtering are displayed.


Details of a problem:
There is an issue in My Services page, after applying/clicking on some filter from Global/My Filters in accordion: if we click on an other node in tree, for example Active Services (or Retired Services), services are not displayed properly: there is inconsistency between displayed services and the title of the page, filter is applied on Active or Retired services, not on all of the services.

Steps to reproduce:

  1. Go to Services > My Services page
  2. Click on some filter from accordion (from Global/My Filters folder)
    and you will see that filtering is applied on all of the services (this works right)
  3. Click on Active Services (or Retired Services) node in the tree in accordion
    => you will see active (or retired) services, filtered by previously selected filter, without any " - Filtered by name_of_filter"

Step 2:
filtered_active

Before: (step 3)
active
retired

After: (the title is consistent with services displayed on the page)
active
retired

Notes: When fixing the problem, I also had to deal with normal Search - to keep it working without any changes which lead to adding a necessary condition to resetting some values of session in get_node_info.

@hstastna
Copy link
Author

@miq-bot add_label bug, services, expressions/filters

@hstastna
Copy link
Author

@dclarizio @h-kataria @lgalis Now it should work right ;)

@h-kataria
Copy link
Contributor

@hstastna this is not the correct solution because, this is clearing everything that's stored in session[:adv_search] such as selected filters for other screens/controllers. If you go to list of Hosts and select a filter there, then leave and come back to Host list view, it remembers which filter user had selected previously, but with this change all the previously selected filters for other screens during the session are getting lost. I think we need to look at other screens to figure out how those are handling the same scenario.

Steps to recreate:

  1. Go to list of Hosts, select some filter.
  2. Now go out to lets say Storage main tab.
  3. Then back to Hosts tab, screen is presented with the previously selected filter that you chose before going to Storage main tab.
  4. Now go to My Services, test the fix in this PR
  5. Go back to Hosts, filter selection is no longer present, you will see All Hosts selected.

@hstastna hstastna changed the title Fix displaying services after applying a filter (2) [WIP] Fix displaying services after applying a filter (2) Mar 21, 2018
@miq-bot miq-bot added the wip label Mar 21, 2018
@hstastna hstastna force-pushed the Apply_filter_click_node_Services_display_title2 branch from 18c2eca to e36813b Compare March 22, 2018 10:54
@hstastna
Copy link
Author

hstastna commented Mar 22, 2018

@h-kataria I made a change and now it should work, your scenario is not reproducible anymore. Anyway, using listnav_search_selected or clear_selected_search did not work, we cannot use it here because @edit is nil if we enter get_node_info method in service controller so then calling listnav_search_selected or clear_selected_search from there would lead to error because those methods work with @edit.

@hstastna hstastna changed the title [WIP] Fix displaying services after applying a filter (2) Fix displaying services after applying a filter (2) Mar 22, 2018
@miq-bot miq-bot removed the wip label Mar 22, 2018
@hstastna
Copy link
Author

@miq-bot add_label gaprindashvili/yes

@hstastna
Copy link
Author

@h-kataria Could you please look at my change in this PR? Thanks! ⭐

fixing ManageIQ#3261

Fix displaying all services after applying a filter and clicking
on an other node in tree, in Services > My Services page.
@hstastna hstastna force-pushed the Apply_filter_click_node_Services_display_title2 branch from e36813b to d6db487 Compare April 26, 2018 10:05
@hstastna
Copy link
Author

@h-kataria, @skateman I've added some spec test for the fix. Feel free to comment, discuss. Thanks! ✨

@@ -103,7 +103,7 @@
end
end

context "#show" do
describe "#show" do
Copy link
Member

Choose a reason for hiding this comment

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

😍

@@ -182,7 +182,7 @@
expect(response).to redirect_to(:action => 'explorer', :id => "s-#{service.id}")
end

context "#button" do
describe "#button" do
Copy link
Member

Choose a reason for hiding this comment

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

😍

@@ -211,7 +211,7 @@
end
end

context "#sanitize_output" do
describe "#sanitize_output" do
Copy link
Member

Choose a reason for hiding this comment

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

😍

end
end

def reset_session_values
Copy link
Member

Choose a reason for hiding this comment

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

Please don't define methods in tests if it's not absolutely necessary. Having a duplication in this case is totally fine IMO.

Copy link
Author

Choose a reason for hiding this comment

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

I see methods in test in many places where I consider it as less necessary than here :D ;) But, yeah, I will change this! ;)

end

def reset_session_values
expect(controller.session[:edit]).to be(nil)
Copy link
Member

Choose a reason for hiding this comment

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

be_nil

Copy link
Author

Choose a reason for hiding this comment

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

👼


def reset_session_values
expect(controller.session[:edit]).to be(nil)
expect(controller.session[:adv_search]["Service"]).to be(nil)
Copy link
Member

Choose a reason for hiding this comment

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

be_nil

context 'clicking on Active/Retired Services node in the tree, after applying a filter' do
describe '#get_node_info' do
before do
allow(controller).to receive(:session).and_return(:adv_search => {"Service" => {:expression => {}}}, :edit => {:expression => {}})
Copy link
Member

Choose a reason for hiding this comment

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

Could you make this a little bit more readable? Maybe expand it into multiple lines? Or just my screen is too small? 😉

Copy link
Author

@hstastna hstastna Apr 26, 2018

Choose a reason for hiding this comment

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

That's problem of github.. I sometimes have the same problems. Or I can use let ;) Anyway:
allow(controller).to receive(:session).and_return(:adv_search => {"Service" => {:expression => {}}}, :edit => {:expression => {}})

Add spec test which checks resetting session values to same values as first time in.
@hstastna hstastna force-pushed the Apply_filter_click_node_Services_display_title2 branch from d6db487 to 4f5ee64 Compare April 26, 2018 11:33
Copy link
Member

@skateman skateman left a comment

Choose a reason for hiding this comment

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

The Seal of Approval

@miq-bot
Copy link
Member

miq-bot commented Apr 26, 2018

Checked commits hstastna/manageiq-ui-classic@1df3f00~...4f5ee64 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🏆

@hstastna
Copy link
Author

@h-kataria I think this PR is ready :)

@h-kataria h-kataria added this to the Sprint 87 Ending Jun 4, 2018 milestone May 23, 2018
@h-kataria h-kataria merged commit 169064b into ManageIQ:master May 23, 2018
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