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

Fix "Missing translation" console error when the dataProvider fails #5655

Merged
merged 2 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
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