-
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
[Lens] Introduce new duration formatter #162246
Conversation
Pinging @elastic/kibana-visualizations @elastic/kibana-visualizations-external (Team:Visualizations) |
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.
Code LGTM, tested on Chrome 👌🏼
x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/datasources/form_based/dimension_panel/formatting/duration_input.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/datasources/form_based/dimension_panel/formatting/duration_input.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.tsx
Outdated
Show resolved
Hide resolved
…-ref HEAD~1..HEAD --fix'
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.
Code only review, field format changes LGTM 👍
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
@dej611: Apologies for the delayed response. Leaving my feedback now, in case there is an opportunity for a follow-up PR. I like the thinking behind using the EUI delimited controls, but I don't think the current layout affords us enough horizontal space for it to be used without needing to resort to abbreviations (see my example below). As such, I think the direction you ultimately appear to have implemented makes the most sense (at least until some point in the future where we re-evaluate how form elements are laid out in the Lens configuration flyouts). However, I would make the following suggestions:
Regarding the "Human-readable" options, why the choice between approximate and precise? Are the two options necessary? Or can there not be a single "Human-readable" option? Finally, I noticed that some of my previous suggestions as part of the "Custom format" selection are not as intended. I'm not sure if this is a regression, but noting my suggestions here again in the hopes that we can squeeze them in as well.
CCing @amyjtechwriter, in case she has any additional input on some of the suggested wording. |
Thanx @MichaelMarcialis, I will create an issue for your feedback, we need to also alloq TSVB with duration formatter to be moved to Lens so we will have a follow up PR for sure |
## Summary Fixes elastic#153378 This PR introduces a new Duration formatter, similar to the TSVB one and more complete like the Field Formatter one. Few keys features of the new formatter: * supports from and to unit selection * supports Humanize (approximate) and Humanize (precise) outputs * supports units below milliseconds * supports decimals precision (with the exception of the `humanize approximate` output) * supports suffix * supports the compact version (with the exception of the `humanize approximate` output) Input and Output options are now exported directly from the Field Formatter to have a shared list of options. A first look at the new formatter in action: when enabled it the first time it will lands on `Seconds => Humanize (Approximate)` configuration (this emulates the current Field Formatter behaviour) <img width="1217" alt="Screenshot 2023-07-19 at 15 28 52" src="https://github.com/elastic/kibana/assets/924948/8ddcb945-3cd7-4af1-bdfb-2ae1795ab06c"> In this example the input was in Minutes so it is possible to change it from the default `Seconds` entry: <img width="1223" alt="Screenshot 2023-07-19 at 14 17 11" src="https://github.com/elastic/kibana/assets/924948/b547b3ed-475e-421c-b196-a76b07235bd3"> Switching output type to something else than `Humanize (approximate)` will make available both decimals and compact controls as well. Custom suffix is supported as well. <img width="1220" alt="Screenshot 2023-07-19 at 14 18 34" src="https://github.com/elastic/kibana/assets/924948/f5efe1f7-5f0d-4de1-bb3e-80ff00857bc6"> <img width="1228" alt="Screenshot 2023-07-19 at 14 18 19" src="https://github.com/elastic/kibana/assets/924948/fef7fa2d-ecd3-48ae-a833-16dbeaeaade2"> When Decimals and Compact controls are disabled a helpful tooltip is shown to the user to explain why: <img width="341" alt="Screenshot 2023-07-19 at 14 17 30" src="https://github.com/elastic/kibana/assets/924948/78ca1df5-808d-4e2d-8598-90e3f3ec5a85"> <img width="337" alt="Screenshot 2023-07-19 at 14 17 23" src="https://github.com/elastic/kibana/assets/924948/4ca0028d-3344-464c-8b36-1f74f53bd34e"> I've also prepared an alternate UI version which is more compact, using the `DelimitedControls` UI, but it does not looks that great. Maybe some design iteration could help make it better? cc @MichaelMarcialis <img width="1226" alt="Screenshot 2023-07-19 at 14 20 02" src="https://github.com/elastic/kibana/assets/924948/fb8f69f2-5182-480d-9cb2-7a7149a54320"> ### Checklist Delete any items that are not applicable to this PR. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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 - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### Risk Matrix Delete this section if it is not applicable to this PR. Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release. When forming the risk matrix, consider some of the following examples and how they may potentially impact the change: | Risk | Probability | Severity | Mitigation/Notes | |---------------------------|-------------|----------|-------------------------| | Multiple Spaces—unexpected behavior in non-default Kibana Space. | Low | High | Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces. | | Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. | High | Low | Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure. | | Code should gracefully handle cases when feature X or plugin Y are disabled. | Medium | High | Unit tests will verify that any feature flag or plugin combination still results in our service operational. | | [See more potential risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) | ### For maintainers - [ ] 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: kibanamachine <[email protected]> Co-authored-by: Stratoula Kalafateli <[email protected]>
Summary
Fixes #153378
This PR introduces a new Duration formatter, similar to the TSVB one and more complete like the Field Formatter one.
Few keys features of the new formatter:
humanize approximate
output)humanize approximate
output)Input and Output options are now exported directly from the Field Formatter to have a shared list of options.
A first look at the new formatter in action: when enabled it the first time it will lands on
Seconds => Humanize (Approximate)
configuration (this emulates the current Field Formatter behaviour)In this example the input was in Minutes so it is possible to change it from the default
Seconds
entry:Switching output type to something else than
Humanize (approximate)
will make available both decimals and compact controls as well.Custom suffix is supported as well.
When Decimals and Compact controls are disabled a helpful tooltip is shown to the user to explain why:
I've also prepared an alternate UI version which is more compact, using the
DelimitedControls
UI, but it does not looks that great. Maybe some design iteration could help make it better? cc @MichaelMarcialisChecklist
Delete any items that are not applicable to this PR.
Risk Matrix
Delete this section if it is not applicable to this PR.
Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.
When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:
For maintainers