Remove old notification API

Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
soupette 2021-05-17 11:31:19 +02:00
parent a310d52b72
commit f3da9beacd
12 changed files with 68 additions and 27 deletions

View File

@ -125,6 +125,7 @@
"component": "default.restaurantservice",
"repeatable": true,
"type": "component",
"max": 1,
"pluginOptions": {
"i18n": {
"localized": true

View File

@ -101,7 +101,10 @@ export class Admin extends React.Component {
this.props.getInfosDataSucceeded(data);
} catch (err) {
console.error(err);
strapi.notification.error('notification.error');
strapi.notification.toggle({
type: 'warning',
message: { id: 'notification.error' },
});
}
};

View File

@ -71,7 +71,10 @@ const DynamicZone = ({
if (dynamicDisplayedComponentsLength < max) {
setIsOpen(prev => !prev);
} else {
strapi.notification.info(`${pluginId}.components.notification.info.maximum-requirement`);
strapi.notification.toggle({
type: 'info',
message: { id: `${pluginId}.components.notification.info.maximum-requirement` },
});
}
};

View File

@ -67,7 +67,10 @@ const RepeatableComponent = ({
setCollapseToOpen(nextTempKey);
} else if (componentValueLength >= max) {
strapi.notification.info(`${pluginId}.components.notification.info.maximum-requirement`);
strapi.notification.toggle({
type: 'info',
message: { id: `${pluginId}.components.notification.info.maximum-requirement` },
});
}
}
}, [

View File

@ -152,7 +152,10 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
// Not allowed to read a document
if (resStatus === 403) {
strapi.notification.info(getTrad('permissions.not-allowed.update'));
strapi.notification.toggle({
type: 'info',
message: { id: getTrad('permissions.not-allowed.update') },
});
push(redirectionLink);
}
@ -192,7 +195,7 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
}
if (typeof errorMessage === 'string') {
strapi.notification.error(errorMessage);
strapi.notification.toggle({ type: 'warning', message: errorMessage });
}
}, []);
@ -205,7 +208,10 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
method: 'DELETE',
});
strapi.notification.success(getTrad('success.record.delete'));
strapi.notification.toggle({
type: 'success',
message: { id: getTrad('success.record.delete') },
});
emitEventRef.current('didDeleteEntry', trackerProperty);
@ -318,7 +324,10 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
const response = await request(endPoint, { method: 'POST' });
emitEventRef.current('didUnpublishEntry');
strapi.notification.success(getTrad('success.record.unpublish'));
strapi.notification.toggle({
type: 'success',
message: { id: getTrad('success.record.unpublish') },
});
dispatch(submitSucceeded(cleanReceivedData(response)));
dispatch(setStatus('resolved'));

View File

@ -134,7 +134,7 @@ const EditSettingsView = ({ components, mainLayout, isContentTypeView, slug, upd
emitEvent('didEditEditSettings');
} catch (err) {
strapi.notification.error('notification.error');
strapi.notification.toggle({ type: 'warning', message: { id: 'notification.error' } });
}
};

View File

@ -36,7 +36,7 @@ const DeleteLink = ({ isCreatingEntry, onDelete, onDeleteSucceeded, trackerPrope
'response.payload.message',
formatMessage({ id: `${pluginId}.error.record.delete` })
);
strapi.notification.error(errorMessage);
strapi.notification.toggle({ type: 'warning', message: errorMessage });
} finally {
setIsModalConfirmButtonLoading(false);
toggleWarningDelete();

View File

@ -83,7 +83,10 @@ const EditViewDataManagerProvider = ({
useEffect(() => {
if (shouldRedirectToHomepageWhenEditingEntry) {
strapi.notification.info(getTrad('permissions.not-allowed.update'));
strapi.notification.toggle({
type: 'info',
message: { id: getTrad('permissions.not-allowed.update') },
});
}
}, [shouldRedirectToHomepageWhenEditingEntry]);

View File

@ -142,7 +142,10 @@ function ListView({
if (resStatus === 403) {
await fetchPermissionsRef.current();
strapi.notification.info(getTrad('permissions.not-allowed.update'));
strapi.notification.toggle({
type: 'info',
message: { id: getTrad('permissions.not-allowed.update') },
});
push('/');
@ -151,7 +154,10 @@ function ListView({
if (err.name !== 'AbortError') {
console.error(err);
strapi.notification.error(getTrad('error.model.fetch'));
strapi.notification.toggle({
type: 'warning',
message: { id: getTrad('error.model.fetch') },
});
}
}
},
@ -188,7 +194,10 @@ function ListView({
onDeleteSeveralDataSucceeded();
emitEventRef.current('didBulkDeleteEntries');
} catch (err) {
strapi.notification.error(`${pluginId}.error.record.delete`);
strapi.notification.toggle({
type: 'warning',
message: { id: getTrad('error.record.delete') },
});
}
}, [entriesToDelete, onDeleteSeveralDataSucceeded, slug, setModalLoadingState]);
@ -213,7 +222,7 @@ function ListView({
strapi.notification.toggle({
type: 'success',
message: { id: `${pluginId}.success.record.delete` },
message: { id: getTrad('success.record.delete') },
});
// Close the modal and refetch data
@ -223,7 +232,7 @@ function ListView({
const errorMessage = get(
err,
'response.payload.message',
formatMessage({ id: `${pluginId}.error.record.delete` })
formatMessage({ id: getTrad('error.record.delete') })
);
strapi.notification.toggle({

View File

@ -39,7 +39,7 @@ function Main({ getData, getDataSucceeded, isLoading, resetProps }) {
getDataSucceeded(models, components);
} catch (err) {
console.error(err);
strapi.notification.error('notification.error');
strapi.notification.toggle({ type: 'warning', message: { id: 'notification.error' } });
}
};

View File

@ -122,7 +122,10 @@ const SingleTypeFormWrapper = ({ allLayoutData, children, slug }) => {
}
if (responseStatus === 403) {
strapi.notification.info(getTrad('permissions.not-allowed.update'));
strapi.notification.toggle({
type: 'info',
message: { id: getTrad('permissions.not-allowed.update') },
});
push('/');
}
@ -146,7 +149,7 @@ const SingleTypeFormWrapper = ({ allLayoutData, children, slug }) => {
}
if (typeof errorMessage === 'string') {
strapi.notification.error(errorMessage);
strapi.notification.toggle({ type: 'warning', message: errorMessage });
}
}, []);
@ -159,7 +162,10 @@ const SingleTypeFormWrapper = ({ allLayoutData, children, slug }) => {
method: 'DELETE',
});
strapi.notification.success(getTrad('success.record.delete'));
strapi.notification.toggle({
type: 'success',
message: { id: getTrad('success.record.delete') },
});
emitEventRef.current('didDeleteEntry', trackerProperty);

View File

@ -50,14 +50,17 @@ const SettingsPage = () => {
});
setTestSuccess(true);
strapi.notification.success(
formatMessage({ id: getTrad('Settings.notification.test.success') }, { to: testAddress })
const message = formatMessage(
{ id: getTrad('Settings.notification.test.success') },
{ to: testAddress }
);
strapi.notification.toggle({ type: 'success', message });
} catch (err) {
strapi.notification.error(
formatMessage({ id: getTrad('Settings.notification.test.error') }, { to: testAddress })
const message = formatMessage(
{ id: getTrad('Settings.notification.test.error') },
{ to: testAddress }
);
strapi.notification.toggle({ type: 'warning', message });
} finally {
if (isMounted.current) {
setIsTestButtonLoading(false);
@ -83,9 +86,10 @@ const SettingsPage = () => {
setTestAddress(get(data, 'config.settings.testAddress'));
})
.catch(() =>
strapi.notification.error(
formatMessage({ id: getTrad('Settings.notification.config.error') })
)
strapi.notification.toggle({
type: 'warning',
message: { id: getTrad('Settings.notification.config.error') },
})
)
.finally(() => setShowLoader(false));
};