Skip to content
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

[Embeddables Rebuild] Fix sharing unchanged panels #184873

Conversation

ThomThomson
Copy link
Contributor

Summary

Fixes #184870

Fixes a regression introduced in #184264 where if there were any unsaved changes to a react embeddable, any panels without unsaved changes would be missing.

// this dashboard has unsaved panels.
const allUnsavedPanelsMap = {
...latestPanels,
...(unsavedDashboardState?.panels ?? {}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you spreading unsavedDashboardState?.panels? How would unsavedDashboardState?.panels be different from panelModifications?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty messy right now. Likely we can clean this up majorly once the legacy embeddable system is removed.

  • latestPanels is the latest panels directly from input.
  • unsavedDashboardState?.panels is the full panels listing if there are any unsaved changes to panels. This is from the legacy system.
  • panelModifications is a map of all react embeddables with unsaved changes, where each key has been modified.

We can determine if there are any unsaved panels at all by checking if panelModifications is populated or if unsavedDashboardState.panels is populated.

Then if either is populated we return the complete panels. When spreading, we can probably omit unsavedDashboardState?.panels - not because it's covered in panelModifications, but because it would be covered by latestPanels.

Let me test this.

In the future, when the old system is removed we will serialize panelModifications here directly because that will contain everything. Then on load time we can zip those with the panels loaded from the saved object rather than replacing them wholesale.

Copy link
Contributor Author

@ThomThomson ThomThomson Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update, yes I could technically remove this, just had to update a test to better match the actual behaviour. Done in a323be8

: {};

// this dashboard has unsaved panels.
const allUnsavedPanelsMap = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should allUnsavedPanelsMap be renamed since it contains saved and unsaved panel state?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can rename it sure. The reason it's still called unsaved is because it's only populated when there are some unsaved changes to panels. Otherwise it's undefined. I.e. fall back to the panels from the SO.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a rename is not needed - just a comment explaining what this is and why/when its used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 56049f4

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
code review, tested in chrome

@ThomThomson ThomThomson added Feature:Dashboard Dashboard related features Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas loe:small Small Level of Effort Feature:SharingURLs Short URLs and Share URL features impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. project:embeddableRebuild release_note:skip Skip the PR/issue when compiling release notes labels Jun 7, 2024
@ThomThomson ThomThomson marked this pull request as ready for review June 7, 2024 14:47
@ThomThomson ThomThomson requested a review from a team as a code owner June 7, 2024 14:47
@elasticmachine
Copy link
Contributor

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

@ThomThomson
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
dashboard 496.3KB 496.4KB +64.0B

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@ThomThomson ThomThomson merged commit f87eccf into elastic:main Jun 7, 2024
19 checks passed
@kibanamachine kibanamachine added v8.15.0 backport:skip This commit does not require backporting labels Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Dashboard Dashboard related features Feature:SharingURLs Short URLs and Share URL features impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:small Small Level of Effort project:embeddableRebuild release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.15.0
Projects
None yet
5 participants