Skip to content

Commit

Permalink
Merge pull request #5655 from marmelab/fix-notify-missing-translation
Browse files Browse the repository at this point in the history
Fix "Missing translation" console error when the dataProvider fails
  • Loading branch information
djhi authored Dec 11, 2020
2 parents 4deee95 + 9aebbfd commit be749b7
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 12 deletions.
10 changes: 9 additions & 1 deletion examples/demo/src/layout/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 9 additions & 1 deletion packages/ra-core/src/controller/details/useCreateController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
);
},
}
Expand Down
10 changes: 9 additions & 1 deletion packages/ra-core/src/controller/details/useEditController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,15 @@ export const useEditController = <RecordType extends Record = Record>(
? error
: error.message ||
'ra.notification.http_error',
'warning'
'warning',
{
_:
typeof error === 'string'
? error
: error && error.message
? error.message
: undefined,
}
);
if (undoable) {
refresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
),
}
);
Expand Down
10 changes: 9 additions & 1 deletion packages/ra-core/src/controller/useListController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,15 @@ const useListController = <RecordType extends Record = Record>(
typeof error === 'string'
? error
: error.message || 'ra.notification.http_error',
'warning'
'warning',
{
_:
typeof error === 'string'
? error
: error && error.message
? error.message
: undefined,
}
),
}
);
Expand Down
10 changes: 9 additions & 1 deletion packages/ra-ui-materialui/src/auth/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ const LoginForm: FunctionComponent<Props> = 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,
}
);
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ const BulkDeleteWithConfirmButton: FC<BulkDeleteWithConfirmButtonProps> = 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);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@ const BulkDeleteWithUndoButton: FC<BulkDeleteWithUndoButtonProps> = 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,
});
Expand Down

0 comments on commit be749b7

Please sign in to comment.