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 flash message on import/export custom report #125

Conversation

jzigmund
Copy link

The PR is recreated after the UI split, original PR ManageIQ/manageiq#13246

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

@@ -178,6 +178,10 @@ def x_show
def tree_select
@edit = nil
@sb[:select_node] = false
if @sb.try(:[], :flash_msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

This line should better read if @sb.key?(:flash_msg)

Copy link
Author

@jzigmund jzigmund Jan 13, 2017

Choose a reason for hiding this comment

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

what if @sb is nil ? this approach doesn't need to test that ;-) but if you insist on that I can replace it ofc.

Copy link
Contributor

Choose a reason for hiding this comment

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

if @sb is nil, then the line above that would fail as well, right?

Copy link
Author

@jzigmund jzigmund Jan 13, 2017

Choose a reason for hiding this comment

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

I can imagine that someone will delete the line or change the lines order ;-)

Copy link
Contributor

Choose a reason for hiding this comment

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

@sb is being set in ApplicationController before every action either to an empty hash or to whatever
the sandbox for the given controller contained before. I haven't seen this @sb.try(:[], ...) construct anywhere
in our code, I consider it a bad coding practice and I won't merge this PR looking like this.

Copy link
Author

@jzigmund jzigmund Jan 13, 2017

Choose a reason for hiding this comment

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

btw. not sure what version of ruby, we support right now, but the best is using safe navigation operator .& ...

I haven't seen this @sb.try(:[], ...) construct anywhere
in our code, I consider it a bad coding practice and I won't merge this PR looking like this.

$ grep -rn \\.try app/ | wc -l
458

vs.

$ grep -rn \\.key? app/ | wc -l
259

Copy link
Author

@jzigmund jzigmund Jan 13, 2017

Choose a reason for hiding this comment

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

FYI above numbers are for manageiq repo, for manageiq-ui-classic the numbers are:

$ grep -rn \\.try app/ | wc -l
330

$ grep -rn \\.key? app/ | wc -l
206

Choose a reason for hiding this comment

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

So looking at this, I think .try has its place, but perhaps not here. This is because @sb.try will not fail if @sb is nil, which in this case is bad. So, to me, I would prefer we use .key? and blow up with a nil error here, which would fail any test that runs this code and we would know that somehow we ended up here without our sandbox object in place. Anyplace we address @sb, except where we initialize it, we'd probably want it to fail if it's nil.

@mzazrivec mzazrivec self-assigned this Jan 13, 2017
@jzigmund jzigmund force-pushed the bz1393244-flash_msg_import_export_custom_reports branch from cee650b to 3a0eb1a Compare January 13, 2017 17:21
@jzigmund jzigmund force-pushed the bz1393244-flash_msg_import_export_custom_reports branch from 3a0eb1a to 1b92982 Compare January 13, 2017 17:25
@miq-bot
Copy link
Member

miq-bot commented Jan 13, 2017

Checked commit jzigmund@1b92982 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
1 file checked, 0 offenses detected
Everything looks good. 👍

@mzazrivec mzazrivec added this to the Sprint 52 Ending Jan 16, 2017 milestone Jan 16, 2017
@mzazrivec mzazrivec merged commit 5384b7b into ManageIQ:master Jan 16, 2017
@simaishi
Copy link
Contributor

Euwe backport (to manageiq repo) details:

$ git log -1
commit 9b0fe0b488ec76c74e8db0423f9341e45a364395
Author: Milan Zázrivec <[email protected]>
Date:   Mon Jan 16 13:37:51 2017 +0100

    Merge pull request #125 from jzigmund/bz1393244-flash_msg_import_export_custom_reports
    
    Display flash message on import/export custom report
    (cherry picked from commit 5384b7b77f8a913323ce45f913b5a6760fda54b1)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1414888

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