From 27e446b9cf53340b3fb83f069094db4b3b0a2582 Mon Sep 17 00:00:00 2001 From: fzaninotto Date: Fri, 11 Dec 2020 07:21:07 +0100 Subject: [PATCH 1/2] Fix "Missing translation" console error when the dataProvider fails --- examples/demo/src/layout/Login.tsx | 10 +++++++++- .../button/useDeleteWithConfirmController.tsx | 10 +++++++++- .../controller/button/useDeleteWithUndoController.tsx | 10 +++++++++- .../src/controller/details/useCreateController.ts | 10 +++++++++- .../src/controller/details/useEditController.ts | 10 +++++++++- .../field/useReferenceArrayFieldController.ts | 10 +++++++++- .../field/useReferenceManyFieldController.ts | 10 +++++++++- packages/ra-core/src/controller/useListController.ts | 10 +++++++++- packages/ra-ui-materialui/src/auth/LoginForm.tsx | 10 +++++++++- .../src/button/BulkDeleteWithConfirmButton.tsx | 10 +++++++++- .../src/button/BulkDeleteWithUndoButton.tsx | 10 +++++++++- 11 files changed, 99 insertions(+), 11 deletions(-) diff --git a/examples/demo/src/layout/Login.tsx b/examples/demo/src/layout/Login.tsx index 78ab9679a1d..a769d8f5369 100644 --- a/examples/demo/src/layout/Login.tsx +++ b/examples/demo/src/layout/Login.tsx @@ -99,7 +99,15 @@ const Login = () => { : typeof error === 'undefined' || !error.message ? 'ra.auth.sign_in_error' : error.message, - 'warning' + 'warning', + { + _: + typeof error === 'string' + ? error + : error && error.message + ? error.message + : undefined, + } ); } ); diff --git a/packages/ra-core/src/controller/button/useDeleteWithConfirmController.tsx b/packages/ra-core/src/controller/button/useDeleteWithConfirmController.tsx index e4c615de321..9c422c37bd2 100644 --- a/packages/ra-core/src/controller/button/useDeleteWithConfirmController.tsx +++ b/packages/ra-core/src/controller/button/useDeleteWithConfirmController.tsx @@ -103,7 +103,15 @@ const useDeleteWithConfirmController = ( typeof error === 'string' ? error : error.message || 'ra.notification.http_error', - 'warning' + 'warning', + { + _: + typeof error === 'string' + ? error + : error && error.message + ? error.message + : undefined, + } ); refresh(); } else { diff --git a/packages/ra-core/src/controller/button/useDeleteWithUndoController.tsx b/packages/ra-core/src/controller/button/useDeleteWithUndoController.tsx index 1e08a6dcac9..4b054888e33 100644 --- a/packages/ra-core/src/controller/button/useDeleteWithUndoController.tsx +++ b/packages/ra-core/src/controller/button/useDeleteWithUndoController.tsx @@ -87,7 +87,15 @@ const useDeleteWithUndoController = ( typeof error === 'string' ? error : error.message || 'ra.notification.http_error', - 'warning' + 'warning', + { + _: + typeof error === 'string' + ? error + : error && error.message + ? error.message + : undefined, + } ); refresh(); }, diff --git a/packages/ra-core/src/controller/details/useCreateController.ts b/packages/ra-core/src/controller/details/useCreateController.ts index 4a41e8d0655..b59186e6a50 100644 --- a/packages/ra-core/src/controller/details/useCreateController.ts +++ b/packages/ra-core/src/controller/details/useCreateController.ts @@ -187,7 +187,15 @@ export const useCreateController = < ? error : error.message || 'ra.notification.http_error', - 'warning' + 'warning', + { + _: + typeof error === 'string' + ? error + : error && error.message + ? error.message + : undefined, + } ); }, } diff --git a/packages/ra-core/src/controller/details/useEditController.ts b/packages/ra-core/src/controller/details/useEditController.ts index a212b06d7e2..2d7bffdab4f 100644 --- a/packages/ra-core/src/controller/details/useEditController.ts +++ b/packages/ra-core/src/controller/details/useEditController.ts @@ -204,7 +204,15 @@ export const useEditController = ( ? error : error.message || 'ra.notification.http_error', - 'warning' + 'warning', + { + _: + typeof error === 'string' + ? error + : error && error.message + ? error.message + : undefined, + } ); if (undoable) { refresh(); diff --git a/packages/ra-core/src/controller/field/useReferenceArrayFieldController.ts b/packages/ra-core/src/controller/field/useReferenceArrayFieldController.ts index 7a848ab6770..c88aa101c0d 100644 --- a/packages/ra-core/src/controller/field/useReferenceArrayFieldController.ts +++ b/packages/ra-core/src/controller/field/useReferenceArrayFieldController.ts @@ -73,7 +73,15 @@ const useReferenceArrayFieldController = ( typeof error === 'string' ? error : error.message || 'ra.notification.http_error', - 'warning' + 'warning', + { + _: + typeof error === 'string' + ? error + : error && error.message + ? error.message + : undefined, + } ), }); diff --git a/packages/ra-core/src/controller/field/useReferenceManyFieldController.ts b/packages/ra-core/src/controller/field/useReferenceManyFieldController.ts index 2baffa9fdb4..138605bd8b3 100644 --- a/packages/ra-core/src/controller/field/useReferenceManyFieldController.ts +++ b/packages/ra-core/src/controller/field/useReferenceManyFieldController.ts @@ -172,7 +172,15 @@ const useReferenceManyFieldController = ( typeof error === 'string' ? error : error.message || 'ra.notification.http_error', - 'warning' + 'warning', + { + _: + typeof error === 'string' + ? error + : error && error.message + ? error.message + : undefined, + } ), } ); diff --git a/packages/ra-core/src/controller/useListController.ts b/packages/ra-core/src/controller/useListController.ts index cebd36ea9bc..ea4e46597b2 100644 --- a/packages/ra-core/src/controller/useListController.ts +++ b/packages/ra-core/src/controller/useListController.ts @@ -160,7 +160,15 @@ const useListController = ( typeof error === 'string' ? error : error.message || 'ra.notification.http_error', - 'warning' + 'warning', + { + _: + typeof error === 'string' + ? error + : error && error.message + ? error.message + : undefined, + } ), } ); diff --git a/packages/ra-ui-materialui/src/auth/LoginForm.tsx b/packages/ra-ui-materialui/src/auth/LoginForm.tsx index bb0ff72b37b..a6ffef401ab 100644 --- a/packages/ra-ui-materialui/src/auth/LoginForm.tsx +++ b/packages/ra-ui-materialui/src/auth/LoginForm.tsx @@ -84,7 +84,15 @@ const LoginForm: FunctionComponent = props => { : typeof error === 'undefined' || !error.message ? 'ra.auth.sign_in_error' : error.message, - 'warning' + 'warning', + { + _: + typeof error === 'string' + ? error + : error && error.message + ? error.message + : undefined, + } ); }); }; diff --git a/packages/ra-ui-materialui/src/button/BulkDeleteWithConfirmButton.tsx b/packages/ra-ui-materialui/src/button/BulkDeleteWithConfirmButton.tsx index 5992f732d5d..761b03108c9 100644 --- a/packages/ra-ui-materialui/src/button/BulkDeleteWithConfirmButton.tsx +++ b/packages/ra-ui-materialui/src/button/BulkDeleteWithConfirmButton.tsx @@ -70,7 +70,15 @@ const BulkDeleteWithConfirmButton: FC = props typeof error === 'string' ? error : error.message || 'ra.notification.http_error', - 'warning' + 'warning', + { + _: + typeof error === 'string' + ? error + : error && error.message + ? error.message + : undefined, + } ); setOpen(false); }, diff --git a/packages/ra-ui-materialui/src/button/BulkDeleteWithUndoButton.tsx b/packages/ra-ui-materialui/src/button/BulkDeleteWithUndoButton.tsx index 92a69ee43a4..f5d28ee8b41 100644 --- a/packages/ra-ui-materialui/src/button/BulkDeleteWithUndoButton.tsx +++ b/packages/ra-ui-materialui/src/button/BulkDeleteWithUndoButton.tsx @@ -64,7 +64,15 @@ const BulkDeleteWithUndoButton: FC = props => { typeof error === 'string' ? error : error.message || 'ra.notification.http_error', - 'warning' + 'warning', + { + _: + typeof error === 'string' + ? error + : error && error.message + ? error.message + : undefined, + } ), undoable: true, }); From 9aebbfd83f79a736aae3bdfbaf632cba59c6963b Mon Sep 17 00:00:00 2001 From: fzaninotto Date: Fri, 11 Dec 2020 09:02:00 +0100 Subject: [PATCH 2/2] useCreateController --- .../ra-core/src/controller/details/useCreateController.spec.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ra-core/src/controller/details/useCreateController.spec.tsx b/packages/ra-core/src/controller/details/useCreateController.spec.tsx index fdb6ad6541f..151816084c3 100644 --- a/packages/ra-core/src/controller/details/useCreateController.spec.tsx +++ b/packages/ra-core/src/controller/details/useCreateController.spec.tsx @@ -158,7 +158,7 @@ describe('useCreateController', () => { expect(notify[0]).toEqual({ type: 'RA/SHOW_NOTIFICATION', payload: { - messageArgs: {}, + messageArgs: { _: 'not good' }, undoable: false, autoHideDuration: undefined, type: 'warning',