Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Lens] Introduce new duration formatter (#162246)
## 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: * 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]>
- Loading branch information