diff --git a/x-pack/plugins/lens/public/app_plugin/app.test.tsx b/x-pack/plugins/lens/public/app_plugin/app.test.tsx index edee2bf8e6b1d..c8c0f6d322118 100644 --- a/x-pack/plugins/lens/public/app_plugin/app.test.tsx +++ b/x-pack/plugins/lens/public/app_plugin/app.test.tsx @@ -722,15 +722,14 @@ describe('Lens App', () => { }); expect(services.attributeService.wrapAttributes).toHaveBeenCalledWith( expect.objectContaining({ - savedObjectId: undefined, title: 'hello there', }), true, undefined ); - expect(props.redirectTo).toHaveBeenCalledWith('aaa'); + expect(props.redirectTo).toHaveBeenCalledWith(defaultSavedObjectId); await act(async () => { - component.setProps({ initialInput: { savedObjectId: 'aaa' } }); + component.setProps({ initialInput: { savedObjectId: defaultSavedObjectId } }); }); expect(services.attributeService.wrapAttributes).toHaveBeenCalledTimes(1); expect(services.notifications.toasts.addSuccess).toHaveBeenCalledWith( @@ -781,7 +780,6 @@ describe('Lens App', () => { await act(async () => { testSave(component, { newCopyOnSave: false, newTitle: 'hello there' }); }); - expect(services.notifications.toasts.addDanger).toHaveBeenCalled(); expect(props.redirectTo).not.toHaveBeenCalled(); expect(getButton(component).disableButton).toEqual(false); }); @@ -857,6 +855,7 @@ describe('Lens App', () => { ); component.update(); await act(async () => { + component.setProps({ initialInput: { savedObjectId: '123' } }); getButton(component).run(component.getDOMNode()); }); component.update(); @@ -871,7 +870,7 @@ describe('Lens App', () => { }); }); expect(checkForDuplicateTitle).toHaveBeenCalledWith( - expect.objectContaining({ savedObjectId: '123' }), + expect.objectContaining({ id: '123' }), false, onTitleDuplicate, expect.anything() diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx index 2d35c203661d0..366a27a8a9a05 100644 --- a/x-pack/plugins/lens/public/app_plugin/app.tsx +++ b/x-pack/plugins/lens/public/app_plugin/app.tsx @@ -359,7 +359,6 @@ export function App({ const docToSave = { ...getLastKnownDocWithoutPinnedFilters()!, description: saveProps.newDescription, - savedObjectId: saveProps.newCopyOnSave ? undefined : lastKnownDoc.savedObjectId, title: saveProps.newTitle, }; @@ -375,25 +374,31 @@ export function App({ const originalInput = saveProps.newCopyOnSave ? undefined : initialInput; const originalSavedObjectId = (originalInput as LensByReferenceInput)?.savedObjectId; - if (options.saveToLibrary && !originalInput) { - await checkForDuplicateTitle( - { - ...docToSave, - copyOnSave: saveProps.newCopyOnSave, - lastSavedTitle: lastKnownDoc.title, - getEsType: () => 'lens', - getDisplayName: () => - i18n.translate('xpack.lens.app.saveModalType', { - defaultMessage: 'Lens visualization', - }), - }, - saveProps.isTitleDuplicateConfirmed, - saveProps.onTitleDuplicate, - { - savedObjectsClient, - overlays, - } - ); + if (options.saveToLibrary) { + try { + await checkForDuplicateTitle( + { + id: originalSavedObjectId, + title: docToSave.title, + copyOnSave: saveProps.newCopyOnSave, + lastSavedTitle: lastKnownDoc.title, + getEsType: () => 'lens', + getDisplayName: () => + i18n.translate('xpack.lens.app.saveModalType', { + defaultMessage: 'Lens visualization', + }), + }, + saveProps.isTitleDuplicateConfirmed, + saveProps.onTitleDuplicate, + { + savedObjectsClient, + overlays, + } + ); + } catch (e) { + // ignore duplicate title failure, user notified in save modal + return; + } } try { const newInput = (await attributeService.wrapAttributes( @@ -453,11 +458,6 @@ export function App({ // eslint-disable-next-line no-console console.dir(e); trackUiEvent('save_failed'); - notifications.toasts.addDanger( - i18n.translate('xpack.lens.app.docSavingError', { - defaultMessage: 'Error saving document', - }) - ); setState((s) => ({ ...s, isSaveModalVisible: false })); } }; diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 7386903c311d2..c20fdaa10e8de 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -10692,7 +10692,6 @@ "xpack.lens.app.cancel": "キャンセル", "xpack.lens.app.cancelButtonAriaLabel": "変更を保存せずに最後に使用していたアプリに戻る", "xpack.lens.app.docLoadingError": "保存されたドキュメントの保存中にエラーが発生", - "xpack.lens.app.docSavingError": "ドキュメントの保存中にエラーが発生", "xpack.lens.app.indexPatternLoadingError": "インデックスパターンの読み込み中にエラーが発生", "xpack.lens.app.save": "保存", "xpack.lens.app.saveAndReturn": "保存して戻る", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 3dfa1cbbca434..e6c568462dc84 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -10705,7 +10705,6 @@ "xpack.lens.app.cancel": "取消", "xpack.lens.app.cancelButtonAriaLabel": "返回到上一个应用而不保存更改", "xpack.lens.app.docLoadingError": "加载已保存文档时出错", - "xpack.lens.app.docSavingError": "保存文档时出错", "xpack.lens.app.indexPatternLoadingError": "加载索引模式时出错", "xpack.lens.app.save": "保存", "xpack.lens.app.saveAndReturn": "保存并返回",