From 3ca089ada0fabda19573a8c61dd9f6e5764d73ca Mon Sep 17 00:00:00 2001 From: Ole Wieners Date: Wed, 14 Aug 2024 23:38:21 +0200 Subject: [PATCH] Adjust http error handling and notifications 503 errors mean that Tobira either isn't configured, or not configured correcty in Opencast. Unfortunately, it doesn't distinguish between the two. Since it might very well be the former, I think we shouldn't show the error as a notification in the UI. Instead there will be an info in console saying "Tobira isn't configured (correctly)" and the Tobira tab will be hidden. This solution isn't optimal but I think it's the best we can do for now. The other errors (404, 500) will trigger notifications that are shown in the respective Tobira tab. --- .../ModalTabsAndPages/DetailsTobiraTab.tsx | 4 +- .../ModalTabsAndPages/NewTobiraPage.tsx | 18 ++--- .../events/partials/modals/EventDetails.tsx | 8 ++- .../events/partials/modals/SeriesDetails.tsx | 4 +- .../partials/wizards/NewSeriesWizard.tsx | 6 +- src/components/shared/Notifications.tsx | 31 ++++---- src/configs/modalConfig.ts | 3 + .../adminui/languages/lang-en_US.json | 13 +++- src/selectors/eventDetailsSelectors.ts | 6 +- src/selectors/seriesDetailsSelectors.ts | 4 +- src/slices/eventDetailsSlice.ts | 31 +------- src/slices/notificationSlice.ts | 2 +- src/slices/seriesDetailsSlice.ts | 43 +++-------- src/slices/seriesSlice.ts | 35 +-------- src/slices/shared/tobiraErrors.ts | 72 +++++++++++++++++++ 15 files changed, 147 insertions(+), 133 deletions(-) create mode 100644 src/slices/shared/tobiraErrors.ts diff --git a/src/components/events/partials/ModalTabsAndPages/DetailsTobiraTab.tsx b/src/components/events/partials/ModalTabsAndPages/DetailsTobiraTab.tsx index cabd57e33e..7230b75a1e 100644 --- a/src/components/events/partials/ModalTabsAndPages/DetailsTobiraTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/DetailsTobiraTab.tsx @@ -2,7 +2,7 @@ import { useTranslation } from "react-i18next"; import Notifications from "../../../shared/Notifications"; import { useAppDispatch, useAppSelector } from "../../../../store"; import { getSeriesDetailsTobiraData, getSeriesDetailsTobiraDataError, getTobiraTabHierarchy } from "../../../../selectors/seriesDetailsSelectors"; -import { addNotification, removeNotificationWizardForm } from "../../../../slices/notificationSlice"; +import { addNotification } from "../../../../slices/notificationSlice"; import { NOTIFICATION_CONTEXT } from "../../../../configs/modalConfig"; import { getEventDetailsTobiraData, getEventDetailsTobiraDataError } from "../../../../selectors/eventDetailsSelectors"; import { Formik } from "formik"; @@ -112,7 +112,7 @@ const DetailsTobiraTab: React.FC = ({ kind, id }) => { />} {tabHierarchy === "main" &&
{/* Notifications */} - + {!error && <>
diff --git a/src/components/events/partials/ModalTabsAndPages/NewTobiraPage.tsx b/src/components/events/partials/ModalTabsAndPages/NewTobiraPage.tsx index 54093d9d57..9921b9a7a5 100644 --- a/src/components/events/partials/ModalTabsAndPages/NewTobiraPage.tsx +++ b/src/components/events/partials/ModalTabsAndPages/NewTobiraPage.tsx @@ -7,7 +7,7 @@ import { OurNotification, addNotification, removeNotificationByKey, removeNotifi import { useAppDispatch, useAppSelector } from "../../../../store"; import { TobiraPage, fetchSeriesDetailsTobiraNew, setErrorTobiraPage, setTobiraPage } from "../../../../slices/seriesSlice"; import { getSeriesTobiraPage, getSeriesTobiraPageError } from "../../../../selectors/seriesSeletctor"; -import { NOTIFICATION_CONTEXT } from "../../../../configs/modalConfig"; +import { NOTIFICATION_CONTEXT_TOBIRA } from "../../../../configs/modalConfig"; import { SaveEditFooter } from "../../../shared/SaveEditFooter"; import { Tooltip } from "../../../shared/Tooltip"; @@ -71,7 +71,7 @@ const NewTobiraPage = ({ let valid = true; - valid = valid && check('info', 'TOBIRA_OVERRIDE_NAME', NOTIFICATION_CONTEXT, () => { + valid = valid && check('info', 'TOBIRA_OVERRIDE_NAME', NOTIFICATION_CONTEXT_TOBIRA, () => { return !!formik.values.selectedPage && !!formik.values.selectedPage.title; }); @@ -87,9 +87,9 @@ const NewTobiraPage = ({ } const newPage = currentPage.children[currentPage.children.length - 1]; - valid = valid && check('warning', 'TOBIRA_NO_PATH_SEGMENT', NOTIFICATION_CONTEXT, () => !newPage.segment); + valid = valid && check('warning', 'TOBIRA_NO_PATH_SEGMENT', NOTIFICATION_CONTEXT_TOBIRA, () => !newPage.segment); - valid = valid && check('warning', 'TOBIRA_PATH_SEGMENT_INVALID', NOTIFICATION_CONTEXT, () => ( + valid = valid && check('warning', 'TOBIRA_PATH_SEGMENT_INVALID', NOTIFICATION_CONTEXT_TOBIRA, () => ( newPage.segment.length <= 1 || [ // eslint-disable-next-line no-control-regex /[\u0000-\u001F\u007F-\u009F]/u, @@ -99,7 +99,7 @@ const NewTobiraPage = ({ ].some(regex => regex.test(newPage.segment)) )); - valid = valid && check('warning', 'TOBIRA_PATH_SEGMENT_UNIQUE', NOTIFICATION_CONTEXT, () => ( + valid = valid && check('warning', 'TOBIRA_PATH_SEGMENT_UNIQUE', NOTIFICATION_CONTEXT_TOBIRA, () => ( currentPage.children.some(child => child !== newPage && child.segment === newPage.segment) )); @@ -211,7 +211,7 @@ const NewTobiraPage = ({
{/* Notifications */} - + {!editMode &&

{t("EVENTS.SERIES.NEW.TOBIRA.DESCRIPTION")}

} {!error && <>
@@ -271,8 +271,8 @@ const NewTobiraPage = ({ {!!page.new ? setPage(key, e, "title")} + value={page.title ?? ""} + onChange={e => setPage(key, e, "title")} /> :