[dashboard as code] embeddable transforms registry#227141
[dashboard as code] embeddable transforms registry#227141nreese merged 27 commits intoelastic:mainfrom
Conversation
|
@elasticmachine merge upstream |
|
/ci |
|
/ci |
|
/ci |
|
Pinging @elastic/kibana-presentation (Team:Presentation) |
|
@elasticmachine merge upstream |
nickpeihl
left a comment
There was a problem hiding this comment.
lgtm! Code review and tested book embeddable example.
I did add a few questions, but nothing blocking. I can't wait to start adding transforms in our other embeddables!
| developerExamples: DeveloperExamplesSetup; | ||
| embeddable: EmbeddableSetup; | ||
| uiActions: UiActionsStart; | ||
| uiActions: UiActionsSetup; |
There was a problem hiding this comment.
It doesn't look like we even use the UIActionsSetup dependency. I wonder if we can get rid of it?
...m/plugins/shared/dashboard/server/content_management/v1/transforms/in/transform_panels_in.ts
Show resolved
Hide resolved
...plugins/shared/dashboard/server/content_management/v1/transforms/out/transform_panels_out.ts
Show resolved
Hide resolved
|
@elasticmachine merge upstream |
ThomThomson
left a comment
There was a problem hiding this comment.
Took a cursory review of this as well, ran locally and messed around with the book example, also looked through the code. Left a couple tiny nits and a few other comments, but nothing blocking at all. Nice work! Will be great to get this merged!
| export type BookEmbeddableState = SerializedTitles & (BookState | BookByReferenceState); | ||
|
|
||
| // Shape of stored state <=9.1 | ||
| export type BookEmbeddableState910 = SerializedTitles & |
There was a problem hiding this comment.
Where is this type used? Can we have all BWC related code and types isolated in a BWC file or folder?
There was a problem hiding this comment.
BookEmbeddableState910 is used to type transformOut storedState parameter as storedState: BookEmbeddableState | BookEmbeddableState910.
There was a problem hiding this comment.
Can we have all BWC related code and types isolated in a BWC file or folder?
I am not sure that is possible since transformOut receives current state and legacy state. Handling of both types occurs in the same method.
examples/embeddable_examples/public/react_embeddables/saved_book/default_book_state.ts
Show resolved
Hide resolved
...ples/embeddable_examples/public/react_embeddables/saved_book/saved_book_react_embeddable.tsx
Show resolved
Hide resolved
examples/embeddable_examples/server/book/content_management/book_storage.ts
Show resolved
Hide resolved
...rm/plugins/shared/dashboard/public/dashboard_api/load_dashboard_api/transform_panels.test.ts
Show resolved
Hide resolved
ad5b8f0 to
c20199f
Compare
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
|
Closes elastic#222472 Closes elastic#222466 ### Problem Dashboard CRUD request and response shapes are overly complex because 1) panel state contains extracted references 2) by-value panel state often mirrors embeddable saved object state, which usually contains stringified JSON. For example, a by-value maps panel state contains `layerListJSON` instead of exposing just `layerList`. To simplify dashboard CRUD request and response shapes, embeddables need a mechanism to 1) inject references in dashboard CRUD read APIs 2) transform by-value embeddable state to a more consumable shape in dashboard CRUD read APIs 2) extract references in dashbaord CRUD write APIs The embeddable transforms registry is the solution to these problems and allows embeddables to transform embeddable state that is part of dashboard CRUD APIs. ### Changes to Embeddable plugin Adds transforms registry to embeddable server and start plugin, allowing embeddable implementations to register transforms. ### Changes to Dashboard plugin Updates dashboard CRUD write APIs to use `transformIn` function to extract references. The below image shows the create request body. The dashboard contains a single by-reference book embeddable. Notice how the savedObjectId has not been extracted to a reference. <img height="300" alt="Screenshot 2025-07-10 at 11 28 47 AM" src="https://github.com/user-attachments/assets/f950006e-50bf-44ea-8b9c-77a2123a6713" /> The below image shows the saved object for the dashboard above. Notice how the persisted state has saved object reference extracted. Panel `embeddableConfig` no longer contains `savedObjectId` key and references contains `savedObjectRef`. <img height="400" alt="Screenshot 2025-07-10 at 11 30 41 AM" src="https://github.com/user-attachments/assets/eb7e9921-b02b-4029-b43d-e6c77f7d65b3" /> Updates dashboard CRUD read APIs to use `transformOut` function to inject references and transform stored embeddable state to a more consumable shape. Dashboards loaded from stored URL state also use `transformOut` for the same purpose. ### Changes to embeddable_examples Implements book saved object <img height="300" alt="Screenshot 2025-07-10 at 11 09 33 AM" src="https://github.com/user-attachments/assets/b1785512-4dd3-40bf-b848-6d88b85e3eb2" /> Implements book content management CRUD API <img height="195" alt="Screenshot 2025-07-10 at 11 08 51 AM" src="https://github.com/user-attachments/assets/378aab47-b2bd-4541-85df-b108a44c8da7" /> Updates book embeddable to use book CRUD API --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Closes elastic#222472 Closes elastic#222466 ### Problem Dashboard CRUD request and response shapes are overly complex because 1) panel state contains extracted references 2) by-value panel state often mirrors embeddable saved object state, which usually contains stringified JSON. For example, a by-value maps panel state contains `layerListJSON` instead of exposing just `layerList`. To simplify dashboard CRUD request and response shapes, embeddables need a mechanism to 1) inject references in dashboard CRUD read APIs 2) transform by-value embeddable state to a more consumable shape in dashboard CRUD read APIs 2) extract references in dashbaord CRUD write APIs The embeddable transforms registry is the solution to these problems and allows embeddables to transform embeddable state that is part of dashboard CRUD APIs. ### Changes to Embeddable plugin Adds transforms registry to embeddable server and start plugin, allowing embeddable implementations to register transforms. ### Changes to Dashboard plugin Updates dashboard CRUD write APIs to use `transformIn` function to extract references. The below image shows the create request body. The dashboard contains a single by-reference book embeddable. Notice how the savedObjectId has not been extracted to a reference. <img height="300" alt="Screenshot 2025-07-10 at 11 28 47 AM" src="https://github.com/user-attachments/assets/f950006e-50bf-44ea-8b9c-77a2123a6713" /> The below image shows the saved object for the dashboard above. Notice how the persisted state has saved object reference extracted. Panel `embeddableConfig` no longer contains `savedObjectId` key and references contains `savedObjectRef`. <img height="400" alt="Screenshot 2025-07-10 at 11 30 41 AM" src="https://github.com/user-attachments/assets/eb7e9921-b02b-4029-b43d-e6c77f7d65b3" /> Updates dashboard CRUD read APIs to use `transformOut` function to inject references and transform stored embeddable state to a more consumable shape. Dashboards loaded from stored URL state also use `transformOut` for the same purpose. ### Changes to embeddable_examples Implements book saved object <img height="300" alt="Screenshot 2025-07-10 at 11 09 33 AM" src="https://github.com/user-attachments/assets/b1785512-4dd3-40bf-b848-6d88b85e3eb2" /> Implements book content management CRUD API <img height="195" alt="Screenshot 2025-07-10 at 11 08 51 AM" src="https://github.com/user-attachments/assets/378aab47-b2bd-4541-85df-b108a44c8da7" /> Updates book embeddable to use book CRUD API --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Closes #222472
Closes #222466
Problem
Dashboard CRUD request and response shapes are overly complex because
layerListJSONinstead of exposing justlayerList.To simplify dashboard CRUD request and response shapes, embeddables need a mechanism to
The embeddable transforms registry is the solution to these problems and allows embeddables to transform embeddable state that is part of dashboard CRUD APIs.
Changes to Embeddable plugin
Adds transforms registry to embeddable server and public plugins, allowing embeddable implementations to register transforms.
Changes to Dashboard plugin
Updates dashboard CRUD write APIs to use
transformInfunction to extract references.The below image shows the create request body. The dashboard contains a single by-reference book embeddable. Notice how the savedObjectId has not been extracted to a reference.

The below image shows the saved object for the dashboard above. Notice how the persisted state has saved object reference extracted. Panel

embeddableConfigno longer containssavedObjectIdkey and references containssavedObjectRef.Updates dashboard CRUD read APIs to use
transformOutfunction to inject references and transform stored embeddable state to a more consumable shape. Dashboards loaded from stored URL state also usetransformOutfor the same purpose.Changes to embeddable_examples
Implements book saved object

Implements book content management CRUD API

Updates book embeddable to use book CRUD API