|
|
@@ -1,7 +1,7 @@
|
|
|
import React, { useState, useCallback } from 'react';
|
|
|
+import { useTranslation } from 'react-i18next';
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
-import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
import { DropdownItem } from 'reactstrap';
|
|
|
|
|
|
@@ -13,8 +13,9 @@ import {
|
|
|
} from '~/stores/ui';
|
|
|
import {
|
|
|
usePageAccessoriesModal, PageAccessoriesModalContents,
|
|
|
- usePageDuplicateModal, usePageRenameModal, usePageDeleteModal, usePagePresentationModal,
|
|
|
+ usePageDuplicateModal, usePageRenameModal, usePageDeleteModal, OnDeletedFunction, usePagePresentationModal,
|
|
|
} from '~/stores/modal';
|
|
|
+import { useSWRxPageChildren } from '~/stores/page-listing';
|
|
|
|
|
|
|
|
|
import {
|
|
|
@@ -142,6 +143,7 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
const { data: isAbleToShowPageEditorModeManager } = useIsAbleToShowPageEditorModeManager();
|
|
|
const { data: isAbleToShowPageAuthors } = useIsAbleToShowPageAuthors();
|
|
|
|
|
|
+ const { mutate: mutateChildren } = useSWRxPageChildren(path);
|
|
|
const { mutate: mutateSWRTagsInfo, data: tagsInfoData } = useSWRTagsInfo(pageId);
|
|
|
|
|
|
const { open: openDuplicateModal } = usePageDuplicateModal();
|
|
|
@@ -186,9 +188,27 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
openRenameModal(pageId, revisionId, path);
|
|
|
}, [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(() => {
|
|
|
setIsPageTempleteModalShown(true);
|
|
|
@@ -200,9 +220,11 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
mutateEditorMode(viewType);
|
|
|
}
|
|
|
|
|
|
+ const className = `d-flex flex-column align-items-end justify-content-center ${isViewMode ? ' h-50' : ''}`;
|
|
|
+
|
|
|
return (
|
|
|
<>
|
|
|
- <div className="h-50 d-flex flex-column align-items-end justify-content-center">
|
|
|
+ <div className={className}>
|
|
|
{ pageId != null && isViewMode && (
|
|
|
<SubNavButtons
|
|
|
isCompactMode={isCompactMode}
|
|
|
@@ -227,7 +249,7 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
/>
|
|
|
) }
|
|
|
</div>
|
|
|
- <div className="h-50 d-flex flex-column align-items-end justify-content-center">
|
|
|
+ <div className={className}>
|
|
|
{isAbleToShowPageEditorModeManager && (
|
|
|
<PageEditorModeManager
|
|
|
onPageEditorModeButtonClicked={onPageEditorModeButtonClicked}
|