deps: migrate fec/notifications
The frontend component library decoupled notifications from redux.
Dispatching notifications via the notifications middleware was replaced
by a new `useAddNotifications` hook.
We mostly used the notifications middleware outside of React Components
in our `enhancedImageBuilderApi` store for mutation events. I created a
wrapper around the RTK hooks that uses the `useAddNotification` hook
and created a directory for the new hooks.
In other places, where we were using the notification dispatcher inside
React components, I replaced the call with the new hook.
[1] b1d4973144/packages/notifications/doc/migration.md
bump @redhat-cloud-services/frontend-components-notifications
---
updated-dependencies:
- dependency-name: "@redhat-cloud-services/frontend-components-notifications"
dependency-version: 6.0.2
dependency-type: direct:production
update-type: version-update:semver-major
...
Co-authored-by: dependabot[bot] <support@github.com>
Assisted-by: cursor ide for generalizing the `useMutationWithNotification`
hook.
This commit is contained in:
parent
77e0f5d6bf
commit
e8d46dd716
32 changed files with 412 additions and 473 deletions
|
|
@ -1,40 +0,0 @@
|
|||
import { addNotification } from '@redhat-cloud-services/frontend-components-notifications/redux';
|
||||
import { Dispatch } from 'redux';
|
||||
|
||||
const manageEdgeImagesUrlName = 'manage-edge-images';
|
||||
|
||||
const getNotificationProp = (dispatch: Dispatch) => {
|
||||
return {
|
||||
hasInfo: (hasInfoMessage: Notification) => {
|
||||
dispatch({
|
||||
...addNotification({
|
||||
variant: 'info',
|
||||
...hasInfoMessage,
|
||||
}),
|
||||
});
|
||||
},
|
||||
hasSuccess: (hasSuccessMessage: Notification) => {
|
||||
dispatch({
|
||||
...addNotification({
|
||||
variant: 'success',
|
||||
...hasSuccessMessage,
|
||||
}),
|
||||
});
|
||||
},
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
err: (errMessage: any, err: any) => {
|
||||
dispatch({
|
||||
...addNotification({
|
||||
variant: 'danger',
|
||||
...errMessage,
|
||||
// Add error message from API, if present
|
||||
description: err?.Title
|
||||
? `${errMessage.description}: ${err.Title}`
|
||||
: errMessage.description,
|
||||
}),
|
||||
});
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export { getNotificationProp, manageEdgeImagesUrlName };
|
||||
Loading…
Add table
Add a link
Reference in a new issue