-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Embeddables Rebuild] Fix sharing unchanged panels #184873
Conversation
// this dashboard has unsaved panels. | ||
const allUnsavedPanelsMap = { | ||
...latestPanels, | ||
...(unsavedDashboardState?.panels ?? {}), |
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.
Why are you spreading unsavedDashboardState?.panels
? How would unsavedDashboardState?.panels
be different from panelModifications
?
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 pretty messy right now. Likely we can clean this up majorly once the legacy embeddable system is removed.
latestPanels
is the latest panels directly frominput
.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.
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.
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 = { |
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.
Should allUnsavedPanelsMap
be renamed since it contains saved and unsaved panel state?
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 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.
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.
Maybe a rename is not needed - just a comment explaining what this is and why/when its used
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.
done in 56049f4
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.
LGTM
code review, tested in chrome
Pinging @elastic/kibana-presentation (Team:Presentation) |
@elasticmachine merge upstream |
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Async chunks
To update your PR or re-run it, just comment with: |
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.