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] Embeddable react refactor #186642

Merged
merged 321 commits into from
Nov 26, 2024
Merged

Conversation

dej611
Copy link
Contributor

@dej611 dej611 commented Jun 21, 2024

Summary

This PR contains the refactor of the Lens embeddable with the new React architecture.

fix #174957
fixes #180672

Current status:
✅ Ready to review

Notes for testing and reviewers

Other than reworking the Lens embeddable with the new architecture this PR contains the following major changes.

Edit flow

The Edit flow has changed to in-line first using the new Edit API provided by the new system

  • The impact of this change can be noticed in the code on the Canvas case where the Custom Lens component is instructed to avoid the inline editing. In all the other cases in-line editing is enabled by default now.
  • Another side effect of this has been the replacement of the special INLINE_EDIT action id into the regular EDIT action. Some tests have been affected by this replacing the clickEdit function with the openEditorFromFlyout one.
  • The Inline editing codebase as been reworked entirely so make sure to stress test this side of things.

Attribute service

Another important aspect changed in this PR is the attributeService: this was tied to the previous Embeddable system and it is now completely skipped. The Lens wrapper around that has been reworked to be thinner and directly call the CM services.

  • Please make sure to test thoroughly save/load SO flows

Transformation API (by-value <=> by-reference flow)

The new system adopts the new Transformation API (who prevents the panel to fully reload on change).

  • Please make sure to test thoroughly Visualize library <=> by value flows
    • In particular moving from one type and another should change how the Panel Settings interpret "default" values to reset

Message system

Also this part of the code was partially rewritten to be more manageable ont he embeddable surface, maintaining the core functionalities.

  • Please make sure to test thoroughly error messages, warnings and info messages
    • Some scenarios to test includes
      • multi-layer errors (i.e. use a broken KQL query for an annotation/multi-layers). Check that the panel recovers correctly from it when resolved
      • Missing references
      • Missing dataViews
      • Wrong formatted SO
      • Configuration mistakes - check that a broken config is not saveable

Other areas to check

  • Change filters in dashboard/viz and check that are correctly handled
  • Check drilldowns
  • Check that Unsaved changes are correctly detected
  • Check that the panel updates correctly on View mode change

Main type changes

This PR contains also some important type changes, here's listed:

  • the query property now explicitly supports ES|QL query type.
    • in main it used to work without type support
  • LensEmbeddableInput/LensEmbeddableOutput types have changed, but the type names remained the same.

Follow ups already planned:

Some enhancements have been already collected and will be addressed in a follow up here

Tasks

Detailed list of tasks for the refactor
  • New embeddable factory
    • Define visualization context
    • Define observables to track
    • Basic panel settings
    • Basic edit api
    • inspector api
    • Library services
    • Unified search api
    • Basic integrations api
    • State management api for inline editing
    • Publish correct observables
      • dataViews
      • query
      • filters
      • dataLoading
      • savedObjectId
    • Actions
      • View underlying data api
  • Custom renderer
    • Basic implementation
    • Support callbacks
    • Support custom styling/paddings
  • Expose
  • Handle searchSession
  • Edit
  • Add from library issues
    • Fix missing title and tags
  • Data loading
    • Compute all required data params for rendering
  • Render the panel
    • hook up user messaging system
    • Merge search context
    • Expression variables
    • panel settings
      • per panel time range
      • per panel filter
      • test with both DSL and ES|QL mode
    • Reload
      • on unified search updates
      • on config changes
      • on drilldown changes?
      • on view mode change
  • Attributes service
    • load from library
    • save to library

Pending issues:

Detailed list of issues
  • Unified histogram does not render in Discover
  • Saving to library from context menu in dashboard doesn't save the title
  • When adding a vis from the library the new panel has no title
  • Vis disappears when opening inline editor and cancel
    • Create a viz, save and return to dashboard, then edit it and cancel.
  • Saving an edit inline doesn't apply the changes (i.e. changing the chart type)
    • Changing the chart type on the layer panel leads to a crash
    • Changing the chart type won't update the visualization (via both config panel or suggestions)
  • Edit a dimension will stretch the panel to overflow the fly-out
  • duplicating a dimension in the inline editor by drag and drop works buggy visually
  • When duplicating a panel, the new panel gets the same title rather than “title (copy)”
    • by-value panels
    • by-reference panels
  • brushing throughout the timerange doesn’t work
  • filtering when clicking on value doesn’t work
  • filtering from legend doesn’t work
  • for lens table, the sort ascending/descending actions don’t have an effect
  • filtering doesn’t display on table either
  • Discover related issues
    • thanks to @davismcphee investigation the source of the issue seems to be related to the way the abortController is managed in the new embeddable implementation as Discover is relying on that.
    • needs to investigate for a fix that restores the previous behaviour of the abortController management
    • the hits total count is not in sync with the chart/table now
    • Change chart type via suggestion panel when inline editing in Discover doesn't update the chart
  • Dirty panel issue (see @nickofthyme 's comment )
  • Unsaved changes issue (see @mbondyra comment)
  • Multiple errors not rendered correctly in panel when blocking (i.e. missing field - lens-message-list-trigger related)
    • recover from a blocker error required 2 renders
    • Missing SO error should not be handled for the custom render component (legacy behaviour) but should be correctly handled for dashboard (will be handled in a follow up PR given that is broken on main too)
  • Too many requests on Unified Histogram when in Discover (3 vs 2)
  • Too many request on slow queries for Unified Histogram (2 vs 1)
  • Annotations preview issues (chart rendering with height 0px)
  • uuid not propagated correctly
    • another flavour of this was id not propagated correctly into the data-test-embeddable-id attribute
  • Dispatch correctly the render events
  • refresh interval does not propagate thru the Lens custom component in Discover (thanks to @jughosta to sort this out )

expect(getTrigger).not.toHaveBeenCalled();
});

it('handles edit actions ', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test has moved into the on_event.test.ts suite

expect(getTrigger).not.toHaveBeenCalled();
});

it('should call onBrush event on brushing', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test has moved into the on_event.test.ts suite

expect(onBrushEnd).toHaveBeenCalledTimes(1);
});

it('should prevent the onBrush trigger when calling preventDefault', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test has moved into the on_event.test.ts suite

expect(getTrigger).not.toHaveBeenCalled();
});

it('should call onTableRowClick event ', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test has moved into the on_event.test.ts suite

expect(onTableRowClick).toHaveBeenCalledTimes(1);
});

it('should prevent onTableRowClick trigger when calling preventDefault ', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test has moved into the on_event.test.ts suite

expect(onFilter).toHaveBeenCalledTimes(1);
});

it('should prevent the onFilter trigger when calling preventDefault', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test has moved into the on_event.test.ts suite

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@markov00 found a new bug with the dashboard Reset function.
I've managed to reproduce the issue in main too for Visualize and Maps and it is not possible atm to workaround it: #201627

@elasticmachine
Copy link
Contributor

⏳ Build in-progress

  • Buildkite Build
  • Commit: 684b106
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-186642-684b106effc4

History

@markov00 markov00 self-requested a review November 26, 2024 08:32
@dej611 dej611 merged commit 61d0320 into elastic:main Nov 26, 2024
52 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12026735650

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.x Backport failed because of merge conflicts

You might need to backport the following PRs to 8.x:
- [Synthetics] Fix overview page vizs for large number of monitors !! (#199512)

Manual backport

To create the backport manually run:

node scripts/backport --pr 186642

Questions ?

Please refer to the Backport tool documentation

@dej611
Copy link
Contributor Author

dej611 commented Nov 26, 2024

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Nov 26, 2024
## Summary

This PR contains the refactor of the Lens embeddable with the new React
architecture.

fix elastic#174957
fixes elastic#180672

**Current status**:
✅ Ready to review

### Notes for testing and reviewers

Other than reworking the Lens embeddable with the new architecture this
PR contains the following major changes.

#### Edit flow
The `Edit` flow has changed to in-line first using the new `Edit` API
provided by the new system
* The impact of this change can be noticed in the code on the `Canvas`
case where the Custom Lens component is instructed to avoid the inline
editing. In all the other cases in-line editing is enabled by default
now.
* Another side effect of this has been the replacement of the special
`INLINE_EDIT` action id into the regular `EDIT` action. Some tests have
been affected by this replacing the `clickEdit` function with the
`openEditorFromFlyout` one.
* The Inline editing codebase **as been reworked entirely** so make sure
to stress test this side of things.

#### Attribute service

Another important aspect changed in this PR is the `attributeService`:
this was tied to the previous Embeddable system and it is now completely
skipped. The Lens wrapper around that has been reworked to be thinner
and directly call the CM services.
* Please make sure to test thoroughly save/load SO flows

#### Transformation API (by-value <=> by-reference flow)

The new system adopts the new Transformation API (who prevents the panel
to fully reload on change).
* Please make sure to test thoroughly Visualize library <=> by value
flows
* In particular moving from one type and another should change how the
Panel Settings interpret "default" values to reset

#### Message system

Also this part of the code was partially rewritten to be more manageable
ont he embeddable surface, maintaining the core functionalities.
* Please make sure to test thoroughly error messages, warnings and info
messages
  * Some scenarios to test includes
* multi-layer errors (i.e. use a broken KQL query for an
annotation/multi-layers). Check that the panel recovers correctly from
it when resolved
    * Missing references
    * Missing dataViews
    * Wrong formatted SO
* Configuration mistakes - check that a broken config is not saveable

### Other areas to check

* Change filters in dashboard/viz and check that are correctly handled
* Check drilldowns
* Check that `Unsaved changes` are correctly detected
* Check that the panel updates correctly on `View` mode change

## Main type changes

This PR contains also some important `type` changes, here's listed:
* the `query` property now explicitly supports ES|QL query type.
  * in `main` it used to work without type support
* `LensEmbeddableInput`/`LensEmbeddableOutput` types have changed, but
the type names remained the same.

## Follow ups already planned:

Some enhancements have been already collected and will be addressed in a
follow up [here](elastic#195355)

### Tasks
<details>

<summary>Detailed list of tasks for the refactor</summary>

* New embeddable factory
  * [x] Define visualization context
  * [x] Define observables to track
  * [x] Basic panel settings
  * [x] Basic edit api
  * [x] inspector api 
  * [x] Library services
  * [x] Unified search api
  * [x] Basic integrations api
  * [x] State management api for inline editing
  * Publish correct observables
    * [x] `dataViews`
    * [x] `query`
    * [x] `filters`
    * [x] `dataLoading`
    * [x] `savedObjectId`
  * Actions
    * [x] View underlying data api
 * Custom renderer
   * [x] Basic implementation
   * [x] Support callbacks
   * [x] Support custom styling/paddings
 * Expose  
* [x] Handle searchSession
* Edit
  * [x] Open panel in Lens editor
  * Inline editing
    * [x] rework references logic
      * elastic#180726
* integrate the logic to extract filters dataViews from filters as for
the first bug in elastic#188545
    * DSL flyout
      * [x] open flyout
      * [x] save
    * ES|QL
      * [x] open flyout on creation
      * [x] open flyout on editing
      * [x] save
* [x] revisit mounting logic to avoid detach if possible (not possible
yet)
* [x] explore the integration with the new `onEdit` api method used for
the inline editing~~
      * [x] created panel management module and sorted it out
    * [x] open in Editor
      * [x] fix the save on return to dashboard
* ~~migrate by ref to by value on inline editing~~ will do it in a
follow up PR
* Add from library issues
  * [x] Fix missing title and tags
* Data loading
  * [x] Compute all required data params for rendering
* Render the panel
  * [x] hook up user messaging system
  * [x] Merge search context
  * [x] Expression variables
  * [x] panel settings
    * [x] per panel time range
    * [x] per panel filter
    * test with both DSL and ES|QL mode
  * Reload
    * [x] on unified search updates
    * [x] on config changes
    * [x] on drilldown changes?
    * [x] on view mode change 
 * Attributes service
   * [x] load from library
   * [x] save to library

</details>


### Pending issues:
<details>

<summary>Detailed list of issues</summary>

* [x] Unified histogram does not render in Discover
* [x] Saving to library from context menu in dashboard doesn't save the
title
* [x] When adding a vis from the library the new panel has no title
* [x] Vis disappears when opening inline editor and cancel
  * Create a viz, save and return to dashboard, then edit it and cancel.
* Saving an edit inline doesn't apply the changes (i.e. changing the
chart type)
  * [x] Changing the chart type on the layer panel leads to a crash
* [x] Changing the chart type won't update the visualization (via both
config panel or suggestions)
* [x] Edit a dimension will stretch the panel to overflow the fly-out
* [x] duplicating a dimension in the inline editor by drag and drop
works buggy visually
* When duplicating a panel, the new panel gets the same title rather
than “title (copy)”
  * [x] by-value panels
  * [x] by-reference panels
* [x] brushing throughout the timerange doesn’t work
* [x] filtering when clicking on value doesn’t work
* [x] filtering from legend doesn’t work
* [x] for lens table, the sort ascending/descending actions don’t have
an effect
* [x] filtering doesn’t display on table either
* Discover related issues
* thanks to @davismcphee investigation the source of the issue seems to
be related to the way the `abortController` is managed in the new
embeddable implementation as Discover is relying on that.
* [x] needs to investigate for a fix that restores the previous
behaviour of the `abortController` management
  * [x] the hits total count is not in sync with the chart/table now
* [x] Change chart type via suggestion panel when inline editing in
Discover doesn't update the chart
* [x] Dirty panel issue (see @nickofthyme 's
[comment](elastic#186642 (comment))
)
* [x] `Unsaved changes` issue (see @mbondyra
[comment](elastic#186642 (comment)))
* [x] Multiple errors not rendered correctly in panel when blocking
(i.e. missing field - `lens-message-list-trigger` related)
  * [x] recover from a blocker error required 2 renders
* Missing SO error should not be handled for the custom render component
(legacy behaviour) but should be correctly handled for dashboard (will
be handled in a follow up PR given that is broken on `main` too)
* [x] Too many requests on Unified Histogram when in Discover (3 vs 2)
* [x] Too many request on slow queries for Unified Histogram (2 vs 1)
* [x] Annotations preview issues (chart rendering with height `0px`)
* [x] `uuid` not propagated correctly
* [x] another flavour of this was `id` not propagated correctly into the
`data-test-embeddable-id` attribute
* [x] Dispatch correctly the `render` events
* [x] refresh interval does not propagate thru the Lens custom component
in Discover (thanks to @jughosta to sort this out )
</details>

---------

Co-authored-by: Marta Bondyra <4283304+mbondyra@users.noreply.github.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Marco Vettorello <vettorello.marco@gmail.com>
Co-authored-by: Marta Bondyra <marta.bondyra@elastic.co>
Co-authored-by: Bhavya RM <bhavya@elastic.co>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
dej611 added a commit that referenced this pull request Nov 27, 2024
# 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-->
markov00 added a commit that referenced this pull request Dec 10, 2024
## Summary

When using the new Custom Lens embeddable component, the titles are
hidden by default due to to a regression introduced in
#186642.
This PR should fix the correct title handling of the header visibility
by hiding or showing the wrapping Panel title depending on the
`hidePanelTitles` props of the `LensRenderer` component


fix #203354
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 10, 2024
## Summary

When using the new Custom Lens embeddable component, the titles are
hidden by default due to to a regression introduced in
elastic#186642.
This PR should fix the correct title handling of the header visibility
by hiding or showing the wrapping Panel title depending on the
`hidePanelTitles` props of the `LensRenderer` component

fix elastic#203354

(cherry picked from commit 6e57a23)
kibanamachine added a commit that referenced this pull request Dec 10, 2024
# Backport

This will backport the following commits from `main` to `8.x`:
- [[Lens] Fix missing embeddable panel titles
(#203355)](#203355)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Marco
Vettorello","email":"marco.vettorello@elastic.co"},"sourceCommit":{"committedDate":"2024-12-10T15:39:15Z","message":"[Lens]
Fix missing embeddable panel titles (#203355)\n\n## Summary\r\n\r\nWhen
using the new Custom Lens embeddable component, the titles are\r\nhidden
by default due to to a regression introduced
in\r\nhttps://github.com//pull/186642.\r\nThis PR should
fix the correct title handling of the header visibility\r\nby hiding or
showing the wrapping Panel title depending on the\r\n`hidePanelTitles`
props of the `LensRenderer` component\r\n\r\n\r\nfix
https://github.com/elastic/kibana/issues/203354","sha":"6e57a23d18d949e7ac3118c1f27550e2ba9eedf8","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","Team:Visualizations","release_note:skip","Feature:Lens","v9.0.0","backport:prev-minor","Feature:Embeddables"],"title":"[Lens]
Fix missing embeddable panel
titles","number":203355,"url":"https://github.com/elastic/kibana/pull/203355","mergeCommit":{"message":"[Lens]
Fix missing embeddable panel titles (#203355)\n\n## Summary\r\n\r\nWhen
using the new Custom Lens embeddable component, the titles are\r\nhidden
by default due to to a regression introduced
in\r\nhttps://github.com//pull/186642.\r\nThis PR should
fix the correct title handling of the header visibility\r\nby hiding or
showing the wrapping Panel title depending on the\r\n`hidePanelTitles`
props of the `LensRenderer` component\r\n\r\n\r\nfix
https://github.com/elastic/kibana/issues/203354","sha":"6e57a23d18d949e7ac3118c1f27550e2ba9eedf8"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203355","number":203355,"mergeCommit":{"message":"[Lens]
Fix missing embeddable panel titles (#203355)\n\n## Summary\r\n\r\nWhen
using the new Custom Lens embeddable component, the titles are\r\nhidden
by default due to to a regression introduced
in\r\nhttps://github.com//pull/186642.\r\nThis PR should
fix the correct title handling of the header visibility\r\nby hiding or
showing the wrapping Panel title depending on the\r\n`hidePanelTitles`
props of the `LensRenderer` component\r\n\r\n\r\nfix
https://github.com/elastic/kibana/issues/203354","sha":"6e57a23d18d949e7ac3118c1f27550e2ba9eedf8"}}]}]
BACKPORT-->

Co-authored-by: Marco Vettorello <marco.vettorello@elastic.co>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
## Summary

This PR contains the refactor of the Lens embeddable with the new React
architecture.

fix elastic#174957
fixes elastic#180672

**Current status**:
✅ Ready to review

### Notes for testing and reviewers

Other than reworking the Lens embeddable with the new architecture this
PR contains the following major changes.

#### Edit flow
The `Edit` flow has changed to in-line first using the new `Edit` API
provided by the new system
* The impact of this change can be noticed in the code on the `Canvas`
case where the Custom Lens component is instructed to avoid the inline
editing. In all the other cases in-line editing is enabled by default
now.
* Another side effect of this has been the replacement of the special
`INLINE_EDIT` action id into the regular `EDIT` action. Some tests have
been affected by this replacing the `clickEdit` function with the
`openEditorFromFlyout` one.
* The Inline editing codebase **as been reworked entirely** so make sure
to stress test this side of things.

#### Attribute service

Another important aspect changed in this PR is the `attributeService`:
this was tied to the previous Embeddable system and it is now completely
skipped. The Lens wrapper around that has been reworked to be thinner
and directly call the CM services.
* Please make sure to test thoroughly save/load SO flows

#### Transformation API (by-value <=> by-reference flow)

The new system adopts the new Transformation API (who prevents the panel
to fully reload on change).
* Please make sure to test thoroughly Visualize library <=> by value
flows
* In particular moving from one type and another should change how the
Panel Settings interpret "default" values to reset

#### Message system

Also this part of the code was partially rewritten to be more manageable
ont he embeddable surface, maintaining the core functionalities.
* Please make sure to test thoroughly error messages, warnings and info
messages
  * Some scenarios to test includes
* multi-layer errors (i.e. use a broken KQL query for an
annotation/multi-layers). Check that the panel recovers correctly from
it when resolved
    * Missing references
    * Missing dataViews
    * Wrong formatted SO
* Configuration mistakes - check that a broken config is not saveable

### Other areas to check

* Change filters in dashboard/viz and check that are correctly handled
* Check drilldowns
* Check that `Unsaved changes` are correctly detected
* Check that the panel updates correctly on `View` mode change

## Main type changes

This PR contains also some important `type` changes, here's listed:
* the `query` property now explicitly supports ES|QL query type.
  * in `main` it used to work without type support
* `LensEmbeddableInput`/`LensEmbeddableOutput` types have changed, but
the type names remained the same.

## Follow ups already planned:

Some enhancements have been already collected and will be addressed in a
follow up [here](elastic#195355)

### Tasks
<details>

<summary>Detailed list of tasks for the refactor</summary>

* New embeddable factory
  * [x] Define visualization context
  * [x] Define observables to track
  * [x] Basic panel settings
  * [x] Basic edit api
  * [x] inspector api 
  * [x] Library services
  * [x] Unified search api
  * [x] Basic integrations api
  * [x] State management api for inline editing
  * Publish correct observables
    * [x] `dataViews`
    * [x] `query`
    * [x] `filters`
    * [x] `dataLoading`
    * [x] `savedObjectId`
  * Actions
    * [x] View underlying data api
 * Custom renderer
   * [x] Basic implementation
   * [x] Support callbacks
   * [x] Support custom styling/paddings
 * Expose  
* [x] Handle searchSession
* Edit
  * [x] Open panel in Lens editor
  * Inline editing
    * [x] rework references logic
      * elastic#180726
* integrate the logic to extract filters dataViews from filters as for
the first bug in elastic#188545
    * DSL flyout
      * [x] open flyout
      * [x] save
    * ES|QL
      * [x] open flyout on creation
      * [x] open flyout on editing
      * [x] save
* [x] revisit mounting logic to avoid detach if possible (not possible
yet)
* [x] explore the integration with the new `onEdit` api method used for
the inline editing~~
      * [x] created panel management module and sorted it out
    * [x] open in Editor
      * [x] fix the save on return to dashboard
* ~~migrate by ref to by value on inline editing~~ will do it in a
follow up PR
* Add from library issues
  * [x] Fix missing title and tags
* Data loading
  * [x] Compute all required data params for rendering
* Render the panel
  * [x] hook up user messaging system
  * [x] Merge search context
  * [x] Expression variables
  * [x] panel settings
    * [x] per panel time range
    * [x] per panel filter
    * test with both DSL and ES|QL mode
  * Reload
    * [x] on unified search updates
    * [x] on config changes
    * [x] on drilldown changes?
    * [x] on view mode change 
 * Attributes service
   * [x] load from library
   * [x] save to library

</details>


### Pending issues:
<details>

<summary>Detailed list of issues</summary>

* [x] Unified histogram does not render in Discover
* [x] Saving to library from context menu in dashboard doesn't save the
title
* [x] When adding a vis from the library the new panel has no title
* [x] Vis disappears when opening inline editor and cancel
  * Create a viz, save and return to dashboard, then edit it and cancel.
* Saving an edit inline doesn't apply the changes (i.e. changing the
chart type)
  * [x] Changing the chart type on the layer panel leads to a crash
* [x] Changing the chart type won't update the visualization (via both
config panel or suggestions)
* [x] Edit a dimension will stretch the panel to overflow the fly-out
* [x] duplicating a dimension in the inline editor by drag and drop
works buggy visually
* When duplicating a panel, the new panel gets the same title rather
than “title (copy)”
  * [x] by-value panels
  * [x] by-reference panels
* [x] brushing throughout the timerange doesn’t work
* [x] filtering when clicking on value doesn’t work
* [x] filtering from legend doesn’t work
* [x] for lens table, the sort ascending/descending actions don’t have
an effect
* [x] filtering doesn’t display on table either
* Discover related issues
* thanks to @davismcphee investigation the source of the issue seems to
be related to the way the `abortController` is managed in the new
embeddable implementation as Discover is relying on that.
* [x] needs to investigate for a fix that restores the previous
behaviour of the `abortController` management
  * [x] the hits total count is not in sync with the chart/table now
* [x] Change chart type via suggestion panel when inline editing in
Discover doesn't update the chart
* [x] Dirty panel issue (see @nickofthyme 's
[comment](elastic#186642 (comment))
)
* [x] `Unsaved changes` issue (see @mbondyra
[comment](elastic#186642 (comment)))
* [x] Multiple errors not rendered correctly in panel when blocking
(i.e. missing field - `lens-message-list-trigger` related)
  * [x] recover from a blocker error required 2 renders
* Missing SO error should not be handled for the custom render component
(legacy behaviour) but should be correctly handled for dashboard (will
be handled in a follow up PR given that is broken on `main` too)
* [x] Too many requests on Unified Histogram when in Discover (3 vs 2)
* [x] Too many request on slow queries for Unified Histogram (2 vs 1)
* [x] Annotations preview issues (chart rendering with height `0px`)
* [x] `uuid` not propagated correctly
* [x] another flavour of this was `id` not propagated correctly into the
`data-test-embeddable-id` attribute
* [x] Dispatch correctly the `render` events
* [x] refresh interval does not propagate thru the Lens custom component
in Discover (thanks to @jughosta to sort this out )
</details>

---------

Co-authored-by: Marta Bondyra <4283304+mbondyra@users.noreply.github.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Marco Vettorello <vettorello.marco@gmail.com>
Co-authored-by: Marta Bondyra <marta.bondyra@elastic.co>
Co-authored-by: Bhavya RM <bhavya@elastic.co>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
## Summary

When using the new Custom Lens embeddable component, the titles are
hidden by default due to to a regression introduced in
elastic#186642.
This PR should fix the correct title handling of the header visibility
by hiding or showing the wrapping Panel title depending on the
`hidePanelTitles` props of the `LensRenderer` component


fix elastic#203354
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels ci:project-deploy-observability Create an Observability project Feature:Embedding Embedding content via iFrame Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) Feature:Lens release_note:skip Skip the PR/issue when compiling release notes Team:Obs AI Assistant Observability AI Assistant Team:obs-ux-management Observability Management User Experience Team Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] rewrite app.test.tsx tests to testing library [Embeddables Rebuild] Migrate Lens