[Dashboard] Fix explicitInput removal#215580
Conversation
|
/ci |
|
Pinging @elastic/kibana-presentation (Team:Presentation) |
|
@elasticmachine merge upstream |
| const getApiMissingFallback = (id: string): SerializedPanelState<object> => { | ||
| // If the Dashboard has been saved with this panel before, we should be able to grab it from the current value of panels$ | ||
| if (Object.keys(panels$.value[id].explicitInput ?? {}).length > 0) { | ||
| return { |
There was a problem hiding this comment.
If a panel is not new so explicitInput is populated but has unsaved changes - Shouldn't unsaved changes version of explicitInput be used?
There was a problem hiding this comment.
Yes I think you're right. We could confirm this by making a change to a panel, minimizing it with a collapsible section and then saving the Dashboard.
That change would be overwritten. It seems to me that we should only use the serializedPanelBackup here. I'll make that change.
| const serializeResult = apiHasSerializableState(childApi) | ||
| ? childApi.serializeState() | ||
| : { rawState: {} }; | ||
| : getDashboardBackupService().getSerializedPanelBackup(id, dashboardId) ?? { |
There was a problem hiding this comment.
I still think we need to fallback to panels$.value[id].explicitInput but check for getSerializedPanelBackup first.
const serializeResult = apiHasSerializableState(childApi)
? childApi.serializeState()
: getDashboardBackupService().getSerializedPanelBackup(id, dashboardId) ?? {
rawState: panels$.value[id].explicitInput ?? {},
references: getReferencesForPanelId(id)
};
Here is a use case. A dashboard is opened with a collapsable panel section that is closed on load and never opened. The dashboard title is changed and the dashboard is saved.
For embeddables in unopened collapsable section:
childApiwill not be provided because the embeddable was never renderedgetSerializedPanelBackupwill not be provided because the embeddable was never rendered and no unsaved changes where recorded. We can not count on the session state from when the panel was added because this dashboard may be opened on a different session.- fallback to
panels$.value[id].explicitInput
There was a problem hiding this comment.
Ugh. You're right again. Thanks Nathan. It's obvious I'm not using my whole brain power on this PR - the situation you describe was the one I had in mind when I made the first function.
This is another reason why this code needs to be removed ASAP. Implemented your suggestion in
d18d50e, thanks again!
nreese
left a comment
There was a problem hiding this comment.
LGTM. This is a good work around until the larger problem can be addressed.
|
@elasticmachine merge upstream |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
History
|
|
Starting backport for target branches: 8.16, 8.17, 8.18, 8.x, 9.0 https://github.com/elastic/kibana/actions/runs/14115648062 |
Temporarily adds a serializedStateBackup to Dashboard (cherry picked from commit 62f2daf)
💔 Some backports could not be createdNote: Successful backport PRs will be merged automatically after passing CI. Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
|
Starting backport for target branches: 9.0 https://github.com/elastic/kibana/actions/runs/14115827016 |
💔 Backport failedThe pull request could not be backported due to the following error: Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
|
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
|
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
Temporarily adds a serializedStateBackup to Dashboard
|
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
1 similar comment
|
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
# Backport This will backport the following commits from `main` to `8.x`: - [[Dashboard] Fix explicitInput removal (#215580)](#215580) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Devon Thomson","email":"devon.thomson@elastic.co"},"sourceCommit":{"committedDate":"2025-03-27T20:02:22Z","message":"[Dashboard] Fix explicitInput removal (#215580)\n\nTemporarily adds a serializedStateBackup to Dashboard","sha":"62f2daf32e07a8aace4648578641f9965436c424","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Presentation","loe:small","release_note:skip","impact:high","backport:prev-minor","backport:prev-major","v9.1.0"],"title":"[Dashboard] Fix explicitInput removal","number":215580,"url":"https://github.com/elastic/kibana/pull/215580","mergeCommit":{"message":"[Dashboard] Fix explicitInput removal (#215580)\n\nTemporarily adds a serializedStateBackup to Dashboard","sha":"62f2daf32e07a8aace4648578641f9965436c424"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/215580","number":215580,"mergeCommit":{"message":"[Dashboard] Fix explicitInput removal (#215580)\n\nTemporarily adds a serializedStateBackup to Dashboard","sha":"62f2daf32e07a8aace4648578641f9965436c424"}}]}] BACKPORT--> Co-authored-by: Devon Thomson <devon.thomson@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Summary
Temporary fix for #215429 to unblock #197716 before #215551 can be completed.
Warning
This fix works, but it introduces a duplication of information that should be immediately removed as soon as #215551 is solved.
Explanation
This PR fixes #215429 by making the Dashboard's serialize function fall back to whatever state was last saved to the Dashboard for that panel when a child API cannot be found.
Unfortunately, when attempting to serialize a newly added panel it's possible that the child API cannot be found and the panel hasn't been saved before. In this edge case the
explicitInputwould still be missing. Because of this, this PR adds another state backup which stores the result of serializing every panel with unsaved changes. This way in cases where the panel is new and the API is missing we're still able to serialize it.