-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[SharedUX] Merge similar toast messages in case of a toast-flood/storm #161738
[SharedUX] Merge similar toast messages in case of a toast-flood/storm #161738
Conversation
31dff78
to
3948f10
Compare
@elasticmachine merge upstream |
abb7801
to
7fabc6e
Compare
@elasticmachine merge upstream |
...ore/notifications/core-notifications-browser-internal/src/toasts/deduplicate_toasts.test.tsx
Show resolved
Hide resolved
...ges/core/notifications/core-notifications-browser-internal/src/toasts/deduplicate_toasts.tsx
Outdated
Show resolved
Hide resolved
…t element was triggered
31f97a4
to
15dd131
Compare
Pinging @elastic/appex-sharedux (Team:SharedUX) |
472e6c5
to
a231d52
Compare
@elasticmachine merge upstream |
I think this is fine for the time being. I can create the issue requesting the implementation of the counter in the EUI repo. What do you think @ryankeairns ? @delanni are you using EuiNotificationBadge in size "m"? I think that size will work nicely. |
Yes, this seems like the right approach: quick fix, then replace with EUI solution once available Thanks all! |
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.
LGTM
d421da7
to
f227247
Compare
@delanni, It seems that
|
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.
We discussed in slack:
Currently when grouping we check that title + text are the same if they both are texts. But if there is a MountPoint in one of those, then it skips it and checks just either title or text. This means we might group toasts with completely different contents inside the mount point.
I think that the chance is quite small to miss something important there, but I’d personally prefer a safer route and to always not group if there is a MountPoint
It also seems that if we simplify this MountPoint thing , it means that we won’t ever have a MountPoint in a grouped toast. Then TitleWithBadge
could be simplified to not worry about the MountPoint edge case
This is just my opinion and I don't think this is critical, so 👍
Maybe with this change we could also finally close #67270? |
…nctions (case: error toasts)
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.
I retested with the latest changes, looks great 👍
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
elastic#161738) ## Summary This PR addresses the occasional toast-floods/toast-storms with a simple catch mechanism: deduplicate/group toasts by their broad alikeness, their text and title. This implementation plugs in to the `global_toast_list.tsx` in Kibana's GlobalToastList component, capturing updates on the toast update stream, and collapses toasts before passing them further to the downstream EUI Toast list react components. The core idea is to not display notifications directly, but to keep the toast notifications apart from their visual representation. This way, we can represent more notifications with one toast on our end, if we group rightly. The only issue then, is to clean up everything nicely when it's time. For this we're also exporting a mapping that shows which toast ID represents which grouped toasts. I also changed the type `ToastInputFields` to accept rendered react components as title/text - this will prevent attempts to unmount react components from elements that are not displayed, thus causing React warnings. The close-all button is an EUI feature, which we've started discussing [here](elastic/eui#6945), probably not part of this PR. ## What toasts get merged? The exact merging strategy was not settled, and it's kind of a valve, where we trade off potential detail lost in toasts for the prevented noise in the toast floods. The current strategy is as folows: ``` * These toasts will be merged: * - where title and text are strings, and the same (1) * - where titles are the same, and texts are missing (2) * - where titles are the same, and the text's mount function is the same string (3) * - where titles are missing, but the texts are the same string (4) ``` The base merge case is `(1) & (2)`, after some discussion with @Dosant we decided to include (3) as a compromise, where we're still merging somewhat similar toasts, and extend the merging to `ToastsApi::addError` where all error toasts have a MountPoint as their text. We understand this might hide some details (e.g.: same titles, but very slightly different MountPoints as their text) but realistically this shouldn't really happen. The ultimate future improvement will be (as suggested in the comments by @jloleysens) a sort of identifier to the toast, based on which we can group without fear of losing information. But this will require more work on all the call-sites. Relates to: elastic#161482  ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ### For maintainers - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Summary
This PR addresses the occasional toast-floods/toast-storms with a simple catch mechanism: deduplicate/group toasts by their broad alikeness, their text and title.
This implementation plugs in to the
global_toast_list.tsx
in Kibana's GlobalToastList component, capturing updates on the toast update stream, and collapses toasts before passing them further to the downstream EUI Toast list react components.The core idea is to not display notifications directly, but to keep the toast notifications apart from their visual representation. This way, we can represent more notifications with one toast on our end, if we group rightly. The only issue then, is to clean up everything nicely when it's time. For this we're also exporting a mapping that shows which toast ID represents which grouped toasts.
I also changed the type
ToastInputFields
to accept rendered react components as title/text - this will prevent attempts to unmount react components from elements that are not displayed, thus causing React warnings.The close-all button is an EUI feature, which we've started discussing here, probably not part of this PR.
What toasts get merged?
The exact merging strategy was not settled, and it's kind of a valve, where we trade off potential detail lost in toasts for the prevented noise in the toast floods. The current strategy is as folows:
The base merge case is
(1) & (2)
, after some discussion with @Dosant we decided to include (3) as a compromise, where we're still merging somewhat similar toasts, and extend the merging toToastsApi::addError
where all error toasts have a MountPoint as their text. We understand this might hide some details (e.g.: same titles, but very slightly different MountPoints as their text) but realistically this shouldn't really happen.The ultimate future improvement will be (as suggested in the comments by @jloleysens) a sort of identifier to the toast, based on which we can group without fear of losing information. But this will require more work on all the call-sites.
Relates to: #161482
Checklist
Delete any items that are not applicable to this PR.
For maintainers