Skip to content

Commit a5f60fa

Browse files
authored
Clear modal notifs when opening modal (#1051)
* Clear modal notifs when opening modal When opening a modal, modal notifications were not properly cleared. This would lead to notifications being displayed in the wrong modals, i.e. "This event cannot be edited due to an active workflow" would appear on a create series modal. This patch should fix that. * Actually clear notif when opening create modals
1 parent 0b8ed1f commit a5f60fa

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/components/events/partials/wizards/NewEventWizard.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { useAppDispatch, useAppSelector } from "../../../../store";
1919
import { getOrgProperties, getUserInformation } from "../../../../selectors/userInfoSelectors";
2020
import { MetadataCatalog, UploadAssetOption, postNewEvent } from "../../../../slices/eventSlice";
2121
import { UserInfoState } from "../../../../slices/userInfoSlice";
22+
import { removeNotificationWizardForm } from "../../../../slices/notificationSlice";
2223
import NewMetadataCommonPage from "../ModalTabsAndPages/NewMetadataCommonPage";
2324
import WizardStepper from "../../../shared/wizard/WizardStepper";
2425

@@ -38,6 +39,12 @@ const NewEventWizard: React.FC<{
3839
const user = useAppSelector(state => getUserInformation(state));
3940
const orgProperties = useAppSelector(state => getOrgProperties(state));
4041

42+
useEffect(() => {
43+
dispatch(removeNotificationWizardForm());
44+
45+
// eslint-disable-next-line react-hooks/exhaustive-deps
46+
}, []);
47+
4148
// Whether the ACL of a new event is initialized with the ACL of its series.
4249
let initEventAclWithSeriesAcl = true
4350
const ADMIN_INIT_EVENT_ACL_WITH_SERIES_ACL = "admin.init.event.acl.with.series.acl";

src/components/events/partials/wizards/NewSeriesWizard.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import NewTobiraPage from "../ModalTabsAndPages/NewTobiraPage";
2121
import { getOrgProperties, getUserInformation } from "../../../../selectors/userInfoSelectors";
2222
import { UserInfoState } from "../../../../slices/userInfoSlice";
2323
import { TransformedAcl } from "../../../../slices/aclDetailsSlice";
24+
import { removeNotificationWizardForm } from "../../../../slices/notificationSlice";
2425
import NewMetadataCommonPage from "../ModalTabsAndPages/NewMetadataCommonPage";
2526

2627
/**
@@ -40,6 +41,12 @@ const NewSeriesWizard: React.FC<{
4041
const user = useAppSelector(state => getUserInformation(state));
4142
const orgProperties = useAppSelector(state => getOrgProperties(state));
4243

44+
useEffect(() => {
45+
dispatch(removeNotificationWizardForm());
46+
47+
// eslint-disable-next-line react-hooks/exhaustive-deps
48+
}, []);
49+
4350
const themesEnabled = (orgProperties['admin.themes.enabled'] || 'false').toLowerCase() === 'true';
4451

4552
const initialValues = getInitialValues(metadataFields, extendedMetadata, user);

src/slices/notificationSlice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ const notificationSlice = createSlice({
183183
},
184184
removeNotificationWizardForm(state) {
185185
state.notifications = state.notifications.filter(
186-
(notification) => notification.context === NOTIFICATION_CONTEXT
186+
(notification) => notification.context !== NOTIFICATION_CONTEXT
187187
)
188188
},
189189
removeNotificationWizardAccess(state) {

src/slices/seriesDetailsSlice.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ export const fetchSeriesDetailsAcls = createAppAsyncThunk('seriesDetails/fetchSe
144144
key: "SERIES_ACL_LOCKED",
145145
duration: -1,
146146
parameter: undefined,
147-
context: NOTIFICATION_CONTEXT
147+
context: NOTIFICATION_CONTEXT,
148+
noDuplicates: true
148149
})
149150
);
150151
}

0 commit comments

Comments
 (0)