mirror of
https://github.com/strapi/strapi.git
synced 2025-11-17 18:51:22 +00:00
Fix toast message
Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
parent
907979acd3
commit
6cefdaaf11
@ -6,7 +6,7 @@ import { Link } from '@strapi/parts/Link';
|
|||||||
|
|
||||||
const Notification = ({ dispatch, notification }) => {
|
const Notification = ({ dispatch, notification }) => {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const { message, link, type, id, onClose, timeout, blockTransition, title } = notification;
|
const { message, link, type, id, onClose, timeout, blockTransition } = notification;
|
||||||
|
|
||||||
const formattedMessage = msg => (typeof msg === 'string' ? msg : formatMessage(msg, msg.values));
|
const formattedMessage = msg => (typeof msg === 'string' ? msg : formatMessage(msg, msg.values));
|
||||||
const handleClose = useCallback(() => {
|
const handleClose = useCallback(() => {
|
||||||
@ -56,10 +56,6 @@ const Notification = ({ dispatch, notification }) => {
|
|||||||
variant = 'success';
|
variant = 'success';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (title) {
|
|
||||||
alertTitle = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Alert
|
<Alert
|
||||||
action={
|
action={
|
||||||
@ -97,7 +93,6 @@ Notification.defaultProps = {
|
|||||||
},
|
},
|
||||||
onClose: () => null,
|
onClose: () => null,
|
||||||
timeout: 2500,
|
timeout: 2500,
|
||||||
title: null,
|
|
||||||
blockTransition: false,
|
blockTransition: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -126,7 +121,6 @@ Notification.propTypes = {
|
|||||||
}),
|
}),
|
||||||
]).isRequired,
|
]).isRequired,
|
||||||
}),
|
}),
|
||||||
title: PropTypes.string,
|
|
||||||
type: PropTypes.string,
|
type: PropTypes.string,
|
||||||
onClose: PropTypes.func,
|
onClose: PropTypes.func,
|
||||||
timeout: PropTypes.number,
|
timeout: PropTypes.number,
|
||||||
|
|||||||
@ -14,7 +14,6 @@ const notificationReducer = (state = initialState, action) =>
|
|||||||
draftState.notifications.push({
|
draftState.notifications.push({
|
||||||
// No action.config spread to limit the notification API and avoid customization
|
// No action.config spread to limit the notification API and avoid customization
|
||||||
id: state.notifId,
|
id: state.notifId,
|
||||||
title: action.config.title || null,
|
|
||||||
type: get(action, ['config', 'type'], 'success'),
|
type: get(action, ['config', 'type'], 'success'),
|
||||||
message: get(action, ['config', 'message'], {
|
message: get(action, ['config', 'message'], {
|
||||||
id: 'notification.success.saved',
|
id: 'notification.success.saved',
|
||||||
|
|||||||
@ -30,7 +30,6 @@ describe('ADMIN | COMPONENTS | NOTIFICATIONS | reducer', () => {
|
|||||||
notifications: [
|
notifications: [
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
title: null,
|
|
||||||
type: 'success',
|
type: 'success',
|
||||||
message: { id: 'notification.message' },
|
message: { id: 'notification.message' },
|
||||||
link: null,
|
link: null,
|
||||||
|
|||||||
@ -304,12 +304,13 @@ const EditViewDataManagerProvider = ({
|
|||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
||||||
errors = getYupInnerErrors(err);
|
errors = getYupInnerErrors(err);
|
||||||
const firstError = Object.keys(errors)[0];
|
|
||||||
|
|
||||||
toggleNotification({
|
toggleNotification({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
title: `${firstError}:`,
|
message: {
|
||||||
message: errors[firstError],
|
id: getTrad('containers.EditView.notification.errors'),
|
||||||
|
defaultMessage: 'The form contains some errors',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user