-
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
[Time to Visualize] Lens By Value With AttributeService #77561
[Time to Visualize] Lens By Value With AttributeService #77561
Conversation
…o avoid confusion. Added cancel button
…d to determine if newly created or editing
I tested this in Chrome on Mac OS, looks great! I tested the following scenarios:
All above scenarios work as expected. However, I found this breaks saving "regular visualizations" to library.
(I don't have a duplicate title for this visualization) |
...vis.serialize(), | ||
id: embeddableId ? embeddableId : uuid.v4(), | ||
}, | ||
savedVis: vis.serialize(), |
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.
savedVis
won't exist in by-value mode. Why this change?
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.
I don't know the visualize embeddable too well, but all the changes in this file were required to make visualize work with the new stateTransfer types. I added a unified EmbeddablePackageState
with an input
key which means that dashboard doesn't have to worry at all about 'by reference' vs 'by value' when adding an embeddable.
So it seems like this change here is done for the by reference case.
@majagrubic, good find with the issue relating to |
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.
I tested different scenarios. Looks good 🔥
Noticed couple edge case:
- Seems like saving lens by value with filters doesn't always work. I think it is related to this issue: cleanup filters meta types and usage #77588
This is the error:
I see you have a "list of issues" to solve before releasing this? I guess this could just be another one.
-
Story around browser navigation and history: I guess it isn't necessary to improve this in scope of this pr, but worth creating an issue? Basically I'd except the behavior to be as consistent with visualize / lens by saved object as possible. Some quirks:
2.1.Back
on a dashboard just after navigating from editor first removes just added panel. 2ndBack
gets back to Lens. (this actually happen for all visualisations., not only by value Lens, I guess this isn't a regression..🤔). Wonder if it is a quick fix on a dashboard side.
2.2.Back
on a dashboard to editor: works fine for saved visualisations, but in case of "by value", we don't get navigated to the latest state. I wonder if this could be fixed by "replaceState" somewhere insidetransferStateService
2.3 Dashboard -> Edit Lens -> Back -> Forward ---> we don't have "return and save to dashboard" button anymore. (this seems minor and an edge case)
2.4. When your try to reload the Lens page it normally notifies if there are unsaved changes. Seems like it shows an alert if there are any edits. This is fine in case of saved visualisation. But in scenario when you've just navigated to /edit_by_value and do the page reload without any changes, the page reloads and Lens gets into "empty" state. I think in case of edit_by_value unsaved_changed dialog should always be triggered. -
I was really confused by the following scenario: Dashboard -> edit by value lens -> Save As: Now there is an
Add to Dashboard after saving
switch.
3.1 If it isON
It is not clear if it would add a new panel on a dashboard or if it would change an existing one. Technically this vis is already on a dashboard, so it probably should be labeled asUpdate panel on a dashboard
3.2 If it isOFF
it is not clear if changes would be saved to the panel on a dashboard.
Maybe it would be simpler to remove this flow completely: when you EDIT by value vis which is already on a dashboard, then the only option you have is to "SAVE & RETURN" ? Otherwise some work has to be done to make UX about this clearer.
x-pack/plugins/lens/public/editor_frame_service/embeddable/embeddable.tsx
Outdated
Show resolved
Hide resolved
if (!this.savedVis) { | ||
return; | ||
} | ||
const promises = this.savedVis.references |
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.
nit: technically this promises
array could contain null
. To avoid this, I'd filter null
in the end of this chain instead of filtering after Promise.all
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.
I only moved this piece of code from embeddable_factory
into embeddable
, but it does make more sense to filter out the nulls here instead of after the Promise.all
, so I've made that change
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.
have some questions but mostly the code looks good to me
src/plugins/dashboard/public/application/actions/library_notification_action.tsx
Show resolved
Hide resolved
src/plugins/dashboard/public/attribute_service/attribute_service.tsx
Outdated
Show resolved
Hide resolved
…yValueAttributeServiceOnly
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.
code LGTM
Responding to @Dosant's comments
|
Checked this out and came to following recommendations:
I think of this 'Add to library' UX in terms of: |
Thanks for the help @ryankeairns, I've changed the copy to match the suggestions! This is definitely a UX improvement, and helps to fill in a use case I wasn't quite sure about before. Thanks for pointing this out @Dosant |
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.
I retested saving with filters scenario. Worked well.
Also label update in "Save as" scenario makes sense to me and makes it a lot clearer 👍
Thanks for looking into it.
…yValueAttributeServiceOnly
@elasticmachine merge upstream |
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
async chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
Used the attribute service to make lens work properly with by value embeddables.
This PR is a simpler version of #70272. To standardize the code, the lens editor has been changed to use the
attributeService
as an additional layer of abstraction above savedObjects for loading and saving.Summary
This PR is a part of the Time to Visualize initiative. It allows for Lens embeddables to be created and edited 'by value'. This results in less clicks to create, and edit visualizations, and avoids the slow 'think up a unique name, then search for it later to add the panel to a dashboard` process. In concert with #72256, and other visualize by value PRs a faster work flow for dashboards is created, and the number of savedObjects can be greatly reduced.
How should I review this?
This is just one part of a much larger change, so all changes in this PR are hidden behind a configuration value. In order for the 'by value' workflow to be made default, some architectural changes need to be completed including #67931, #71499, and #61663
Config
In order to test the new behaviour you'll need to set the
allowByValueEmbeddables
config value totrue
:kibana/src/plugins/dashboard/config.ts
Line 23 in 5b64a4c
New Functionality & Tests to Cover
edit_by_value
endpoint. Save and return should properly apply edits back to the dashboard.save as
withoutadd to dashboards on save
should redirect the editor to/edit/{savedObjectId}
save as
withadd to dashboards on save
should return to dashboard and replace the by value embeddable with a by reference embeddable. The embeddableId should be persisted.Fancy gifs
Creating a panel by value
Editing a panel by value
Using save as to transform a panel into 'by reference'
Convert a panel to 'by value' with the Unlink action
Convert a panel to 'by reference' with the Add to Library action
Checklist
Delete any items that are not applicable to this PR.
For maintainers