-
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
[dashboard] Do not reset panel to undefined or empty last saved state #203158
Changes from 5 commits
f5b6dd5
447baea
1114069
92ae80d
1ddd161
e685af6
770e424
b3c5603
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,7 @@ import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; | |
import { LocatorPublic } from '@kbn/share-plugin/common'; | ||
import { ExitFullScreenButtonKibanaProvider } from '@kbn/shared-ux-button-exit-full-screen'; | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { DASHBOARD_CONTAINER_TYPE, DashboardApi, DashboardLocatorParams } from '../..'; | ||
import type { DashboardAttributes } from '../../../server/content_management'; | ||
import { DashboardContainerInput, DashboardPanelMap, DashboardPanelState } from '../../../common'; | ||
|
@@ -957,7 +958,16 @@ export class DashboardContainer | |
for (const panelId of Object.keys(currentChildren)) { | ||
if (this.getInput().panels[panelId]) { | ||
const child = currentChildren[panelId]; | ||
if (apiPublishesUnsavedChanges(child)) child.resetUnsavedChanges(); | ||
if (apiPublishesUnsavedChanges(child)) { | ||
const success = child.resetUnsavedChanges(); | ||
if (!success) { | ||
coreServices.notifications.toasts.addWarning( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great to have a warning in this case. I wonder if we should clarify that the user needs to start a new session (open a new tab etc) to get their last saved state back? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not want to complicate the error message. Its complex because if its a by-ref panel then a new session will not revert the changes because the by-ref saved object has already been saved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yet another example of why we need to fix this architecturally, as ++ to not complicating the error message. Ideally this isn't seen by users at all. |
||
i18n.translate('dashboard.reset.panelError', { | ||
defaultMessage: 'Unable to reset panel changes', | ||
}) | ||
); | ||
} | ||
} | ||
} else { | ||
// if reset resulted in panel removal, we need to update the list of children | ||
delete currentChildren[panelId]; | ||
|
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.
Do you think we should remove this typing after the architectural fix is in? I think this should be temporary because in theory, the
reset
function shouldn't be capable of failing.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.
agreed. This typing fix is only temporary.