-
Notifications
You must be signed in to change notification settings - Fork 356
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
Adding view full log in alerts button #2862
Conversation
@miq-bot add_label bug, gaprindashvili/yes, wip |
02e6450
to
a05086c
Compare
This needs to be different. You are changing the styling of every single flash message generated on JS side, in a way that is inconsistent with flash messages coming from ruby. You're also randomly hardcoding a 200 character limit - this is wrong because this will affect any existing messages long enough. And it is also wrong because the reasonable size will depend on the user's resolution, and chosen language (this is why Twitter still limits Chinese to 140 chars). Also, the CSS looks like it can't work on mobile, limiting height is seldom a good idea. So.. proposing:
(or we could add a separate message body concept to flash messages - so that we keep the flash the same, but can optionally add a longer body, which will trigger a button to display it, and needs no extra logic) (EDIT: sorry, closed by mistake) |
@nimrodshn Although we don't have PatternFly support for this, I'd suggest doing something like OpenShift has implement ... where there is a See All link which allows for expansion and a vertical scrolllbar Tagging @jeff-phillips-18 who may be able to point you to some code which can does this |
@himdel is @serenamarie125 's approach OK with you? (before I continue with implementation I just wanna make sure we're all on the same page). |
Depends on the details - @serenamarie125 's screenshot is a toast notification, not a flash message. So... if you do manage to make the error go via our asynchronous notifications so that it ends up in the notification area... even better, I do believe there is some support for expandable messages already. But it means going through a completely different code path than a flash message, and the message pretty much needs to come from the server, we have no way of creating these toasts in JS now. (Or rather, no clean way - if this is something that doesn't have to be visible in the notification area after the user reloads the page, then maybe we do. If it needs to be there after reload, it needs to come from the server.) (I don't really object to the flash message approach either, just that the style needs to be consistent, and work for all the existing ones too.) |
what's a flash message @himdel - inline notification? |
@serenamarie125 Yes, it's the inline one - the one you can see in the gif in the description (except the button is new there). |
@nimrodshn I'd suggest using similar behavior, regardless if it's a flash/inline or toast notification. @himdel I think we need to discuss the flash/inline versus toast approach in general and see how we can transition away from flash/inline in most cases. I wouldn't expect that to be part of this PR. |
So @jrafanie defers for a different solution in the backend:
Thoughts @himdel @serenamarie125 ? |
Re-reading the BZ, I'm wondering if we're looking at the problem the right way.. does the user really need to get that long HTML message in its entirety? Do we assume the user will be able to understand it? Because, if this is not about getting randomly long descriptive messages from backend, but about sometimes getting unexpected HTML back, maybe we could fix this by actually dealing with the HTML on the backend - parsing it, or replacing it with a simpler message. (I don't know the details of what openshift actually returns when, but seems to me that if we just stripped all the html tags and left just the text nodes, if would probably fit in the limit while still letting the user know more.) (Incidentally, that's what we do in JS when the rails backend returns an unexpected response - try to parse out the exception from the message.) ((But if parsing it server-side doesn't work .. I don't know, my complaints were more about the style changes to the flash messages than anything else - if we drop the length limit without changing the format, I don't think there's any issue, as long as the backend is happy. :) )) |
There are a couple common mistakes (such as "no such app" page from openshift router).
But it's impossible to say what we'll get generally, we can't even know whether it's HTML! (for working openshift it's actually JSON)
The main scenario I had in mind when I opened that BZ is *talking to something unexpected* — because user entered wrong hostname/port, or entered correct ones but reached something else.
(In a customer case that prompted this, a firewall blocked the connection.)
The user might or might not understand it... In the firewall case, first 200 chars was unhelpful but once I asked them to run `curl` and they saw "blocked" and the firewall vendor name they went "aha!" and fixed it quickly.
The way I see it, when you're trying to connect a provider and it Just Doesn't Work (tm), it's a miserable experience.
At that point, you got exactly zero value of the product, you can't make any progress until you get help, and you don't even have enough data for troubleshooting, like text to google — or to send to people who might help.
(well in case of RedHat support you'd be asked to upload logs, but in any case triage is faster if you have error message)
I like the idea of backend sending independent "message" and "details" texts, because in future we might want to add more diagnostic data there, e.g. details on the TLS certificate, maybe some advice / pointers to docs etc...
|
a05086c
to
b887fcc
Compare
c9c1295
to
8d9182b
Compare
@himdel PTAL |
@himdel code climate is really annoying 😭 |
@nimrodshn Feel free to ignore :) We do need to fix CC at some point, yes, the 3 issues are nonsense. The code looks good I think 👍 (have not tested in UI yet) One issue I see - we can't use an Other than that, can you please also add the corresponding change to the Ruby |
@himdel Sure will do that! |
@@ -98,7 +98,7 @@ def render_validation_result(result, details) | |||
level = :error | |||
end | |||
|
|||
render_flash_json(msg, level) | |||
render_flash_json(msg, level, :long_alert => true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nowsg is unlimited, perhaps ruby should still truncate to some large limit here, to avoid sending megabyte responses to UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cben so truncate at 500 chars here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this addressed by https://github.com/ManageIQ/manageiq/pull/16550/files#diff-f9cace1fe4fdcec66f962b23f2110fd6R337 now? (I think it is, making sure :).)
more like 20000 if you ask me :)
it's will be loooong but only in rare cases, and it's hidden by default,
and in those cases long is better than lack of info...
it's just to avoid completely blowing up...
(well a gigabytes response could still exhaust ruby memory before we even
get to UI. but that's out of scope, let's hope people don't connect MIQ
directly to youtube :-)
|
This pull request is not mergeable. Please rebase and repush. |
1e86d1f
to
949434d
Compare
@himdel reverted to the old code. just need to add the scrollbar. |
8f73083
to
638800f
Compare
@himdel Added the scroll bar plus fixed the dangling link situation. |
app/assets/javascripts/miq_flash.js
Outdated
params.clicked = true; | ||
params.alert_elem.removeClass('text-overflow-pf'); | ||
params.alert_elem.addClass('text-vertical-overflow-pf'); | ||
params.link.find('a').text("View Less"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translate ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch!
app/assets/javascripts/miq_flash.js
Outdated
|
||
// remove dangling 'Show More' link when the alert msg is short. | ||
if( options.long_alert && !checkElipsis(alertDiv) ) { | ||
detailsLink.hide(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice 👍
cc @skateman @serenamarie125 |
49f3919
to
02b6ca3
Compare
app/assets/javascripts/miq_flash.js
Outdated
} | ||
|
||
function expandAlert(params) { | ||
var viewMoreTxt = _("View More"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In js, you need __
, not _
for i18n ;).
(_
seems to work because it's lodash("string") -> ["string"].toString() -> "string" :))
@miq-bot add_label ux/review |
@miq-bot add_label ux/approved |
@miq-bot remove_label ux/review |
Tested in UI, looks like resizing the window now works both for expanded and for non-expanded alerts 👍 Two more things I notice:
(+ the __ thing #2862 (comment)) EDIT: and fixed 👍 |
app/assets/javascripts/miq_flash.js
Outdated
if (options.long_alert) { | ||
var detailsLinkTxt = _("View More"); | ||
var detailsLink = $('<div class="alert_expand_link"><strong><a href="#">' + detailsLinkTxt + '</a></strong></div>'); | ||
var params = {clicked: false, alert_elem: alertDiv, link: detailsLink}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to save the state in that particular element's data
, or somewhere per-element, not global.
app/assets/javascripts/miq_flash.js
Outdated
var found = false; | ||
var $c = element | ||
.clone() | ||
.css({display: 'inline', width: 'auto', visibility: 'hidden'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
display: 'inline-block'
will make this work in firefox :)
minor refactoring to pr second iteration minor refactoring making code climate happy minor refactoring and tests minor refactoring adding dealing with small alerts minor refactoring extracting txt and trimming whitespaces fixed the specs moved to link refactoing class selector adding view more minor refactoring hardcoded msg length solution reverting to elipsis solution fix dangling link adding stylesheet for scrollbar fix whitespaces and tests fix dangling whitespace minor refactoring, adding compatability with firefox
02b6ca3
to
7e07090
Compare
Checked commit nimrodshn@7e07090 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 |
Gaprindashvili backport details:
|
Adding view full log in alerts button (cherry picked from commit dd0eadb) https://bugzilla.redhat.com/show_bug.cgi?id=1530645
Currently we truncate (after 200 characters) the log error / warning that was received when connecting to a provider - In this patch I purpose a way of dealing with the full log error by adding a button to the alert when the alert is too long (above 200 characters).
Summary of scenarios tested:
Short alert:
Long alert:
Very Long alert
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1506718
cc: @cben , @serenamarie125 , @himdel
Please share thoughts on this 😅 - this is just a proposition 😇