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

Adding view full log in alerts button #2862

Merged
merged 1 commit into from
Dec 20, 2017
Merged

Conversation

nimrodshn
Copy link
Contributor

@nimrodshn nimrodshn commented Nov 29, 2017

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:
short_alert
Long alert:
middle_alert
Very Long alert
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 😇

@miq-bot miq-bot added the wip label Nov 29, 2017
@nimrodshn
Copy link
Contributor Author

@miq-bot add_label bug, gaprindashvili/yes, wip

@himdel
Copy link
Contributor

himdel commented Nov 29, 2017

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:

  • keep the both implementations consistent, and update ruby-side add_flash and corresponding templates to keep generating the same layout

  • do a proper css class for the style changes, and ... if you can prevent using overflow:hidden and setting height, even better. (Test this on a phone.)

  • don't determine the Details logic by message length, use an explicit option (feel free to add a 3rd options={} arg to add_flash if needed), apply only to messages coming from authentication mixin

(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)

@himdel himdel closed this Nov 29, 2017
@himdel himdel reopened this Nov 29, 2017
@serenamarie125
Copy link

@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
image

Tagging @jeff-phillips-18 who may be able to point you to some code which can does this

@nimrodshn
Copy link
Contributor Author

nimrodshn commented Nov 29, 2017

@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).
Edit: Although without proper Patternfly support I'm not really sure how to implement this..

@himdel
Copy link
Contributor

himdel commented Nov 29, 2017

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.)

@serenamarie125
Copy link

serenamarie125 commented Nov 29, 2017

what's a flash message @himdel - inline notification?

@himdel
Copy link
Contributor

himdel commented Nov 29, 2017

@serenamarie125 Yes, it's the inline one - the one you can see in the gif in the description (except the button is new there).

@serenamarie125
Copy link

@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.

@nimrodshn
Copy link
Contributor Author

nimrodshn commented Nov 30, 2017

So @jrafanie defers for a different solution in the backend:

I'd be ok with a few different solutions:

  • extending the truncate length to fit a reasonable error message to fix your bug (while still fitting into the status_details column)
  • Or move the truncate to the log line and where we save the status_details and all callers of authentication_check

Thoughts @himdel @serenamarie125 ?

@himdel
Copy link
Contributor

himdel commented Nov 30, 2017

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. :) ))

@cben
Copy link
Contributor

cben commented Nov 30, 2017 via email

@nimrodshn
Copy link
Contributor Author

@himdel PTAL

@nimrodshn
Copy link
Contributor Author

@himdel code climate is really annoying 😭

@himdel
Copy link
Contributor

himdel commented Dec 7, 2017

@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 id for alert_expand_button .. you can have more than one flash message on the screen, so it needs to be a class.

Other than that, can you please also add the corresponding change to the Ruby add_flash?
(Or I can do a separate PR if you have trouble there, just want to ensure both are in sync.)

@nimrodshn
Copy link
Contributor Author

@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)
Copy link
Contributor

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.

Copy link
Contributor Author

@nimrodshn nimrodshn Dec 7, 2017

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?

Copy link
Contributor

@himdel himdel Dec 20, 2017

Choose a reason for hiding this comment

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

@cben
Copy link
Contributor

cben commented Dec 7, 2017 via email

@miq-bot
Copy link
Member

miq-bot commented Dec 8, 2017

This pull request is not mergeable. Please rebase and repush.

@nimrodshn
Copy link
Contributor Author

nimrodshn commented Dec 18, 2017

@himdel reverted to the old code. just need to add the scrollbar.

@nimrodshn nimrodshn force-pushed the fix_log_bug branch 2 times, most recently from 8f73083 to 638800f Compare December 18, 2017 18:52
@nimrodshn
Copy link
Contributor Author

nimrodshn commented Dec 18, 2017

@himdel Added the scroll bar plus fixed the dangling link situation.

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");
Copy link
Member

Choose a reason for hiding this comment

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

translate ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch!


// remove dangling 'Show More' link when the alert msg is short.
if( options.long_alert && !checkElipsis(alertDiv) ) {
detailsLink.hide();
Copy link
Member

Choose a reason for hiding this comment

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

nice 👍

@nimrodshn
Copy link
Contributor Author

cc @skateman @serenamarie125
GIF(with scrollbar):
long_alert

@nimrodshn nimrodshn force-pushed the fix_log_bug branch 2 times, most recently from 49f3919 to 02b6ca3 Compare December 19, 2017 11:07
}

function expandAlert(params) {
var viewMoreTxt = _("View More");
Copy link
Contributor

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" :))

@serenamarie125
Copy link

@miq-bot add_label ux/review

@serenamarie125
Copy link

@miq-bot add_label ux/approved

@serenamarie125
Copy link

@miq-bot remove_label ux/review

@himdel himdel self-assigned this Dec 20, 2017
@himdel
Copy link
Contributor

himdel commented Dec 20, 2017

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 👍

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};
Copy link
Contributor

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.

var found = false;
var $c = element
.clone()
.css({display: 'inline', width: 'auto', visibility: 'hidden'})
Copy link
Contributor

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
@miq-bot
Copy link
Member

miq-bot commented Dec 20, 2017

Checked commit nimrodshn@7e07090 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🏆

@himdel himdel added this to the Sprint 76 Ending Jan 1, 2018 milestone Dec 20, 2017
@himdel himdel merged commit dd0eadb into ManageIQ:master Dec 20, 2017
@simaishi
Copy link
Contributor

simaishi commented Jan 3, 2018

Gaprindashvili backport details:

$ git log -1
commit 56283a047f9e3571cce1538abadd723a44b94f97
Author: Martin Hradil <himdel@seznam.cz>
Date:   Wed Dec 20 16:41:15 2017 +0100

    Merge pull request #2862 from nimrodshn/fix_log_bug
    
    Adding view full log in alerts button
    (cherry picked from commit dd0eadbacc34eab74dd1524e7492d8825bdaedbb)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1530645

simaishi pushed a commit that referenced this pull request Jan 3, 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.

8 participants