-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fixes #71461 regression since 7.7 New state syncing utils didn't properly handle errors, Errors happening during URL parsing or writing wasn't handled, so state syncing could stop or in worth case blow out. (see #71461) There are not much scenarios where missing proper error handling could really impact users, except the one described in #71461: Kibana users state:storeInSessionStorage Users often intuitively share hashed dashboard urls directly When someone opens those urls - there is a blank screen with warning In 7.6 - dashboard would still load with default state. Since 7.7 these still could be achieved by removing query params for URL, but it is not obvious for regular users. This PR makes sure that behaviour is similar to one we had before 7.7. Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
fa2bf9b
commit e0efd61
Showing
24 changed files
with
355 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Error handling | ||
|
||
State syncing util doesn't have specific api for handling errors. | ||
It expects that errors are handled on storage level. | ||
|
||
see [KbnUrlStateStorage](./storages/kbn_url_storage.md#) error handling section for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/plugins/kibana_utils/public/state_management/url/errors.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { NotificationsStart } from 'kibana/public'; | ||
|
||
export const restoreUrlErrorTitle = i18n.translate( | ||
'kibana_utils.stateManagement.url.restoreUrlErrorTitle', | ||
{ | ||
defaultMessage: `Error restoring state from URL`, | ||
} | ||
); | ||
|
||
export const saveStateInUrlErrorTitle = i18n.translate( | ||
'kibana_utils.stateManagement.url.saveStateInUrlErrorTitle', | ||
{ | ||
defaultMessage: `Error saving state in URL`, | ||
} | ||
); | ||
|
||
/** | ||
* Helper for configuring {@link IKbnUrlStateStorage} to notify about inner errors | ||
* | ||
* @example | ||
* ```ts | ||
* const kbnUrlStateStorage = createKbnUrlStateStorage({ | ||
* history, | ||
* ...withNotifyOnErrors(core.notifications.toast)) | ||
* } | ||
* ``` | ||
* @param toast - toastApi from core.notifications.toasts | ||
*/ | ||
export const withNotifyOnErrors = (toasts: NotificationsStart['toasts']) => { | ||
return { | ||
onGetError: (error: Error) => { | ||
toasts.addError(error, { | ||
title: restoreUrlErrorTitle, | ||
}); | ||
}, | ||
onSetError: (error: Error) => { | ||
toasts.addError(error, { | ||
title: saveStateInUrlErrorTitle, | ||
}); | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.