From 97b117cae44a83e4b0f641cca4aacc6c68bbbe5d Mon Sep 17 00:00:00 2001 From: Kim Sang Ly Date: Thu, 15 Oct 2020 19:19:38 -0400 Subject: [PATCH 1/3] [Lens] Add toast notification when visualization is saved --- .../plugins/lens/public/app_plugin/app.test.tsx | 9 +++++++++ x-pack/plugins/lens/public/app_plugin/app.tsx | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) 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 e9e6bf43d9f1b..d079f98b7027a 100644 --- a/x-pack/plugins/lens/public/app_plugin/app.test.tsx +++ b/x-pack/plugins/lens/public/app_plugin/app.test.tsx @@ -695,6 +695,9 @@ describe('Lens App', () => { undefined ); expect(props.redirectTo).toHaveBeenCalledWith('aaa'); + expect(services.notifications.toasts.addSuccess).toHaveBeenCalledWith( + "Saved 'hello there'" + ); }); it('adds to the recently accessed list on save', async () => { @@ -729,6 +732,9 @@ describe('Lens App', () => { component.setProps({ initialInput: { savedObjectId: 'aaa' } }); }); expect(services.attributeService.wrapAttributes).toHaveBeenCalledTimes(1); + expect(services.notifications.toasts.addSuccess).toHaveBeenCalledWith( + "Saved 'hello there'" + ); }); it('saves existing docs', async () => { @@ -750,6 +756,9 @@ describe('Lens App', () => { component.setProps({ initialInput: { savedObjectId: defaultSavedObjectId } }); }); expect(services.attributeService.unwrapAttributes).toHaveBeenCalledTimes(1); + expect(services.notifications.toasts.addSuccess).toHaveBeenCalledWith( + "Saved 'hello there'" + ); }); it('handles save failure by showing a warning, but still allows another save', async () => { diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx index 3407ea5de49c4..590c020414cca 100644 --- a/x-pack/plugins/lens/public/app_plugin/app.tsx +++ b/x-pack/plugins/lens/public/app_plugin/app.tsx @@ -425,6 +425,14 @@ export function App({ isSaveModalVisible: false, isLinkedToOriginatingApp: false, })); + notifications.toasts.addSuccess( + i18n.translate('visualize.topNavMenu.saveVisualization.successNotificationText', { + defaultMessage: `Saved '{visTitle}'`, + values: { + visTitle: docToSave.title, + }, + }) + ); redirectTo(newInput.savedObjectId); return; } @@ -440,6 +448,14 @@ export function App({ isSaveModalVisible: false, isLinkedToOriginatingApp: false, })); + notifications.toasts.addSuccess( + i18n.translate('visualize.topNavMenu.saveVisualization.successNotificationText', { + defaultMessage: `Saved '{visTitle}'`, + values: { + visTitle: newDoc.title, + }, + }) + ); } catch (e) { // eslint-disable-next-line no-console console.dir(e); From 0470e94d4c1fdedd66a14562a2cbeb2adc09cb37 Mon Sep 17 00:00:00 2001 From: Kim Sang Ly Date: Fri, 16 Oct 2020 09:34:30 -0400 Subject: [PATCH 2/3] [Lens] Add toast notification when visualization is saved - Add single invocation of toast notification --- x-pack/plugins/lens/public/app_plugin/app.tsx | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx index 590c020414cca..a5f89ae56abf4 100644 --- a/x-pack/plugins/lens/public/app_plugin/app.tsx +++ b/x-pack/plugins/lens/public/app_plugin/app.tsx @@ -411,6 +411,15 @@ export function App({ return; } + notifications.toasts.addSuccess( + i18n.translate('visualize.topNavMenu.saveVisualization.successNotificationText', { + defaultMessage: `Saved '{visTitle}'`, + values: { + visTitle: docToSave.title, + }, + }) + ); + if ( attributeService.inputIsRefType(newInput) && newInput.savedObjectId !== originalSavedObjectId @@ -425,14 +434,6 @@ export function App({ isSaveModalVisible: false, isLinkedToOriginatingApp: false, })); - notifications.toasts.addSuccess( - i18n.translate('visualize.topNavMenu.saveVisualization.successNotificationText', { - defaultMessage: `Saved '{visTitle}'`, - values: { - visTitle: docToSave.title, - }, - }) - ); redirectTo(newInput.savedObjectId); return; } @@ -448,14 +449,6 @@ export function App({ isSaveModalVisible: false, isLinkedToOriginatingApp: false, })); - notifications.toasts.addSuccess( - i18n.translate('visualize.topNavMenu.saveVisualization.successNotificationText', { - defaultMessage: `Saved '{visTitle}'`, - values: { - visTitle: newDoc.title, - }, - }) - ); } catch (e) { // eslint-disable-next-line no-console console.dir(e); From 21586c0d6928ab7e5b41250c23a11d0ed0d7bf8c Mon Sep 17 00:00:00 2001 From: Kim Sang Ly Date: Fri, 16 Oct 2020 11:13:32 -0400 Subject: [PATCH 3/3] [Lens] Add toast notification when visualization is saved - Modify localization ID --- x-pack/plugins/lens/public/app_plugin/app.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx index a5f89ae56abf4..2d35c203661d0 100644 --- a/x-pack/plugins/lens/public/app_plugin/app.tsx +++ b/x-pack/plugins/lens/public/app_plugin/app.tsx @@ -412,7 +412,7 @@ export function App({ } notifications.toasts.addSuccess( - i18n.translate('visualize.topNavMenu.saveVisualization.successNotificationText', { + i18n.translate('xpack.lens.app.saveVisualization.successNotificationText', { defaultMessage: `Saved '{visTitle}'`, values: { visTitle: docToSave.title,