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

Display Cancel after applying changes in non-explorer Compare screen #6542

Merged

Conversation

hstastna
Copy link
Contributor

@hstastna hstastna commented Dec 12, 2019

Issue: #6481

Cancel button "disappeared" after applying changes in Comparison Sections while comparing selected items displayed in a non-explorer screen. This happened because @explorer was accidentaly set to true.

The problem was that %w[VMs Templates].include?(session[:db_title]) condition in sections_field_changed was simply not enough to set @explorer variable properly. The condition did not care about if we are in a nested list of VMs/Templates. And if we are, usually @display is set to 'vms' or 'instances', so I used this variable for setting @explorer properly while making/applying changes in in Comparison Sections. And we need @explorer to be set properly because of this.


Before:
sections_before

After:
sections_after

@hstastna
Copy link
Contributor Author

@miq-bot add_label bug

@miq-bot miq-bot added the bug label Dec 12, 2019
@hstastna hstastna changed the title Display Cancel after applying changes in non-explorer Compare screen [WIP] Display Cancel after applying changes in non-explorer Compare screen Dec 12, 2019
@miq-bot miq-bot added the wip label Dec 12, 2019
@hstastna hstastna force-pushed the Cancel_after_applying_changes_Compare branch 2 times, most recently from dffe306 to a7d67a6 Compare December 13, 2019 15:43
@hstastna hstastna changed the title [WIP] Display Cancel after applying changes in non-explorer Compare screen Display Cancel after applying changes in non-explorer Compare screen Dec 13, 2019
@miq-bot miq-bot removed the wip label Dec 13, 2019
@hstastna hstastna force-pushed the Cancel_after_applying_changes_Compare branch from a7d67a6 to 586577c Compare January 2, 2020 11:19
@miq-bot
Copy link
Member

miq-bot commented Jan 2, 2020

Checked commit hstastna@586577c with ruby 2.5.5, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍪

@ZitaNemeckova
Copy link
Contributor

Tested in UI. Fixes the problem in all possible nested list cases. LGTM 👍

@@ -420,7 +420,7 @@ def drift_same
# AJAX driven routine to check for changes in ANY field on the form
def sections_field_changed
@keep_compare = true
@explorer = %w[VMs Templates].include?(session[:db_title])
@explorer = %w[VMs Templates].include?(session[:db_title]) && @display.nil?
Copy link
Contributor

Choose a reason for hiding this comment

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

Fixes the issue, but I think the condition is wrong anyway.

What we usually do to determine explorer:

  • if BASE_MODEL_EXPLORER_CLASSES.include?(cls)
  • if request.xml_http_request?
  • if @edit[:explorer]

Can any of those work instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

The old logic of "VM" or "Template" is in title => explorer, is wrong, so this is fixing a wrong thing by adding stuff instead of replacing to logic to make sense.

Perhaps the place which renders the template should be setting @edit[:explorer] and then we can get it from session.

Copy link
Contributor Author

@hstastna hstastna Jan 6, 2020

Choose a reason for hiding this comment

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

I've tried the second two of them, before I made the change in this PR, of course, but it was not good enough (it fixed the issue for non explorer screens but stopped working for explorer ones).

if @edit[:explorer] did not work, we need @edit to be set, for this case - and this is not always done even when we are in an explorer screen. Even when I've set @edit[:explorer] to true or false at the beginning of comparing items (after user clicked on Compare action), later right after calling sections_field_changed @edit became nil, the information 'got lost'.

And request.xml_http_request? returned something even when we weren't in explorer screen (this happens to me sometimes also for other places and controllers).

Copy link
Contributor

@himdel himdel Jan 6, 2020

Choose a reason for hiding this comment

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

OK, merging as is then, sounds like a future refactoring :).

(created #6580 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also checking some classes was not enough to decide if we are in a explorer screen or not, because of nested lists which are mostly in non-explorer screens.

@himdel himdel merged commit 2d780ba into ManageIQ:master Jan 6, 2020
@himdel himdel self-assigned this Jan 6, 2020
@himdel himdel added this to the Sprint 127 Ending Jan 6, 2020 milestone Jan 6, 2020
@himdel himdel mentioned this pull request Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants