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

Replace toastr with Ant Notification #3610

Merged
merged 3 commits into from
Mar 24, 2019
Merged

Replace toastr with Ant Notification #3610

merged 3 commits into from
Mar 24, 2019

Conversation

gabrieldutra
Copy link
Member

@gabrieldutra gabrieldutra commented Mar 19, 2019

What type of PR is this? (check all applicable)

  • Refactor

Description

I've considered using the Message component for some cases and I've even given it a try, however as @kravets-levko mentioned in #3547, it's annoying sometimes (even to small messages). Notification seemed a better fit anyway.

What this does:

  • Creates a notification.js to set our defaults to Ant Notification and replace function calls to be more similar to toastr (made life easier to change stuff + I think it will be easier to use);
  • Replaces all toastr calls to use notification;
  • Removes toastr from our dependencies 🙂

Related Tickets & Documents

Closes #3547

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

replace-toastr

@gabrieldutra gabrieldutra self-assigned this Mar 19, 2019
@ghost ghost added the in progress label Mar 19, 2019
export default { // export Ant's notification and replace actions
...notification,
...updatedActions,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

For notification consistency, consider some constants to be used across components:

{
  SAVE_SUCCESS: 'Saved',
  SAVE_ERROR: 'Failed saving',
  ...
}
notification.error(notification.SAVE_ERROR, 'Sth went wrong');

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is an interesting idea, but not sure if we really need it. At least, we should check if we have two or more messages with the same titles.

Copy link
Contributor

Choose a reason for hiding this comment

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

We do. Many.
And some others are variations which I think is worth consolidating.

Copy link
Contributor

Choose a reason for hiding this comment

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

But, it's definitely out-of-scope here. Future thinking.

Copy link
Member Author

Choose a reason for hiding this comment

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

We need this for sure 👍. I think for now we can add both SAVE_SUCCESS and SAVE_ERROR as they are a direct change in code and wouldn't be out-of-scope. This will at least define a future pattern and we can later modify existing notifications, WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it has value for ux, but I'd rather land this as is so we could move on to the next angular2react component.

@@ -33,18 +34,14 @@ function disableUser(user) {
return $http
.post(disableResource(user))
.then((data) => {
toastr.warning(`User <b>${userName}</b> is now disabled.`, { allowHtml: true });
notification.warning(`User ${userName} is now disabled.`);
Copy link
Contributor

Choose a reason for hiding this comment

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

I dunno if this should be a warning.. maybe notification.info?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ranbena in this case it's okay - we show message that user was disabled, and admin should see that they probably did something unsafe

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought it annoying with toastr, but with notification it turns out to be okay (that's why I've opted not to change it during the replacement)

IMO both options are suitable here, but if you still think it's better with info I can simply change that @ranbena :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's leave as is.

@ranbena
Copy link
Contributor

ranbena commented Mar 20, 2019

I think the default fixed width is not great.

Short messages are too distracting and needlessly bulky

Screen Shot 2019-03-20 at 9 33 49
"Go away! I'm trying to click on a button behind you!"

But with flexible width, a bit less

Screen Shot 2019-03-20 at 9 33 56

Long texts will break line

Screen Shot 2019-03-20 at 9 37 42

But not with flexible width

Screen Shot 2019-03-20 at 9 37 20

/* 🎁 */
.ant-notification {
  width: auto;
}
.ant-notification-notice {
  padding-right: 48px;
}

@gabrieldutra gabrieldutra changed the title WIP: Replace toastr with Ant Notification Replace toastr with Ant Notification Mar 20, 2019
@gabrieldutra gabrieldutra merged commit b4a4ee2 into master Mar 24, 2019
@gabrieldutra gabrieldutra deleted the replace-toastr branch March 25, 2019 12:56
harveyrendell pushed a commit to pushpay/redash that referenced this pull request Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants