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
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