Skip to content

Commit

Permalink
[8.x] [Lens] Embeddable react refactor (#186642) (#201739)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [[Lens] Embeddable react refactor
(#186642)](#186642)

I've skipped a flaky test here to carry on with the merge.
The same test is flaky in `main` too:
#201744 .
Will push a test fix asap.

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Marco
Liberati","email":"dej611@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-11-26T08:34:13Z","message":"[Lens]
Embeddable react refactor (#186642)\n\n## Summary\r\n\r\nThis PR
contains the refactor of the Lens embeddable with the new
React\r\narchitecture.\r\n\r\nfix
https://github.com/elastic/kibana/issues/174957\r\nfixes
https://github.com/elastic/kibana/issues/180672\r\n\r\n**Current
status**:\r\n✅ Ready to review\r\n\r\n### Notes for testing and
reviewers\r\n\r\nOther than reworking the Lens embeddable with the new
architecture this\r\nPR contains the following major
changes.\r\n\r\n#### Edit flow\r\nThe `Edit` flow has changed to in-line
first using the new `Edit` API\r\nprovided by the new system\r\n* The
impact of this change can be noticed in the code on the `Canvas`\r\ncase
where the Custom Lens component is instructed to avoid the
inline\r\nediting. In all the other cases in-line editing is enabled by
default\r\nnow.\r\n* Another side effect of this has been the
replacement of the special\r\n`INLINE_EDIT` action id into the regular
`EDIT` action. Some tests have\r\nbeen affected by this replacing the
`clickEdit` function with the\r\n`openEditorFromFlyout` one.\r\n* The
Inline editing codebase **as been reworked entirely** so make sure\r\nto
stress test this side of things.\r\n\r\n#### Attribute
service\r\n\r\nAnother important aspect changed in this PR is the
`attributeService`:\r\nthis was tied to the previous Embeddable system
and it is now completely\r\nskipped. The Lens wrapper around that has
been reworked to be thinner\r\nand directly call the CM services.\r\n*
Please make sure to test thoroughly save/load SO flows\r\n\r\n####
Transformation API (by-value <=> by-reference flow)\r\n\r\nThe new
system adopts the new Transformation API (who prevents the panel\r\nto
fully reload on change).\r\n* Please make sure to test thoroughly
Visualize library <=> by value\r\nflows\r\n* In particular moving from
one type and another should change how the\r\nPanel Settings interpret
\"default\" values to reset\r\n\r\n#### Message system\r\n\r\nAlso this
part of the code was partially rewritten to be more manageable\r\nont he
embeddable surface, maintaining the core functionalities.\r\n* Please
make sure to test thoroughly error messages, warnings and
info\r\nmessages\r\n * Some scenarios to test includes\r\n* multi-layer
errors (i.e. use a broken KQL query for an\r\nannotation/multi-layers).
Check that the panel recovers correctly from\r\nit when resolved\r\n *
Missing references\r\n * Missing dataViews\r\n * Wrong formatted SO\r\n*
Configuration mistakes - check that a broken config is not
saveable\r\n\r\n### Other areas to check\r\n\r\n* Change filters in
dashboard/viz and check that are correctly handled\r\n* Check
drilldowns\r\n* Check that `Unsaved changes` are correctly detected\r\n*
Check that the panel updates correctly on `View` mode change\r\n\r\n##
Main type changes\r\n\r\nThis PR contains also some important `type`
changes, here's listed:\r\n* the `query` property now explicitly
supports ES|QL query type.\r\n * in `main` it used to work without type
support\r\n* `LensEmbeddableInput`/`LensEmbeddableOutput` types have
changed, but\r\nthe type names remained the same.\r\n\r\n## Follow ups
already planned:\r\n\r\nSome enhancements have been already collected
and will be addressed in a\r\nfollow up
[here](https://github.com/elastic/kibana/issues/195355)\r\n\r\n###
Tasks\r\n<details>\r\n\r\n<summary>Detailed list of tasks for the
refactor</summary>\r\n\r\n* New embeddable factory\r\n * [x] Define
visualization context\r\n * [x] Define observables to track\r\n * [x]
Basic panel settings\r\n * [x] Basic edit api\r\n * [x] inspector api
\r\n * [x] Library services\r\n * [x] Unified search api\r\n * [x] Basic
integrations api\r\n * [x] State management api for inline editing\r\n *
Publish correct observables\r\n * [x] `dataViews`\r\n * [x] `query`\r\n
* [x] `filters`\r\n * [x] `dataLoading`\r\n * [x] `savedObjectId`\r\n *
Actions\r\n * [x] View underlying data api\r\n * Custom renderer\r\n *
[x] Basic implementation\r\n * [x] Support callbacks\r\n * [x] Support
custom styling/paddings\r\n * Expose \r\n* [x] Handle searchSession\r\n*
Edit\r\n * [x] Open panel in Lens editor\r\n * Inline editing\r\n * [x]
rework references logic\r\n * #180726\r\n* integrate the logic to
extract filters dataViews from filters as for\r\nthe first bug in
#188545\r\n * DSL flyout\r\n * [x] open flyout\r\n * [x] save\r\n *
ES|QL\r\n * [x] open flyout on creation\r\n * [x] open flyout on
editing\r\n * [x] save\r\n* [x] revisit mounting logic to avoid detach
if possible (not possible\r\nyet)\r\n* [x] explore the integration with
the new `onEdit` api method used for\r\nthe inline editing~~\r\n * [x]
created panel management module and sorted it out\r\n * [x] open in
Editor\r\n * [x] fix the save on return to dashboard\r\n* ~~migrate by
ref to by value on inline editing~~ will do it in a\r\nfollow up PR\r\n*
Add from library issues\r\n * [x] Fix missing title and tags\r\n* Data
loading\r\n * [x] Compute all required data params for rendering\r\n*
Render the panel\r\n * [x] hook up user messaging system\r\n * [x] Merge
search context\r\n * [x] Expression variables\r\n * [x] panel
settings\r\n * [x] per panel time range\r\n * [x] per panel filter\r\n *
test with both DSL and ES|QL mode\r\n * Reload\r\n * [x] on unified
search updates\r\n * [x] on config changes\r\n * [x] on drilldown
changes?\r\n * [x] on view mode change \r\n * Attributes service\r\n *
[x] load from library\r\n * [x] save to
library\r\n\r\n</details>\r\n\r\n\r\n### Pending
issues:\r\n<details>\r\n\r\n<summary>Detailed list of
issues</summary>\r\n\r\n* [x] Unified histogram does not render in
Discover\r\n* [x] Saving to library from context menu in dashboard
doesn't save the\r\ntitle\r\n* [x] When adding a vis from the library
the new panel has no title\r\n* [x] Vis disappears when opening inline
editor and cancel\r\n * Create a viz, save and return to dashboard, then
edit it and cancel.\r\n* Saving an edit inline doesn't apply the changes
(i.e. changing the\r\nchart type)\r\n * [x] Changing the chart type on
the layer panel leads to a crash\r\n* [x] Changing the chart type won't
update the visualization (via both\r\nconfig panel or suggestions)\r\n*
[x] Edit a dimension will stretch the panel to overflow the fly-out\r\n*
[x] duplicating a dimension in the inline editor by drag and
drop\r\nworks buggy visually\r\n* When duplicating a panel, the new
panel gets the same title rather\r\nthan “title (copy)”\r\n * [x]
by-value panels\r\n * [x] by-reference panels\r\n* [x] brushing
throughout the timerange doesn’t work\r\n* [x] filtering when clicking
on value doesn’t work\r\n* [x] filtering from legend doesn’t work\r\n*
[x] for lens table, the sort ascending/descending actions don’t
have\r\nan effect\r\n* [x] filtering doesn’t display on table
either\r\n* Discover related issues\r\n* thanks to @davismcphee
investigation the source of the issue seems to\r\nbe related to the way
the `abortController` is managed in the new\r\nembeddable implementation
as Discover is relying on that.\r\n* [x] needs to investigate for a fix
that restores the previous\r\nbehaviour of the `abortController`
management\r\n * [x] the hits total count is not in sync with the
chart/table now\r\n* [x] Change chart type via suggestion panel when
inline editing in\r\nDiscover doesn't update the chart\r\n* [x] Dirty
panel issue (see @nickofthyme
's\r\n[comment](https://github.com/elastic/kibana/pull/186642#discussion_r1792659477)\r\n)\r\n*
[x] `Unsaved changes` issue (see
@mbondyra\r\n[comment](https://github.com/elastic/kibana/pull/186642#discussion_r1795384587))\r\n*
[x] Multiple errors not rendered correctly in panel when
blocking\r\n(i.e. missing field - `lens-message-list-trigger`
related)\r\n * [x] recover from a blocker error required 2 renders\r\n*
Missing SO error should not be handled for the custom render
component\r\n(legacy behaviour) but should be correctly handled for
dashboard (will\r\nbe handled in a follow up PR given that is broken on
`main` too)\r\n* [x] Too many requests on Unified Histogram when in
Discover (3 vs 2)\r\n* [x] Too many request on slow queries for Unified
Histogram (2 vs 1)\r\n* [x] Annotations preview issues (chart rendering
with height `0px`)\r\n* [x] `uuid` not propagated correctly\r\n* [x]
another flavour of this was `id` not propagated correctly into
the\r\n`data-test-embeddable-id` attribute\r\n* [x] Dispatch correctly
the `render` events\r\n* [x] refresh interval does not propagate thru
the Lens custom component\r\nin Discover (thanks to @jughosta to sort
this out )\r\n</details>\r\n\r\n---------\r\n\r\nCo-authored-by: Marta
Bondyra <4283304+mbondyra@users.noreply.github.com>\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Marco Vettorello <vettorello.marco@gmail.com>\r\nCo-authored-by: Marta
Bondyra <marta.bondyra@elastic.co>\r\nCo-authored-by: Bhavya RM
<bhavya@elastic.co>\r\nCo-authored-by: Stratoula Kalafateli
<efstratia.kalafateli@elastic.co>","sha":"61d0320c6422116dcf1c4e26f8f80760d7a3bb81","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Embedding","Feature:ExpressionLanguage","Team:Visualizations","release_note:skip","Feature:Lens","v9.0.0","Team:Obs
AI
Assistant","ci:project-deploy-observability","Team:obs-ux-management","backport:version","v8.18.0"],"number":186642,"url":"https://github.com/elastic/kibana/pull/186642","mergeCommit":{"message":"[Lens]
Embeddable react refactor (#186642)\n\n## Summary\r\n\r\nThis PR
contains the refactor of the Lens embeddable with the new
React\r\narchitecture.\r\n\r\nfix
https://github.com/elastic/kibana/issues/174957\r\nfixes
https://github.com/elastic/kibana/issues/180672\r\n\r\n**Current
status**:\r\n✅ Ready to review\r\n\r\n### Notes for testing and
reviewers\r\n\r\nOther than reworking the Lens embeddable with the new
architecture this\r\nPR contains the following major
changes.\r\n\r\n#### Edit flow\r\nThe `Edit` flow has changed to in-line
first using the new `Edit` API\r\nprovided by the new system\r\n* The
impact of this change can be noticed in the code on the `Canvas`\r\ncase
where the Custom Lens component is instructed to avoid the
inline\r\nediting. In all the other cases in-line editing is enabled by
default\r\nnow.\r\n* Another side effect of this has been the
replacement of the special\r\n`INLINE_EDIT` action id into the regular
`EDIT` action. Some tests have\r\nbeen affected by this replacing the
`clickEdit` function with the\r\n`openEditorFromFlyout` one.\r\n* The
Inline editing codebase **as been reworked entirely** so make sure\r\nto
stress test this side of things.\r\n\r\n#### Attribute
service\r\n\r\nAnother important aspect changed in this PR is the
`attributeService`:\r\nthis was tied to the previous Embeddable system
and it is now completely\r\nskipped. The Lens wrapper around that has
been reworked to be thinner\r\nand directly call the CM services.\r\n*
Please make sure to test thoroughly save/load SO flows\r\n\r\n####
Transformation API (by-value <=> by-reference flow)\r\n\r\nThe new
system adopts the new Transformation API (who prevents the panel\r\nto
fully reload on change).\r\n* Please make sure to test thoroughly
Visualize library <=> by value\r\nflows\r\n* In particular moving from
one type and another should change how the\r\nPanel Settings interpret
\"default\" values to reset\r\n\r\n#### Message system\r\n\r\nAlso this
part of the code was partially rewritten to be more manageable\r\nont he
embeddable surface, maintaining the core functionalities.\r\n* Please
make sure to test thoroughly error messages, warnings and
info\r\nmessages\r\n * Some scenarios to test includes\r\n* multi-layer
errors (i.e. use a broken KQL query for an\r\nannotation/multi-layers).
Check that the panel recovers correctly from\r\nit when resolved\r\n *
Missing references\r\n * Missing dataViews\r\n * Wrong formatted SO\r\n*
Configuration mistakes - check that a broken config is not
saveable\r\n\r\n### Other areas to check\r\n\r\n* Change filters in
dashboard/viz and check that are correctly handled\r\n* Check
drilldowns\r\n* Check that `Unsaved changes` are correctly detected\r\n*
Check that the panel updates correctly on `View` mode change\r\n\r\n##
Main type changes\r\n\r\nThis PR contains also some important `type`
changes, here's listed:\r\n* the `query` property now explicitly
supports ES|QL query type.\r\n * in `main` it used to work without type
support\r\n* `LensEmbeddableInput`/`LensEmbeddableOutput` types have
changed, but\r\nthe type names remained the same.\r\n\r\n## Follow ups
already planned:\r\n\r\nSome enhancements have been already collected
and will be addressed in a\r\nfollow up
[here](https://github.com/elastic/kibana/issues/195355)\r\n\r\n###
Tasks\r\n<details>\r\n\r\n<summary>Detailed list of tasks for the
refactor</summary>\r\n\r\n* New embeddable factory\r\n * [x] Define
visualization context\r\n * [x] Define observables to track\r\n * [x]
Basic panel settings\r\n * [x] Basic edit api\r\n * [x] inspector api
\r\n * [x] Library services\r\n * [x] Unified search api\r\n * [x] Basic
integrations api\r\n * [x] State management api for inline editing\r\n *
Publish correct observables\r\n * [x] `dataViews`\r\n * [x] `query`\r\n
* [x] `filters`\r\n * [x] `dataLoading`\r\n * [x] `savedObjectId`\r\n *
Actions\r\n * [x] View underlying data api\r\n * Custom renderer\r\n *
[x] Basic implementation\r\n * [x] Support callbacks\r\n * [x] Support
custom styling/paddings\r\n * Expose \r\n* [x] Handle searchSession\r\n*
Edit\r\n * [x] Open panel in Lens editor\r\n * Inline editing\r\n * [x]
rework references logic\r\n * #180726\r\n* integrate the logic to
extract filters dataViews from filters as for\r\nthe first bug in
#188545\r\n * DSL flyout\r\n * [x] open flyout\r\n * [x] save\r\n *
ES|QL\r\n * [x] open flyout on creation\r\n * [x] open flyout on
editing\r\n * [x] save\r\n* [x] revisit mounting logic to avoid detach
if possible (not possible\r\nyet)\r\n* [x] explore the integration with
the new `onEdit` api method used for\r\nthe inline editing~~\r\n * [x]
created panel management module and sorted it out\r\n * [x] open in
Editor\r\n * [x] fix the save on return to dashboard\r\n* ~~migrate by
ref to by value on inline editing~~ will do it in a\r\nfollow up PR\r\n*
Add from library issues\r\n * [x] Fix missing title and tags\r\n* Data
loading\r\n * [x] Compute all required data params for rendering\r\n*
Render the panel\r\n * [x] hook up user messaging system\r\n * [x] Merge
search context\r\n * [x] Expression variables\r\n * [x] panel
settings\r\n * [x] per panel time range\r\n * [x] per panel filter\r\n *
test with both DSL and ES|QL mode\r\n * Reload\r\n * [x] on unified
search updates\r\n * [x] on config changes\r\n * [x] on drilldown
changes?\r\n * [x] on view mode change \r\n * Attributes service\r\n *
[x] load from library\r\n * [x] save to
library\r\n\r\n</details>\r\n\r\n\r\n### Pending
issues:\r\n<details>\r\n\r\n<summary>Detailed list of
issues</summary>\r\n\r\n* [x] Unified histogram does not render in
Discover\r\n* [x] Saving to library from context menu in dashboard
doesn't save the\r\ntitle\r\n* [x] When adding a vis from the library
the new panel has no title\r\n* [x] Vis disappears when opening inline
editor and cancel\r\n * Create a viz, save and return to dashboard, then
edit it and cancel.\r\n* Saving an edit inline doesn't apply the changes
(i.e. changing the\r\nchart type)\r\n * [x] Changing the chart type on
the layer panel leads to a crash\r\n* [x] Changing the chart type won't
update the visualization (via both\r\nconfig panel or suggestions)\r\n*
[x] Edit a dimension will stretch the panel to overflow the fly-out\r\n*
[x] duplicating a dimension in the inline editor by drag and
drop\r\nworks buggy visually\r\n* When duplicating a panel, the new
panel gets the same title rather\r\nthan “title (copy)”\r\n * [x]
by-value panels\r\n * [x] by-reference panels\r\n* [x] brushing
throughout the timerange doesn’t work\r\n* [x] filtering when clicking
on value doesn’t work\r\n* [x] filtering from legend doesn’t work\r\n*
[x] for lens table, the sort ascending/descending actions don’t
have\r\nan effect\r\n* [x] filtering doesn’t display on table
either\r\n* Discover related issues\r\n* thanks to @davismcphee
investigation the source of the issue seems to\r\nbe related to the way
the `abortController` is managed in the new\r\nembeddable implementation
as Discover is relying on that.\r\n* [x] needs to investigate for a fix
that restores the previous\r\nbehaviour of the `abortController`
management\r\n * [x] the hits total count is not in sync with the
chart/table now\r\n* [x] Change chart type via suggestion panel when
inline editing in\r\nDiscover doesn't update the chart\r\n* [x] Dirty
panel issue (see @nickofthyme
's\r\n[comment](https://github.com/elastic/kibana/pull/186642#discussion_r1792659477)\r\n)\r\n*
[x] `Unsaved changes` issue (see
@mbondyra\r\n[comment](https://github.com/elastic/kibana/pull/186642#discussion_r1795384587))\r\n*
[x] Multiple errors not rendered correctly in panel when
blocking\r\n(i.e. missing field - `lens-message-list-trigger`
related)\r\n * [x] recover from a blocker error required 2 renders\r\n*
Missing SO error should not be handled for the custom render
component\r\n(legacy behaviour) but should be correctly handled for
dashboard (will\r\nbe handled in a follow up PR given that is broken on
`main` too)\r\n* [x] Too many requests on Unified Histogram when in
Discover (3 vs 2)\r\n* [x] Too many request on slow queries for Unified
Histogram (2 vs 1)\r\n* [x] Annotations preview issues (chart rendering
with height `0px`)\r\n* [x] `uuid` not propagated correctly\r\n* [x]
another flavour of this was `id` not propagated correctly into
the\r\n`data-test-embeddable-id` attribute\r\n* [x] Dispatch correctly
the `render` events\r\n* [x] refresh interval does not propagate thru
the Lens custom component\r\nin Discover (thanks to @jughosta to sort
this out )\r\n</details>\r\n\r\n---------\r\n\r\nCo-authored-by: Marta
Bondyra <4283304+mbondyra@users.noreply.github.com>\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Marco Vettorello <vettorello.marco@gmail.com>\r\nCo-authored-by: Marta
Bondyra <marta.bondyra@elastic.co>\r\nCo-authored-by: Bhavya RM
<bhavya@elastic.co>\r\nCo-authored-by: Stratoula Kalafateli
<efstratia.kalafateli@elastic.co>","sha":"61d0320c6422116dcf1c4e26f8f80760d7a3bb81"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/186642","number":186642,"mergeCommit":{"message":"[Lens]
Embeddable react refactor (#186642)\n\n## Summary\r\n\r\nThis PR
contains the refactor of the Lens embeddable with the new
React\r\narchitecture.\r\n\r\nfix
https://github.com/elastic/kibana/issues/174957\r\nfixes
https://github.com/elastic/kibana/issues/180672\r\n\r\n**Current
status**:\r\n✅ Ready to review\r\n\r\n### Notes for testing and
reviewers\r\n\r\nOther than reworking the Lens embeddable with the new
architecture this\r\nPR contains the following major
changes.\r\n\r\n#### Edit flow\r\nThe `Edit` flow has changed to in-line
first using the new `Edit` API\r\nprovided by the new system\r\n* The
impact of this change can be noticed in the code on the `Canvas`\r\ncase
where the Custom Lens component is instructed to avoid the
inline\r\nediting. In all the other cases in-line editing is enabled by
default\r\nnow.\r\n* Another side effect of this has been the
replacement of the special\r\n`INLINE_EDIT` action id into the regular
`EDIT` action. Some tests have\r\nbeen affected by this replacing the
`clickEdit` function with the\r\n`openEditorFromFlyout` one.\r\n* The
Inline editing codebase **as been reworked entirely** so make sure\r\nto
stress test this side of things.\r\n\r\n#### Attribute
service\r\n\r\nAnother important aspect changed in this PR is the
`attributeService`:\r\nthis was tied to the previous Embeddable system
and it is now completely\r\nskipped. The Lens wrapper around that has
been reworked to be thinner\r\nand directly call the CM services.\r\n*
Please make sure to test thoroughly save/load SO flows\r\n\r\n####
Transformation API (by-value <=> by-reference flow)\r\n\r\nThe new
system adopts the new Transformation API (who prevents the panel\r\nto
fully reload on change).\r\n* Please make sure to test thoroughly
Visualize library <=> by value\r\nflows\r\n* In particular moving from
one type and another should change how the\r\nPanel Settings interpret
\"default\" values to reset\r\n\r\n#### Message system\r\n\r\nAlso this
part of the code was partially rewritten to be more manageable\r\nont he
embeddable surface, maintaining the core functionalities.\r\n* Please
make sure to test thoroughly error messages, warnings and
info\r\nmessages\r\n * Some scenarios to test includes\r\n* multi-layer
errors (i.e. use a broken KQL query for an\r\nannotation/multi-layers).
Check that the panel recovers correctly from\r\nit when resolved\r\n *
Missing references\r\n * Missing dataViews\r\n * Wrong formatted SO\r\n*
Configuration mistakes - check that a broken config is not
saveable\r\n\r\n### Other areas to check\r\n\r\n* Change filters in
dashboard/viz and check that are correctly handled\r\n* Check
drilldowns\r\n* Check that `Unsaved changes` are correctly detected\r\n*
Check that the panel updates correctly on `View` mode change\r\n\r\n##
Main type changes\r\n\r\nThis PR contains also some important `type`
changes, here's listed:\r\n* the `query` property now explicitly
supports ES|QL query type.\r\n * in `main` it used to work without type
support\r\n* `LensEmbeddableInput`/`LensEmbeddableOutput` types have
changed, but\r\nthe type names remained the same.\r\n\r\n## Follow ups
already planned:\r\n\r\nSome enhancements have been already collected
and will be addressed in a\r\nfollow up
[here](https://github.com/elastic/kibana/issues/195355)\r\n\r\n###
Tasks\r\n<details>\r\n\r\n<summary>Detailed list of tasks for the
refactor</summary>\r\n\r\n* New embeddable factory\r\n * [x] Define
visualization context\r\n * [x] Define observables to track\r\n * [x]
Basic panel settings\r\n * [x] Basic edit api\r\n * [x] inspector api
\r\n * [x] Library services\r\n * [x] Unified search api\r\n * [x] Basic
integrations api\r\n * [x] State management api for inline editing\r\n *
Publish correct observables\r\n * [x] `dataViews`\r\n * [x] `query`\r\n
* [x] `filters`\r\n * [x] `dataLoading`\r\n * [x] `savedObjectId`\r\n *
Actions\r\n * [x] View underlying data api\r\n * Custom renderer\r\n *
[x] Basic implementation\r\n * [x] Support callbacks\r\n * [x] Support
custom styling/paddings\r\n * Expose \r\n* [x] Handle searchSession\r\n*
Edit\r\n * [x] Open panel in Lens editor\r\n * Inline editing\r\n * [x]
rework references logic\r\n * #180726\r\n* integrate the logic to
extract filters dataViews from filters as for\r\nthe first bug in
#188545\r\n * DSL flyout\r\n * [x] open flyout\r\n * [x] save\r\n *
ES|QL\r\n * [x] open flyout on creation\r\n * [x] open flyout on
editing\r\n * [x] save\r\n* [x] revisit mounting logic to avoid detach
if possible (not possible\r\nyet)\r\n* [x] explore the integration with
the new `onEdit` api method used for\r\nthe inline editing~~\r\n * [x]
created panel management module and sorted it out\r\n * [x] open in
Editor\r\n * [x] fix the save on return to dashboard\r\n* ~~migrate by
ref to by value on inline editing~~ will do it in a\r\nfollow up PR\r\n*
Add from library issues\r\n * [x] Fix missing title and tags\r\n* Data
loading\r\n * [x] Compute all required data params for rendering\r\n*
Render the panel\r\n * [x] hook up user messaging system\r\n * [x] Merge
search context\r\n * [x] Expression variables\r\n * [x] panel
settings\r\n * [x] per panel time range\r\n * [x] per panel filter\r\n *
test with both DSL and ES|QL mode\r\n * Reload\r\n * [x] on unified
search updates\r\n * [x] on config changes\r\n * [x] on drilldown
changes?\r\n * [x] on view mode change \r\n * Attributes service\r\n *
[x] load from library\r\n * [x] save to
library\r\n\r\n</details>\r\n\r\n\r\n### Pending
issues:\r\n<details>\r\n\r\n<summary>Detailed list of
issues</summary>\r\n\r\n* [x] Unified histogram does not render in
Discover\r\n* [x] Saving to library from context menu in dashboard
doesn't save the\r\ntitle\r\n* [x] When adding a vis from the library
the new panel has no title\r\n* [x] Vis disappears when opening inline
editor and cancel\r\n * Create a viz, save and return to dashboard, then
edit it and cancel.\r\n* Saving an edit inline doesn't apply the changes
(i.e. changing the\r\nchart type)\r\n * [x] Changing the chart type on
the layer panel leads to a crash\r\n* [x] Changing the chart type won't
update the visualization (via both\r\nconfig panel or suggestions)\r\n*
[x] Edit a dimension will stretch the panel to overflow the fly-out\r\n*
[x] duplicating a dimension in the inline editor by drag and
drop\r\nworks buggy visually\r\n* When duplicating a panel, the new
panel gets the same title rather\r\nthan “title (copy)”\r\n * [x]
by-value panels\r\n * [x] by-reference panels\r\n* [x] brushing
throughout the timerange doesn’t work\r\n* [x] filtering when clicking
on value doesn’t work\r\n* [x] filtering from legend doesn’t work\r\n*
[x] for lens table, the sort ascending/descending actions don’t
have\r\nan effect\r\n* [x] filtering doesn’t display on table
either\r\n* Discover related issues\r\n* thanks to @davismcphee
investigation the source of the issue seems to\r\nbe related to the way
the `abortController` is managed in the new\r\nembeddable implementation
as Discover is relying on that.\r\n* [x] needs to investigate for a fix
that restores the previous\r\nbehaviour of the `abortController`
management\r\n * [x] the hits total count is not in sync with the
chart/table now\r\n* [x] Change chart type via suggestion panel when
inline editing in\r\nDiscover doesn't update the chart\r\n* [x] Dirty
panel issue (see @nickofthyme
's\r\n[comment](https://github.com/elastic/kibana/pull/186642#discussion_r1792659477)\r\n)\r\n*
[x] `Unsaved changes` issue (see
@mbondyra\r\n[comment](https://github.com/elastic/kibana/pull/186642#discussion_r1795384587))\r\n*
[x] Multiple errors not rendered correctly in panel when
blocking\r\n(i.e. missing field - `lens-message-list-trigger`
related)\r\n * [x] recover from a blocker error required 2 renders\r\n*
Missing SO error should not be handled for the custom render
component\r\n(legacy behaviour) but should be correctly handled for
dashboard (will\r\nbe handled in a follow up PR given that is broken on
`main` too)\r\n* [x] Too many requests on Unified Histogram when in
Discover (3 vs 2)\r\n* [x] Too many request on slow queries for Unified
Histogram (2 vs 1)\r\n* [x] Annotations preview issues (chart rendering
with height `0px`)\r\n* [x] `uuid` not propagated correctly\r\n* [x]
another flavour of this was `id` not propagated correctly into
the\r\n`data-test-embeddable-id` attribute\r\n* [x] Dispatch correctly
the `render` events\r\n* [x] refresh interval does not propagate thru
the Lens custom component\r\nin Discover (thanks to @jughosta to sort
this out )\r\n</details>\r\n\r\n---------\r\n\r\nCo-authored-by: Marta
Bondyra <4283304+mbondyra@users.noreply.github.com>\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Marco Vettorello <vettorello.marco@gmail.com>\r\nCo-authored-by: Marta
Bondyra <marta.bondyra@elastic.co>\r\nCo-authored-by: Bhavya RM
<bhavya@elastic.co>\r\nCo-authored-by: Stratoula Kalafateli
<efstratia.kalafateli@elastic.co>","sha":"61d0320c6422116dcf1c4e26f8f80760d7a3bb81"}},{"branch":"8.x","label":"v8.18.0","labelRegex":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
  • Loading branch information
dej611 authored Nov 27, 2024
1 parent edab1bb commit 556deb0
Show file tree
Hide file tree
Showing 209 changed files with 8,921 additions and 6,873 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const ReactEmbeddableRenderer = <
| 'hideLoader'
| 'hideHeader'
| 'hideInspector'
| 'getActions'
>;
hidePanelChrome?: boolean;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import {
EmbeddableComponent,
FieldBasedIndexPatternColumn,
TypedLensByValueInput,
LensByValueInput,
} from '@kbn/lens-plugin/public';
import { Datatable } from '@kbn/expressions-plugin/common';
import { render, screen, waitFor } from '@testing-library/react';
import '@testing-library/jest-dom';
import userEvent from '@testing-library/user-event';
import { I18nProvider } from '@kbn/i18n-react';
import { GroupPreview } from './group_preview';
import { LensByValueInput } from '@kbn/lens-plugin/public/embeddable';
import { DATA_LAYER_ID, DATE_HISTOGRAM_COLUMN_ID, getCurrentTimeField } from './lens_attributes';
import { EuiSuperDatePickerTestHarness } from '@kbn/test-eui-helpers';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,28 +198,25 @@ export const GroupPreview = ({
justifyContent="center"
>
<EuiFlexItem grow={0}>
<div
<LensEmbeddableComponent
css={css`
& > div {
height: 400px;
width: 100%;
}
`}
>
<LensEmbeddableComponent
data-test-subj="chart"
id="annotation-library-preview"
timeRange={chartTimeRange}
attributes={lensAttributes}
onBrushEnd={({ range }) =>
setChartTimeRange({
from: new Date(range[0]).toISOString(),
to: new Date(range[1]).toISOString(),
})
}
searchSessionId={searchSessionId}
/>
</div>
data-test-subj="chart"
id="annotation-library-preview"
timeRange={chartTimeRange}
attributes={lensAttributes}
onBrushEnd={({ range }) =>
setChartTimeRange({
from: new Date(range[0]).toISOString(),
to: new Date(range[1]).toISOString(),
})
}
searchSessionId={searchSessionId}
/>
</EuiFlexItem>
</EuiFlexGroup>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface ExpressionRendererParams extends IExpressionLoaderParams {
debounce?: number;
expression: string | ExpressionAstExpression;
hasCustomErrorRenderer?: boolean;
onData$?<TData, TInspectorAdapters>(
onData$?<TData, TInspectorAdapters extends unknown>(
data: TData,
adapters?: TInspectorAdapters,
partial?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import React from 'react';
import { of } from 'rxjs';
import { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import { Plugin } from '.';
import { createTopNav } from './top_nav_menu';

export type Setup = jest.Mocked<ReturnType<Plugin['setup']>>;
export type Start = jest.Mocked<ReturnType<Plugin['start']>>;

// mock mountPointPortal
jest.mock('@kbn/react-kibana-mount', () => {
const original = jest.requireActual('@kbn/react-kibana-mount');
return {
...original,
MountPointPortal: jest.fn(({ children }) => children),
};
});

const createSetupContract = (): jest.Mocked<Setup> => {
const setupContract = {
registerMenuItem: jest.fn(),
Expand All @@ -21,12 +32,21 @@ const createSetupContract = (): jest.Mocked<Setup> => {
return setupContract;
};

export const unifiedSearchMock = {
ui: {
SearchBar: () => <div className="searchBar" />,
AggregateQuerySearchBar: () => <div className="searchBar" />,
},
} as unknown as UnifiedSearchPublicPluginStart;

const createStartContract = (): jest.Mocked<Start> => {
const startContract = {
ui: {
TopNavMenu: jest.fn(),
createTopNavWithCustomContext: jest.fn().mockImplementation(() => jest.fn()),
AggregateQueryTopNavMenu: jest.fn(),
TopNavMenu: jest.fn().mockImplementation(createTopNav(unifiedSearchMock, [])),
AggregateQueryTopNavMenu: jest.fn().mockImplementation(createTopNav(unifiedSearchMock, [])),
createTopNavWithCustomContext: jest
.fn()
.mockImplementation(createTopNav(unifiedSearchMock, [])),
},
addSolutionNavigation: jest.fn(),
isSolutionNavEnabled$: of(false),
Expand Down
19 changes: 6 additions & 13 deletions src/plugins/navigation/public/top_nav_menu/top_nav_menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,9 @@ import { MountPoint } from '@kbn/core/public';
import { TopNavMenu } from './top_nav_menu';
import { TopNavMenuData } from './top_nav_menu_data';
import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers';
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import { EuiToolTipProps } from '@elastic/eui';
import type { TopNavMenuBadgeProps } from './top_nav_menu_badges';

const unifiedSearch = {
ui: {
SearchBar: () => <div className="searchBar" />,
AggregateQuerySearchBar: () => <div className="searchBar" />,
},
} as unknown as UnifiedSearchPublicPluginStart;
import { unifiedSearchMock } from '../mocks';

describe('TopNavMenu', () => {
const WRAPPER_SELECTOR = '.kbnTopNavMenu__wrapper';
Expand Down Expand Up @@ -97,7 +90,7 @@ describe('TopNavMenu', () => {

it('Should render search bar', () => {
const component = mountWithIntl(
<TopNavMenu appName={'test'} showSearchBar={true} unifiedSearch={unifiedSearch} />
<TopNavMenu appName={'test'} showSearchBar={true} unifiedSearch={unifiedSearchMock} />
);
expect(component.find(WRAPPER_SELECTOR).length).toBe(1);
expect(component.find(TOP_NAV_ITEM_SELECTOR).length).toBe(0);
Expand All @@ -110,7 +103,7 @@ describe('TopNavMenu', () => {
appName={'test'}
config={menuItems}
showSearchBar={true}
unifiedSearch={unifiedSearch}
unifiedSearch={unifiedSearchMock}
/>
);
expect(component.find(WRAPPER_SELECTOR).length).toBe(1);
Expand All @@ -124,7 +117,7 @@ describe('TopNavMenu', () => {
appName={'test'}
config={menuItems}
showSearchBar={true}
unifiedSearch={unifiedSearch}
unifiedSearch={unifiedSearchMock}
className={'myCoolClass'}
/>
);
Expand Down Expand Up @@ -172,7 +165,7 @@ describe('TopNavMenu', () => {
appName={'test'}
config={menuItems}
showSearchBar={true}
unifiedSearch={unifiedSearch}
unifiedSearch={unifiedSearchMock}
setMenuMountPoint={setMountPoint}
/>
);
Expand All @@ -195,7 +188,7 @@ describe('TopNavMenu', () => {
appName={'test'}
badges={badges}
showSearchBar={true}
unifiedSearch={unifiedSearch}
unifiedSearch={unifiedSearchMock}
setMenuMountPoint={setMountPoint}
/>
);
Expand Down
31 changes: 13 additions & 18 deletions src/plugins/unified_histogram/public/chart/chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

import React, { memo, ReactElement, useCallback, useEffect, useMemo, useState } from 'react';
import type { Observable } from 'rxjs';
import { Subject } from 'rxjs';
import useObservable from 'react-use/lib/useObservable';
import { IconButtonGroup, type IconButtonGroupProps } from '@kbn/shared-ux-button-toolbar';
Expand Down Expand Up @@ -70,7 +69,7 @@ export interface ChartProps {
disabledActions?: LensEmbeddableInput['disabledActions'];
input$?: UnifiedHistogramInput$;
lensAdapters?: UnifiedHistogramChartLoadEvent['adapters'];
lensEmbeddableOutput$?: Observable<LensEmbeddableOutput>;
dataLoading$?: LensEmbeddableOutput['dataLoading'];
isChartLoading?: boolean;
onChartHiddenChange?: (chartHidden: boolean) => void;
onTimeIntervalChange?: (timeInterval: string) => void;
Expand Down Expand Up @@ -105,7 +104,7 @@ export function Chart({
disabledActions,
input$: originalInput$,
lensAdapters,
lensEmbeddableOutput$,
dataLoading$,
isChartLoading,
onChartHiddenChange,
onTimeIntervalChange,
Expand Down Expand Up @@ -383,28 +382,24 @@ export function Chart({
)}
{canSaveVisualization && isSaveModalVisible && visContext.attributes && (
<LensSaveModalComponent
initialInput={
removeTablesFromLensAttributes(visContext.attributes) as unknown as LensEmbeddableInput
}
initialInput={removeTablesFromLensAttributes(visContext.attributes)}
onSave={() => {}}
onClose={() => setIsSaveModalVisible(false)}
isSaveable={false}
/>
)}
{isFlyoutVisible && !!visContext && !!lensVisServiceCurrentSuggestionContext && (
<ChartConfigPanel
{...{
services,
visContext,
lensAdapters,
lensEmbeddableOutput$,
isFlyoutVisible,
setIsFlyoutVisible,
isPlainRecord,
query,
currentSuggestionContext: lensVisServiceCurrentSuggestionContext,
onSuggestionContextEdit,
}}
services={services}
visContext={visContext}
lensAdapters={lensAdapters}
dataLoading$={dataLoading$}
isFlyoutVisible={isFlyoutVisible}
setIsFlyoutVisible={setIsFlyoutVisible}
isPlainRecord={isPlainRecord}
query={query}
currentSuggestionContext={lensVisServiceCurrentSuggestionContext}
onSuggestionContextEdit={onSuggestionContextEdit}
/>
)}
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

import React, { ComponentProps, useCallback, useEffect, useRef, useState } from 'react';
import type { Observable } from 'rxjs';
import type { AggregateQuery, Query } from '@kbn/es-query';
import { isEqual, isObject } from 'lodash';
import type { LensEmbeddableOutput, Suggestion } from '@kbn/lens-plugin/public';
Expand All @@ -29,7 +28,7 @@ export function ChartConfigPanel({
services,
visContext,
lensAdapters,
lensEmbeddableOutput$,
dataLoading$,
currentSuggestionContext,
isFlyoutVisible,
setIsFlyoutVisible,
Expand All @@ -42,7 +41,7 @@ export function ChartConfigPanel({
isFlyoutVisible: boolean;
setIsFlyoutVisible: (flag: boolean) => void;
lensAdapters?: UnifiedHistogramChartLoadEvent['adapters'];
lensEmbeddableOutput$?: Observable<LensEmbeddableOutput>;
dataLoading$?: LensEmbeddableOutput['dataLoading'];
currentSuggestionContext: UnifiedHistogramSuggestionContext;
isPlainRecord?: boolean;
query?: Query | AggregateQuery;
Expand Down Expand Up @@ -108,7 +107,7 @@ export function ChartConfigPanel({
updateSuggestion={updateSuggestion}
updatePanelState={updatePanelState}
lensAdapters={lensAdapters}
output$={lensEmbeddableOutput$}
dataLoading$={dataLoading$}
displayFlyoutHeader
closeFlyout={() => {
setIsFlyoutVisible(false);
Expand Down Expand Up @@ -141,7 +140,7 @@ export function ChartConfigPanel({
isFlyoutVisible,
setIsFlyoutVisible,
lensAdapters,
lensEmbeddableOutput$,
dataLoading$,
currentSuggestionType,
]);

Expand Down
Loading

0 comments on commit 556deb0

Please sign in to comment.