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

[Lens] introduce unified user messages system #147818

Merged

Conversation

drewdaemon
Copy link
Contributor

@drewdaemon drewdaemon commented Dec 19, 2022

Summary

Preparation for #147485, #143673

This PR revamps the code that surfaces feedback in Lens. Warnings, deprecation messages, and errors are merged into a unified concept of the UserMessage. Guiding principles:

  • Globally available—messages created from anywhere within the Lens codebase can be displayed in any UI location with minimal to no extra work.
  • Maximally helpful—messages are equipped with useful information and unlimited dynamic user interface (e.g. quick fix buttons, links to docs). The severity of a message (error, warning) is carefully chosen and clearly communicated.
  • Easily extensible—new messages and display locations can be added with ease. Adding a new message or display location adds very little complexity to the code.

Architecture changes

Current State

Warnings and errors are distinct entities. Ad hoc methods and call stacks have been added each time messages needed to be displayed in new UI locations. Warnings surfaced from children in the component tree are pushed to the Redux store in order to display them at a higher hierarchical level. Dimension trigger state is controlled by visualization configuration.

Screen Shot 2023-01-13 at 11 47 51 AM

New State

Most user messages originate from visualization.getUserMessages, datasource.getUserMessages, and getApplicationUserMessages. When messages need to be generated outside those routines, addUserMessages utility makes them available globally. Redux store is no longer in play. Dimension trigger state is now controlled by user messages just like every other display location. Messages are queried for display via the global getUserMessages API.

Screen Shot 2023-01-13 at 11 57 52 AM

Example test cases

Display locations

Editor toolbar

  • new bar vertical stacked visualization
  • horizontal axis -> top 50 values of clientip
  • vertical axis -> median of bytes
  • time range -> last 30 days

Screen Shot 2023-01-13 at 12 06 32 PM

Embeddable badge

Trigger shard failures by following these instructions

Screen Shot 2023-01-13 at 4 29 25 PM

Dimension trigger

  • new gauge chart
  • set minimum dimension to a value greater than the maximum dimension

Screen Shot 2023-01-18 at 10 29 36 AM

Visualization

  • new bar vertical stacked visualization
  • horizontal axis -> date histogram with @timestamp
  • vertical axis -> select cumulative sum quick function

Screen Shot 2023-01-13 at 4 33 33 PM

Screen Shot 2023-01-14 at 12 09 27 PM

Text-based languages query input

  • Enable discover:enableSql in Advanced Settings
  • Open Lens and select SQL from the datasource menu
  • Introduce a typo in the query

Screen Shot 2023-01-14 at 12 07 45 PM

Screen Shot 2023-01-14 at 12 08 07 PM

Banner

  • Enable lens:useFieldExistenceSampling in Advanced Settings
  • Open Lens editor

Screen Shot 2023-01-13 at 4 37 21 PM

Checklist

Delete any items that are not applicable to this PR.

@drewdaemon drewdaemon added Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens labels Dec 19, 2022
@drewdaemon drewdaemon force-pushed the 143673/dont-block-render-on-missing-field branch from becaa38 to 3933fe8 Compare December 19, 2022 22:45
@drewdaemon drewdaemon force-pushed the 143673/dont-block-render-on-missing-field branch from d59b3f0 to fbec723 Compare December 21, 2022 16:18
@drewdaemon drewdaemon force-pushed the 143673/dont-block-render-on-missing-field branch from fbec723 to 0de8d2c Compare December 21, 2022 16:19
@drewdaemon drewdaemon force-pushed the 143673/dont-block-render-on-missing-field branch from 875505b to 8f3afc6 Compare December 21, 2022 22:32
@drewdaemon drewdaemon force-pushed the 143673/dont-block-render-on-missing-field branch from 16f46bd to 6a5e7bf Compare December 22, 2022 20:38
Copy link
Contributor

@dej611 dej611 left a comment

Choose a reason for hiding this comment

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

Tested locally and it works.
Left some minor code refactoring nits. Approving to not block.

Copy link
Contributor

@MichaelMarcialis MichaelMarcialis left a comment

Choose a reason for hiding this comment

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

Left one small comment, but LGTM otherwise.

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

Changes LGTM! Thanx Andrew, I really like the new system and will become even more handy in the future:)

…m:andrewctate/kibana into 143673/dont-block-render-on-missing-field
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
lens 889 890 +1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
lens 602 598 -4

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 1.3MB 1.3MB +5.0KB
maps 2.7MB 2.7MB -22.0B
total +4.9KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
lens 50 52 +2

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
lens 33.9KB 34.0KB +36.0B
Unknown metric groups

API count

id before after diff
lens 698 693 -5

ESLint disabled line counts

id before after diff
lens 19 15 -4

Total ESLint disabled count

id before after diff
lens 22 18 -4

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Lens release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants