From 6f8b4d94db083a1e8aa10638278af26f01604f73 Mon Sep 17 00:00:00 2001 From: ensiyehe Date: Wed, 27 Aug 2025 11:32:57 +0200 Subject: [PATCH 1/3] adding the new error message --- .../adminui/languages/lang-en_US.json | 1 + src/slices/eventSlice.ts | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/i18n/org/opencastproject/adminui/languages/lang-en_US.json b/src/i18n/org/opencastproject/adminui/languages/lang-en_US.json index 9127f89db2..9555477845 100644 --- a/src/i18n/org/opencastproject/adminui/languages/lang-en_US.json +++ b/src/i18n/org/opencastproject/adminui/languages/lang-en_US.json @@ -205,6 +205,7 @@ "CONFLICT_ALREADY_ENDED": "Scheduling error: The event has already ended.", "CONFLICT_END_BEFORE_START": "Scheduling error: Schedule end has to be later than the start.", "CONFLICT_IN_THE_PAST": "The schedule could not be updated: You cannot schedule an event to be in the past.", + "CONFLICT_STILL_DID_NOT_FINISH": "This event cannot be modified because it is currently in progress.", "INVALID_ACL_RULES": "Rules have to contain a valid role and read or/and write right(s).", "MISSING_ACL_RULES": "At least one role with Read and Write permissions is required!", "SAVED_ACL_RULES": "The access rules have been saved.", diff --git a/src/slices/eventSlice.ts b/src/slices/eventSlice.ts index 2e4604a083..997de9e470 100644 --- a/src/slices/eventSlice.ts +++ b/src/slices/eventSlice.ts @@ -923,9 +923,10 @@ export const checkConflicts = (values: { 0, 0, ); - + const today = new Date(); + today.setHours(0, 0, 0, 0); // If start date of event is smaller than today --> Event is in past - if (values.sourceMode === "SCHEDULE_SINGLE" && startDate < new Date()) { + if (values.sourceMode === "SCHEDULE_SINGLE" && startDate < today) { dispatch( addNotification({ type: "error", @@ -954,6 +955,19 @@ export const checkConflicts = (values: { check = false; } + // check if the event has already been started and still is in the process + if ((values.sourceMode === "SCHEDULE_SINGLE" || values.sourceMode === "SCHEDULE_MULTIPLE") && startDate.getHours() < new Date().getHours() && new Date().getHours() < endDate.getHours()) { + dispatch( + addNotification({ + type: "error", + key: "CONFLICT_STILL_DID_NOT_FINISH", + duration: -1, + context: NOTIFICATION_CONTEXT, + }), + ); + check = false; + } + // transform duration into milliseconds (needed for API request) const duration = parseInt(values.scheduleDurationHours) * 3600000 + From c1d5b4c8ce317ab919f4d8dd1af6a0d172baa100 Mon Sep 17 00:00:00 2001 From: ensiyehe Date: Tue, 11 Nov 2025 16:13:34 +0100 Subject: [PATCH 2/3] fix the issues --- .../ModalTabsAndPages/NewSourcePage.tsx | 21 ++++++++++++++++++- src/slices/eventSlice.ts | 4 ++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx b/src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx index 9e24337ce2..f123ced2de 100644 --- a/src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx +++ b/src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx @@ -369,6 +369,23 @@ const Schedule = { const { t } = useTranslation(); const currentLanguage = getCurrentLanguageInformation(); + const [endTimeChosen, setEndTimeChosen] = useState(false); + + // Parse start-Date strings + const startDateTime = new Date( + `${new Date(formik.values.scheduleStartDate).toISOString().split("T")[0]}T${formik.values.scheduleStartHour}:${formik.values.scheduleStartMinute}:00`, + ); + + // Parse end datetime + const endDateTime = new Date( + `${new Date(formik.values.scheduleEndDate).toISOString().split("T")[0]}T${formik.values.scheduleEndHour}:${formik.values.scheduleEndMinute}:00`, + ); + + const now = new Date(); + + // Event is in progress + const eventInProgress = now >= startDateTime && now <= endDateTime; + const renderInputDeviceOptions = () => { if (formik.values.location) { @@ -572,7 +589,7 @@ const Schedule = { if (formik.values.sourceMode === "SCHEDULE_MULTIPLE") { + setEndTimeChosen(true); changeEndMinuteMultiple( value, formik.values, formik.setFieldValue, ); } else { + setEndTimeChosen(true); changeEndMinute( value, formik.values, diff --git a/src/slices/eventSlice.ts b/src/slices/eventSlice.ts index 997de9e470..b271c1ea16 100644 --- a/src/slices/eventSlice.ts +++ b/src/slices/eventSlice.ts @@ -954,9 +954,9 @@ export const checkConflicts = (values: { ); check = false; } - + const now = new Date(); // check if the event has already been started and still is in the process - if ((values.sourceMode === "SCHEDULE_SINGLE" || values.sourceMode === "SCHEDULE_MULTIPLE") && startDate.getHours() < new Date().getHours() && new Date().getHours() < endDate.getHours()) { + if ((values.sourceMode === "SCHEDULE_SINGLE" || values.sourceMode === "SCHEDULE_MULTIPLE") && startDate <= now && now <= endDate) { dispatch( addNotification({ type: "error", From 0b67c6694685ea862012e14e05357ca98f8b0078 Mon Sep 17 00:00:00 2001 From: ensiyehe Date: Tue, 18 Nov 2025 15:19:14 +0100 Subject: [PATCH 3/3] fix the modification end time issues --- .../ModalTabsAndPages/NewSourcePage.tsx | 34 +++++++++++++++---- .../adminui/languages/lang-en_US.json | 2 +- src/slices/eventSlice.ts | 14 -------- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx b/src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx index f123ced2de..9fa0fb0266 100644 --- a/src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx +++ b/src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx @@ -12,7 +12,7 @@ import { Field } from "../../../shared/Field"; import RenderField from "../../../shared/wizard/RenderField"; import { getRecordings } from "../../../../selectors/recordingSelectors"; import { sourceMetadata } from "../../../../configs/sourceConfig"; -import { weekdays } from "../../../../configs/modalConfig"; +import { weekdays, NOTIFICATION_CONTEXT } from "../../../../configs/modalConfig"; import { getUserInformation } from "../../../../selectors/userInfoSelectors"; import { filterDevicesForAccess, @@ -37,7 +37,7 @@ import { } from "../../../../utils/dateUtils"; import { useAppDispatch, useAppSelector } from "../../../../store"; import { Recording, fetchRecordings } from "../../../../slices/recordingSlice"; -import { removeNotificationWizardForm } from "../../../../slices/notificationSlice"; +import { addNotification, removeNotificationWizardForm } from "../../../../slices/notificationSlice"; import { parseISO } from "date-fns"; import WizardNavigationButtons from "../../../shared/wizard/WizardNavigationButtons"; import { checkConflicts, UploadAssetsTrack } from "../../../../slices/eventSlice"; @@ -369,7 +369,7 @@ const Schedule = { const { t } = useTranslation(); const currentLanguage = getCurrentLanguageInformation(); - const [endTimeChosen, setEndTimeChosen] = useState(false); + const dispatch = useAppDispatch(); // Parse start-Date strings const startDateTime = new Date( @@ -589,11 +589,22 @@ const Schedule = { + if (eventInProgress && value < formik.values.scheduleEndHour) { + dispatch( + addNotification({ + type: "error", + key: "CONFLICT_END_TIME_TOO_EARLY", + duration: -1, + context: NOTIFICATION_CONTEXT, + }), + ); + return; // Block shortening + } if (formik.values.sourceMode === "SCHEDULE_MULTIPLE") { changeEndHourMultiple( value, @@ -609,15 +620,26 @@ const Schedule = { + + if (eventInProgress && value < formik.values.scheduleEndMinute) { + dispatch( + addNotification({ + type: "error", + key: "CONFLICT_END_TIME_TOO_EARLY", + duration: -1, + context: NOTIFICATION_CONTEXT, + }), + ); + return; // Block shortening + } + if (formik.values.sourceMode === "SCHEDULE_MULTIPLE") { - setEndTimeChosen(true); changeEndMinuteMultiple( value, formik.values, formik.setFieldValue, ); } else { - setEndTimeChosen(true); changeEndMinute( value, formik.values, diff --git a/src/i18n/org/opencastproject/adminui/languages/lang-en_US.json b/src/i18n/org/opencastproject/adminui/languages/lang-en_US.json index 9555477845..c6dbe8dcbe 100644 --- a/src/i18n/org/opencastproject/adminui/languages/lang-en_US.json +++ b/src/i18n/org/opencastproject/adminui/languages/lang-en_US.json @@ -205,7 +205,7 @@ "CONFLICT_ALREADY_ENDED": "Scheduling error: The event has already ended.", "CONFLICT_END_BEFORE_START": "Scheduling error: Schedule end has to be later than the start.", "CONFLICT_IN_THE_PAST": "The schedule could not be updated: You cannot schedule an event to be in the past.", - "CONFLICT_STILL_DID_NOT_FINISH": "This event cannot be modified because it is currently in progress.", + "CONFLICT_END_TIME_TOO_EARLY": "This event cannot be modified because it is currently in progress.", "INVALID_ACL_RULES": "Rules have to contain a valid role and read or/and write right(s).", "MISSING_ACL_RULES": "At least one role with Read and Write permissions is required!", "SAVED_ACL_RULES": "The access rules have been saved.", diff --git a/src/slices/eventSlice.ts b/src/slices/eventSlice.ts index b271c1ea16..4c948dcfdd 100644 --- a/src/slices/eventSlice.ts +++ b/src/slices/eventSlice.ts @@ -905,7 +905,6 @@ export const checkConflicts = (values: { sourceMode: string, }) => async (dispatch: AppDispatch) => { let check = true; - // Only perform checks if source mode is SCHEDULE_SINGLE or SCHEDULE_MULTIPLE if ( values.sourceMode === "SCHEDULE_SINGLE" || @@ -954,19 +953,6 @@ export const checkConflicts = (values: { ); check = false; } - const now = new Date(); - // check if the event has already been started and still is in the process - if ((values.sourceMode === "SCHEDULE_SINGLE" || values.sourceMode === "SCHEDULE_MULTIPLE") && startDate <= now && now <= endDate) { - dispatch( - addNotification({ - type: "error", - key: "CONFLICT_STILL_DID_NOT_FINISH", - duration: -1, - context: NOTIFICATION_CONTEXT, - }), - ); - check = false; - } // transform duration into milliseconds (needed for API request) const duration =