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 inconstancy of flash messages for Analysis Profiles and Schedules #3800

Conversation

hstastna
Copy link

@hstastna hstastna commented Apr 19, 2018

Fixes BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1516895


Fix inconstancy of flash messages between addition vs. deletion of Analysis Profiles and Schedules, under Configuration -> Settings accordion.

Adding the profile named "Name1" with description "Desc1":
add_profile

Before: (Name in the flash message):
profile_before

After: " (Description in the flash message, the same as for deleting the profile):
profile_after

Deleting the profile named "Name1" with description "Desc1" (we see Description in the flash message):
profile_delete


Details:
The problem with inconstancy is related to all of the records which have name AND also description. The inconstancy was caused in get_record_display_name method where description of the record is checked first (before name is checked) and returned, no chance to check also the name of the record. This happens when deleting the profile. When adding/editing the profile, there is a different way of adding flash message. We don't call any of the methods like get_record_display_name or so, we just simply add it and use the name, not description of profile. But I was told that we "use Description when record responds to description and has description populated regardless of whether name is present or not" so I made the change here (in ap_edit method), as I was suggested, to show description also when adding/editing the profile, not only when deleting it.

@hstastna
Copy link
Author

@miq-bot add_label bug, gaprindashvili/yes

@hstastna hstastna changed the title Fix inconstancy of flash messages for Analysis Profiles and Schedules [WIP] Fix inconstancy of flash messages for Analysis Profiles and Schedules Apr 19, 2018
@miq-bot miq-bot added the wip label Apr 19, 2018
@hstastna hstastna force-pushed the Inconstancy_add_delete_Analysis_Profiles_Schedules branch from f4eb46f to c19be19 Compare April 19, 2018 13:13
@hstastna hstastna changed the title [WIP] Fix inconstancy of flash messages for Analysis Profiles and Schedules Fix inconstancy of flash messages for Analysis Profiles and Schedules Apr 19, 2018
@hstastna
Copy link
Author

@miq-bot remove_label wip

@miq-bot miq-bot removed the wip label Apr 19, 2018
@mzazrivec
Copy link
Contributor

I think that the above behavior is pretty much intentional. Am I correct @dclarizio ?

@dclarizio
Copy link

@mzazrivec @hstastna I'm gonna WIP this until I can discuss with @h-kataria as we've been working on getting these more consistent and I don't recall exactly what we decided on for strategy.

@dclarizio dclarizio changed the title Fix inconstancy of flash messages for Analysis Profiles and Schedules [WIP] Fix inconstancy of flash messages for Analysis Profiles and Schedules Apr 21, 2018
@hstastna
Copy link
Author

hstastna commented May 4, 2018

@dclarizio @h-kataria Any update about this? Thank you! ❇️

@h-kataria
Copy link
Contributor

@hstastna with the proposed change in this PR you are forcing code to use "Description" only when name is blank, we want to be consistent and use Description when record responds to description and has description populated regardless of whether name is present or not.
Note: This is a common method and will effect flash messages in many places in the UI.
I would rather suggest making a change to Add/edit method to call this common method https://github.com/ManageIQ/manageiq-ui-classic/pull/3800/files#diff-55c5b7aecfb519d0e4880eaf2788eb6eL2110 and let it decide whether to use description or name field.

@hstastna
Copy link
Author

hstastna commented May 4, 2018

Thank you, @h-kataria , for your update ❇️ I was following the BZ. Anyway, I can try this change you suggest. Will update this PR with the change.

@hstastna
Copy link
Author

hstastna commented May 7, 2018

@h-kataria I cannot use the common method in add/edit method (in analysis_profiles.rb) because record.respond_to?("whatever") will be always false, as the record does not exist yet, when creating/adding new profile, we have just @edit[:new]. It would also throw an error (because of no id in @edit[:new]). I think I need to change name to description in appropriate line of the code (when adding flash message to flash array). Could you check the new change in this PR? Thanks! :)

@hstastna hstastna force-pushed the Inconstancy_add_delete_Analysis_Profiles_Schedules branch 3 times, most recently from af26122 to e4d0031 Compare May 7, 2018 09:14
@hstastna hstastna changed the title [WIP] Fix inconstancy of flash messages for Analysis Profiles and Schedules Fix inconstancy of flash messages for Analysis Profiles and Schedules May 7, 2018
@miq-bot miq-bot removed the wip label May 7, 2018
@h-kataria
Copy link
Contributor

@hstastna
Copy link
Author

hstastna commented May 7, 2018

@h-kataria yes, I can but I was worried about using scanitemset as the name of this variable is confusing for me.. and also because when adding flash message, there was not used scanitemset but @edit[:new]. So I wanted to keep this.

@hstastna hstastna force-pushed the Inconstancy_add_delete_Analysis_Profiles_Schedules branch from e4d0031 to fa323b9 Compare May 7, 2018 13:45
@hstastna
Copy link
Author

hstastna commented May 7, 2018

@h-kataria now the fix should be ok :D

@h-kataria
Copy link
Contributor

@hstastna can you add a spec test to verify changes in the fix

@hstastna hstastna force-pushed the Inconstancy_add_delete_Analysis_Profiles_Schedules branch from fa323b9 to 4b48b72 Compare May 9, 2018 10:04
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1516895

Fix inconstancy of flash messages between addition vs. deletion of Analysis
Profiles and Schedules, under Configuration -> Settings accordion.
@hstastna hstastna force-pushed the Inconstancy_add_delete_Analysis_Profiles_Schedules branch from 4b48b72 to a099473 Compare May 15, 2018 13:49
@hstastna
Copy link
Author

@h-kataria @skateman I've added spec test for my change :)

@miq-bot
Copy link
Member

miq-bot commented May 15, 2018

Checked commits hstastna/manageiq-ui-classic@a099473~...c23cc00 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. ⭐

@h-kataria h-kataria added this to the Sprint 86 Ending May 21, 2018 milestone May 15, 2018
@h-kataria h-kataria merged commit 787925f into ManageIQ:master May 15, 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.

5 participants