diff --git a/src/components/events/partials/ModalTabsAndPages/DetailsTobiraTab.tsx b/src/components/events/partials/ModalTabsAndPages/DetailsTobiraTab.tsx index 8c9a3c11b7..47cdd1edc5 100644 --- a/src/components/events/partials/ModalTabsAndPages/DetailsTobiraTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/DetailsTobiraTab.tsx @@ -9,8 +9,10 @@ import { Formik } from "formik"; import { useState } from "react"; import EventDetailsTabHierarchyNavigation from "./EventDetailsTabHierarchyNavigation"; import NewTobiraPage, { TobiraFormProps } from "./NewTobiraPage"; -import { fetchSeriesDetailsTobira, setTobiraTabHierarchy, TobiraData, updateSeriesTobiraPath } from "../../../../slices/seriesDetailsSlice"; +import { fetchSeriesDetailsTobira, removeSeriesTobiraPath, setTobiraTabHierarchy, TobiraData, updateSeriesTobiraPath } from "../../../../slices/seriesDetailsSlice"; import { fetchSeriesDetailsTobiraNew, TobiraPage } from "../../../../slices/seriesSlice"; +import ConfirmModal from "../../../shared/ConfirmModal"; +import { Tooltip } from "../../../shared/Tooltip"; export type TobiraTabHierarchy = "main" | "edit-path"; @@ -92,6 +94,13 @@ const DetailsTobiraTab = ({ kind, id }: DetailsTobiraTabProps) => { dispatch(setTobiraTabHierarchy("main")); }; + const handleDelete = async (hostPage: TobiraPage) => { + await dispatch(removeSeriesTobiraPath({ + seriesId: id, + currentPath: hostPage.path, + })).then(() => dispatch(fetchSeriesDetailsTobira(id))) + } + const openSubTab = async (tabType: TobiraTabHierarchy, currentPage?: TobiraPage) => { if (!!currentPage) { const breadcrumbs = getBreadcrumbs(currentPage); @@ -139,16 +148,13 @@ const DetailsTobiraTab = ({ kind, id }: DetailsTobiraTabProps) => { {kind === "series" &&

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

} -
-
-
- {t(`EVENTS.${i18nKey}.DETAILS.TOBIRA.PAGES`)} -
-
- -
-
-
+ } } @@ -159,7 +165,10 @@ const DetailsTobiraTab = ({ kind, id }: DetailsTobiraTabProps) => { onSubmit={values => handleSubmit(values)} > {formik => {}} previousPage={() => {}} @@ -172,59 +181,79 @@ const DetailsTobiraTab = ({ kind, id }: DetailsTobiraTabProps) => { type TobiraTableProps = { tobiraData: TobiraData; i18nKey: "SERIES" | "EVENTS"; - openSubTab: (tabType: TobiraTabHierarchy, currentPage?: TobiraPage) => Promise + openSubTab: (tabType: TobiraTabHierarchy, currentPage?: TobiraPage) => Promise; + handleDelete: (hostPage: TobiraPage) => Promise; }; -const TobiraTable: React.FC = ({ tobiraData, i18nKey, openSubTab }) => { +const TobiraTable = ({ tobiraData, i18nKey, openSubTab, handleDelete }: TobiraTableProps) => { const { t } = useTranslation(); - return - - {tobiraData.hostPages.length === 0 && - - } - {tobiraData.hostPages.map(hostPage => - + )} + +
- {t(`EVENTS.${i18nKey}.DETAILS.TOBIRA.NOT_MOUNTED`)} - {i18nKey === "SERIES" && ( - - )} -
- - {hostPage.path !== '/' && <> - / - {hostPage.ancestors.map((ancestor, key) => ( - - {ancestor.title} - / - - ))} + const [showConfirmationModal, setShowConfirmationModal] = useState(false); + + return
+
{t(`EVENTS.${i18nKey}.DETAILS.TOBIRA.PAGES`)}
+ + + {tobiraData.hostPages.length === 0 && + + } + {tobiraData.hostPages.map(hostPage => + - )} - -
+ {t(`EVENTS.${i18nKey}.DETAILS.TOBIRA.NOT_MOUNTED`)} + {i18nKey === "SERIES" && +
+ + {hostPage.path !== '/' && <> + / + {hostPage.ancestors.map((ancestor, key) => ( + + {ancestor.title} + / + + ))} + } + + {hostPage.path !== '/' && + {hostPage.title} + } + {hostPage.path === '/' && + {t(`EVENTS.${i18nKey}.DETAILS.TOBIRA.HOMEPAGE`)} + } + + + {i18nKey === "SERIES" && hostPage.blocks?.length === 1 && <> + + } -
; +
+ ; }; export default DetailsTobiraTab; diff --git a/src/components/events/partials/ModalTabsAndPages/NewTobiraPage.tsx b/src/components/events/partials/ModalTabsAndPages/NewTobiraPage.tsx index dd8119a95f..fdbae36588 100644 --- a/src/components/events/partials/ModalTabsAndPages/NewTobiraPage.tsx +++ b/src/components/events/partials/ModalTabsAndPages/NewTobiraPage.tsx @@ -24,12 +24,16 @@ const NewTobiraPage = ({ formik, nextPage, previousPage, - editMode, + mode, }: { formik: FormikProps, nextPage: (values: T) => void, previousPage:(values: T) => void, editMode?: boolean, + mode: { + edit?: boolean, + mount?: boolean, + }, }) => { const { t } = useTranslation(); const dispatch = useAppDispatch(); @@ -202,7 +206,7 @@ const NewTobiraPage = ({
{/* Notifications */} - {!editMode &&

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

} +

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

{!error && <>
@@ -226,7 +230,7 @@ const NewTobiraPage = ({ - @@ -300,7 +304,15 @@ const NewTobiraPage = ({ {editing &&
+ {currentPage.children.length > 0 && } {t("EVENTS.SERIES.NEW.TOBIRA.PAGE_TITLE") /* Title */} {page.new &&