elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.76k stars 8.16k forks source link

[Embeddables Rebuild] Remove hardcoded savedObjectId reference from Dashboard #186561

Open ThomThomson opened 3 months ago

ThomThomson commented 3 months ago

Problem

The Dashboard is currently in charge of extracting and injecting references for any panel which could be by reference. It did this by creating a reference for each panel which had a savedObjectId as part of its embeddable config. Because the Dashboard takes care of this reference, the individual embeddable types do not manage this reference for themselves.

After https://github.com/elastic/kibana/pull/176455, React Embeddables (the new Embeddable framework) will be able to extract and inject their own references. If one had a savedObjectId as part of their state, the Dashboard would attempt to create a saved object reference from it, even if the React Embeddable had already created and returned one. This could result in duplication and undefined behaviour.

Additionally, if any panel has a link to a library item which isn't stored with the exact key savedObjectId, no reference would be created.

Fix?

To fix this, we should move the saved object reference injection and extraction logic into the inject and extract methods of each individual Embeddable type that can be by reference and remove all special reference creation logic from src/plugins/dashboard/common/dashboard_container/persistable_state/dashboard_container_references.ts

elasticmachine commented 3 months ago

Pinging @elastic/kibana-presentation (Team:Presentation)