|
@@ -1,7 +1,7 @@
|
|
|
import React, { useState, useCallback } from 'react';
|
|
import React, { useState, useCallback } from 'react';
|
|
|
|
|
+import { useTranslation } from 'react-i18next';
|
|
|
import PropTypes from 'prop-types';
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
-import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
|
|
import { DropdownItem } from 'reactstrap';
|
|
import { DropdownItem } from 'reactstrap';
|
|
|
|
|
|
|
@@ -13,8 +13,9 @@ import {
|
|
|
} from '~/stores/ui';
|
|
} from '~/stores/ui';
|
|
|
import {
|
|
import {
|
|
|
usePageAccessoriesModal, PageAccessoriesModalContents,
|
|
usePageAccessoriesModal, PageAccessoriesModalContents,
|
|
|
- usePageDuplicateModal, usePageRenameModal, usePageDeleteModal, usePagePresentationModal,
|
|
|
|
|
|
|
+ usePageDuplicateModal, usePageRenameModal, usePageDeleteModal, OnDeletedFunction, usePagePresentationModal,
|
|
|
} from '~/stores/modal';
|
|
} from '~/stores/modal';
|
|
|
|
|
+import { useSWRxPageChildren } from '~/stores/page-listing';
|
|
|
|
|
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
@@ -122,6 +123,8 @@ const AdditionalMenuItems = (props: AdditionalMenuItemsProps): JSX.Element => {
|
|
|
|
|
|
|
|
|
|
|
|
|
const GrowiContextualSubNavigation = (props) => {
|
|
const GrowiContextualSubNavigation = (props) => {
|
|
|
|
|
+ const { t } = useTranslation();
|
|
|
|
|
+
|
|
|
const { data: isDeviceSmallerThanMd } = useIsDeviceSmallerThanMd();
|
|
const { data: isDeviceSmallerThanMd } = useIsDeviceSmallerThanMd();
|
|
|
const { data: isDrawerMode } = useDrawerMode();
|
|
const { data: isDrawerMode } = useDrawerMode();
|
|
|
const { data: editorMode, mutate: mutateEditorMode } = useEditorMode();
|
|
const { data: editorMode, mutate: mutateEditorMode } = useEditorMode();
|
|
@@ -142,6 +145,7 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
const { data: isAbleToShowPageEditorModeManager } = useIsAbleToShowPageEditorModeManager();
|
|
const { data: isAbleToShowPageEditorModeManager } = useIsAbleToShowPageEditorModeManager();
|
|
|
const { data: isAbleToShowPageAuthors } = useIsAbleToShowPageAuthors();
|
|
const { data: isAbleToShowPageAuthors } = useIsAbleToShowPageAuthors();
|
|
|
|
|
|
|
|
|
|
+ const { mutate: mutateChildren } = useSWRxPageChildren(path);
|
|
|
const { mutate: mutateSWRTagsInfo, data: tagsInfoData } = useSWRTagsInfo(pageId);
|
|
const { mutate: mutateSWRTagsInfo, data: tagsInfoData } = useSWRTagsInfo(pageId);
|
|
|
|
|
|
|
|
const { open: openDuplicateModal } = usePageDuplicateModal();
|
|
const { open: openDuplicateModal } = usePageDuplicateModal();
|
|
@@ -186,9 +190,27 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
openRenameModal(pageId, revisionId, path);
|
|
openRenameModal(pageId, revisionId, path);
|
|
|
}, [openRenameModal]);
|
|
}, [openRenameModal]);
|
|
|
|
|
|
|
|
- const deleteItemClickedHandler = useCallback(async(pageToDelete) => {
|
|
|
|
|
- openDeleteModal([pageToDelete]);
|
|
|
|
|
- }, [openDeleteModal]);
|
|
|
|
|
|
|
+ const onDeletedHandler: OnDeletedFunction = useCallback((pathOrPathsToDelete, isRecursively, isCompletely) => {
|
|
|
|
|
+ if (typeof pathOrPathsToDelete !== 'string') {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ mutateChildren();
|
|
|
|
|
+
|
|
|
|
|
+ const path = pathOrPathsToDelete;
|
|
|
|
|
+
|
|
|
|
|
+ if (isCompletely) {
|
|
|
|
|
+ // redirect to NotFound Page
|
|
|
|
|
+ window.location.href = path;
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ window.location.reload();
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [mutateChildren]);
|
|
|
|
|
+
|
|
|
|
|
+ const deleteItemClickedHandler = useCallback(async(pageToDelete, isAbleToDeleteCompletely) => {
|
|
|
|
|
+ openDeleteModal([pageToDelete], onDeletedHandler, isAbleToDeleteCompletely);
|
|
|
|
|
+ }, [onDeletedHandler, openDeleteModal]);
|
|
|
|
|
|
|
|
const templateMenuItemClickHandler = useCallback(() => {
|
|
const templateMenuItemClickHandler = useCallback(() => {
|
|
|
setIsPageTempleteModalShown(true);
|
|
setIsPageTempleteModalShown(true);
|
|
@@ -282,7 +304,6 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
tags={tagsInfoData?.tags || []}
|
|
tags={tagsInfoData?.tags || []}
|
|
|
tagsUpdatedHandler={tagsUpdatedHandler}
|
|
tagsUpdatedHandler={tagsUpdatedHandler}
|
|
|
controls={ControlComponents}
|
|
controls={ControlComponents}
|
|
|
- additionalClasses={['container-fluid']}
|
|
|
|
|
/>
|
|
/>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|