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] Add toast notification when visualization is saved #80788

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions x-pack/plugins/lens/public/app_plugin/app.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand Down
9 changes: 9 additions & 0 deletions x-pack/plugins/lens/public/app_plugin/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,15 @@ export function App({
return;
}

notifications.toasts.addSuccess(
i18n.translate('visualize.topNavMenu.saveVisualization.successNotificationText', {
Copy link
Contributor

@flash1293 flash1293 Oct 16, 2020

Choose a reason for hiding this comment

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

@lykims As this is a separate plugin, you need a separate i18n id - I suggest xpack.lens.app.saveVisualization.successNotificationText

You don't need to add translations manually, this is handled in a separate process

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Interesting. I was wondering how the translation was done.

defaultMessage: `Saved '{visTitle}'`,
values: {
visTitle: docToSave.title,
},
})
);

if (
attributeService.inputIsRefType(newInput) &&
newInput.savedObjectId !== originalSavedObjectId
Expand Down