-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Document how to override notifications messages #1193
Comments
And do what? That means baking in the saga some predefined behaviors. Which ones? |
The saga already shows the error message as a notification. What I am proposing is to support a map of resource + error code to a custom error message instead of the default one. This will allow us to give more meaningful notification messages instead of generic "Internal Server Error". |
I think the solution for that is that you provide a custom saga. But we need to provide a way to disable aor's default error messages. So marking this as an enhancement. |
For anybody else who needs this: if you are in control of your backend you can just return {message:'Text'} and Admin-on-rest will show the message text in the notification. |
@dimitrovs thaaaaank you. I was scratching my head for hours trying to figure out how to override the generic error. |
@dimitrovs, can we close this then ? |
This is documented actually: See https://marmelab.com/admin-on-rest/RestClients.html#writing-your-own-rest-client (at the end, How can we make this easier to find ? |
Just stumbled into this issue today. It's documented in this issue as well. |
Even with the possibility to show a custom error message, translation of it is not possible. React-Admin assumes the message coming in I think it would be better to error message be based on a code number/string. Something like, if server returns error object like the following |
Yes we can do a better job on documenting this. In the mean time, you should know that the notifications will always try to translate their texts (https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/layout/Notification.js#L83). So, in order to translate your API errors, just make the error's message a translation key. |
@djhi , how do you translate your Errors? |
Please ask this on StackOverflow |
I just posted an answer on your stackoverflow question @wmwart |
As @fzaninotto mentioned in a comment above, are there any plans to support disabling notifications? Should I open a new issue? I see that overriding the error message is possible, but in my case, I'm looking for a way to disable the notification entirely. I posted a stackoverflow question and looked at the source code, but I can't seem to find a way to do this. Anybody know a way to disable the notification? The relevant part of the source I found is the notification saga which always shows either the error, the error.message or the notification.body with no option to skip or ignore. Thanks for an awesome framework, btw! |
No, we have no such plans. But you can achieve it in userland by overriding the Notification component in the layout. |
Thanks @fzaninotto! I'll give that a try. |
@pavel-nano Can you give more detail of the situation illustrated by your screenshot ? I tried to reproduce your notifcation "failing" message but without succes. Note : Only way of possible bug I founded is in the Exporter if your csv export fails. |
As we have no more information to progress on this issue since a long, I close it. |
This has already been asked before: #180 but the answer provided was to basically not use the Admin component. I believe this could be a useful feature. Can we discuss some alternative approaches to provide an easier to use and user friendly server messaging?
I propose to add support for a mapping file, similar to the way Translation messages are implemented, such that every error (or even every response) received from the server will be looked up in this server messages mapping file by the Admin on rest saga.
The text was updated successfully, but these errors were encountered: