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

[lens] fix unhandled promise rejection when saving Lens with duplicate title #82195

Merged
merged 6 commits into from
Nov 2, 2020

Conversation

nreese
Copy link
Contributor

@nreese nreese commented Oct 30, 2020

fixes #82173

PR adds try/catch around checkForDuplicateTitle to handle rejection when there is a duplicate title

@nreese nreese added chore Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.11.0 labels Oct 30, 2020
@nreese nreese requested review from ThomThomson and a team October 30, 2020 20:17
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@@ -359,7 +359,6 @@ export function App({
const docToSave = {
...getLastKnownDocWithoutPinnedFilters()!,
description: saveProps.newDescription,
savedObjectId: saveProps.newCopyOnSave ? undefined : lastKnownDoc.savedObjectId,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed savedObjectId from docToSave because it is not used and made tracking down how attributeService.wrapAttributes pulls out the savedObjectId extra tricky

@@ -453,11 +457,6 @@ export function App({
// eslint-disable-next-line no-console
console.dir(e);
trackUiEvent('save_failed');
notifications.toasts.addDanger(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove toast notification on save failure. Toast is already displayed by AttributeService.wrapAttributes

@@ -375,25 +374,31 @@ export function App({

const originalInput = saveProps.newCopyOnSave ? undefined : initialInput;
const originalSavedObjectId = (originalInput as LensByReferenceInput)?.savedObjectId;
if (options.saveToLibrary && !originalInput) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed && !originalInput because this actually caused a title naming conflict without warning users.

Steps to view:

  1. create and save a lens saved object called "alpha"
  2. create and save another lens saved object called "bravo"
  3. edit the first lens saved object. Click save and change the title to "bravo". Click save. The modal should notify user about duplicate title but it does not.

Copy link
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

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

Tested locally on chrome - duplicate title warning is issued correctly when the 'save as new' is on and when it's off.

No error is thrown. Code LGTM too!

@flash1293
Copy link
Contributor

@elasticmachine merge upstream

@nreese nreese requested a review from flash1293 November 2, 2020 14:51
Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

I tested this in Chrome and I couldn't find any broken behavior.

@nreese
Copy link
Contributor Author

nreese commented Nov 2, 2020

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

async chunks size

id before after diff
lens 1.0MB 1024.0KB -103.0B

History

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

@nreese nreese merged commit 97a32fd into elastic:master Nov 2, 2020
nreese added a commit to nreese/kibana that referenced this pull request Nov 2, 2020
…e title (elastic#82195)

* [lens] fix unhandled promise rejection when saving Lens with duplicate title

* more clean up

* restore getDisplayName, used by return of checkForDuplicateTitle

* fix jest test

Co-authored-by: Kibana Machine <[email protected]>
nreese added a commit that referenced this pull request Nov 2, 2020
…e title (#82195) (#82342)

* [lens] fix unhandled promise rejection when saving Lens with duplicate title

* more clean up

* restore getDisplayName, used by return of checkForDuplicateTitle

* fix jest test

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[lens] unhandled promise rejection when saving Lens with duplicate title
5 participants