-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
More saved object embeddable examples #61749
More saved object embeddable examples #61749
Conversation
Pinging @elastic/kibana-app-arch (Team:AppArch) |
35e4e40
to
436b58f
Compare
@stacey-gammon In the Time to Dashboard project we've referred to the action as 'Add to library', which raises a question for me: Are we creating a new object when we add to the library or is it the same object but now it is 'flagged' as being visible in the Viz library? |
If the embeddable is not already backed by a saved object, you'd be creating a new one when you click "Save to library". If you try to edit an embeddable that is already linked to a saved object, I had the button say "update library item". We can change that though. We could have an "unlink" functionality (just clears the saved object from the input but keeps the attributes). |
01031e1
to
f4ceac3
Compare
f4ceac3
to
fcd2ccf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very big to review. I like the concept of having a saved object embeddable separately.
Yea, it's a big review, it is built off of this smaller PR though: #61692 However that one hasn't any reviews yet so I may just close it and ask reviews for this one. Regarding your comment, you prefer the approach where there are two embeddable factories registered, one for "by value" one for "by ref"? This is the approach I took in the sample in #61692 but thought it actually might be easier for devs to only have to register one type of factory, hence this PR removes the example in that earlier PR and adds another example. Note that the |
Sorry, I didn't look at the PR carefully, and thought that two factories was the approach you were taking, as in the prototype. I thought that adding an optional I managed to create a new embeddable, both backed by a saved object and without it - works great 🎉 |
I believe saved objects types have to explicitly opt in to showing up in management. Management doesn't just show every new saved object type automatically. |
…re-embed-saved_object_examples
Note: would like to merge #61165 first since I'll have to resolve some conflicts afterward. |
…re-embed-saved_object_examples
💔 Build Failed
Failed CI Steps
History
To update your PR or re-run it, just comment with: |
I'm going to pull a bit of functionality out of this PR to make it smaller. Stay tuned. |
I'm going to get these two PRs merged first:
|
Changes pulled from #61692:
savedObjectIds
work in embeddable containers - they are no longer special, they are just another form ofinput
, and so will now be kept insidepanels[x].explicitInput
instead of onpanels[x]
directly.container.addNewEmbeddable
rather thancontainer.addSavedObjectEmbeddable
TODO:
factory.createFromSavedObject
function. Embeddable factories are meant to be nothing more than registeredcreateEmbeddable
functions. Input into factory is the input into the Embeddable.New examples:
savedObjectId
, as well as optional saved object attributes. You can think of these as editable fields of the saved object. If the savedObjectId is undefined, there must be enough data ininput
to still correctly render the Embeddable. It can be:This allows the user to:
The one caveat I discovered with this approach is how containers work. The container implementation works off
input.panels
. If we have a "by reference" dashboard, we don't want to also force the use to setinput.panels
, you should be able to simply instantiate with:I think this points to a code smell on the Containers that they should be an interface, not a base class, and for some of the complicated logic, we should just offer as helper functions. While it's not ideal, we should be able to move forward with this until the container class can be refactored. Alternatively we could probably go with a separate wrapped embeddable approach for containers, as explored in #61692.
Related: