|
@@ -6,7 +6,9 @@ import Item from './Item';
|
|
|
import { useSWRxPageAncestorsChildren, useSWRxRootPage } from '../../../stores/page-listing';
|
|
import { useSWRxPageAncestorsChildren, useSWRxRootPage } from '../../../stores/page-listing';
|
|
|
import { TargetAndAncestors } from '~/interfaces/page-listing-results';
|
|
import { TargetAndAncestors } from '~/interfaces/page-listing-results';
|
|
|
import { toastError } from '~/client/util/apiNotification';
|
|
import { toastError } from '~/client/util/apiNotification';
|
|
|
-import { IPageForPageDeleteModal, usePageDuplicateModalStatus, usePageDeleteModalStatus } from '~/stores/ui';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ IPageForPageDeleteModal, usePageDuplicateModalStatus, usePageRenameModalStatus, usePageDeleteModalStatus,
|
|
|
|
|
+} from '~/stores/ui';
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
* Utility to generate initial node
|
|
* Utility to generate initial node
|
|
@@ -59,6 +61,7 @@ const renderByInitialNode = (
|
|
|
isEnableActions: boolean,
|
|
isEnableActions: boolean,
|
|
|
targetPathOrId?: string,
|
|
targetPathOrId?: string,
|
|
|
onClickDuplicateMenuItem?: (pageId: string, path: string) => void,
|
|
onClickDuplicateMenuItem?: (pageId: string, path: string) => void,
|
|
|
|
|
+ onClickRenameMenuItem?: (pageId: string, reevisionId: string, path: string) => void,
|
|
|
onClickDeleteByPage?: (pageToDelete: IPageForPageDeleteModal | null) => void,
|
|
onClickDeleteByPage?: (pageToDelete: IPageForPageDeleteModal | null) => void,
|
|
|
): JSX.Element => {
|
|
): JSX.Element => {
|
|
|
|
|
|
|
@@ -71,6 +74,7 @@ const renderByInitialNode = (
|
|
|
isOpen
|
|
isOpen
|
|
|
isEnableActions={isEnableActions}
|
|
isEnableActions={isEnableActions}
|
|
|
onClickDuplicateMenuItem={onClickDuplicateMenuItem}
|
|
onClickDuplicateMenuItem={onClickDuplicateMenuItem}
|
|
|
|
|
+ onClickRenameMenuItem={onClickRenameMenuItem}
|
|
|
onClickDeleteByPage={onClickDeleteByPage}
|
|
onClickDeleteByPage={onClickDeleteByPage}
|
|
|
/>
|
|
/>
|
|
|
</ul>
|
|
</ul>
|
|
@@ -89,12 +93,17 @@ const ItemsTree: FC<ItemsTreeProps> = (props: ItemsTreeProps) => {
|
|
|
const { data: ancestorsChildrenData, error: error1 } = useSWRxPageAncestorsChildren(targetPath);
|
|
const { data: ancestorsChildrenData, error: error1 } = useSWRxPageAncestorsChildren(targetPath);
|
|
|
const { data: rootPageData, error: error2 } = useSWRxRootPage();
|
|
const { data: rootPageData, error: error2 } = useSWRxRootPage();
|
|
|
const { open: openDuplicateModal } = usePageDuplicateModalStatus();
|
|
const { open: openDuplicateModal } = usePageDuplicateModalStatus();
|
|
|
|
|
+ const { open: openRenameModal } = usePageRenameModalStatus();
|
|
|
const { open: openDeleteModal } = usePageDeleteModalStatus();
|
|
const { open: openDeleteModal } = usePageDeleteModalStatus();
|
|
|
|
|
|
|
|
const onClickDuplicateMenuItem = (pageId: string, path: string) => {
|
|
const onClickDuplicateMenuItem = (pageId: string, path: string) => {
|
|
|
openDuplicateModal(pageId, path);
|
|
openDuplicateModal(pageId, path);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ const onClickRenameMenuItem = (pageId: string, revisionId: string, path: string) => {
|
|
|
|
|
+ openRenameModal(pageId, revisionId, path);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
const onClickDeleteByPage = (pageToDelete: IPageForPageDeleteModal) => {
|
|
const onClickDeleteByPage = (pageToDelete: IPageForPageDeleteModal) => {
|
|
|
openDeleteModal([pageToDelete]);
|
|
openDeleteModal([pageToDelete]);
|
|
|
};
|
|
};
|
|
@@ -110,7 +119,7 @@ const ItemsTree: FC<ItemsTreeProps> = (props: ItemsTreeProps) => {
|
|
|
*/
|
|
*/
|
|
|
if (ancestorsChildrenData != null && rootPageData != null) {
|
|
if (ancestorsChildrenData != null && rootPageData != null) {
|
|
|
const initialNode = generateInitialNodeAfterResponse(ancestorsChildrenData.ancestorsChildren, new ItemNode(rootPageData.rootPage));
|
|
const initialNode = generateInitialNodeAfterResponse(ancestorsChildrenData.ancestorsChildren, new ItemNode(rootPageData.rootPage));
|
|
|
- return renderByInitialNode(initialNode, isEnableActions, targetPathOrId, onClickDuplicateMenuItem, onClickDeleteByPage);
|
|
|
|
|
|
|
+ return renderByInitialNode(initialNode, isEnableActions, targetPathOrId, onClickDuplicateMenuItem, onClickRenameMenuItem, onClickDeleteByPage);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -118,7 +127,7 @@ const ItemsTree: FC<ItemsTreeProps> = (props: ItemsTreeProps) => {
|
|
|
*/
|
|
*/
|
|
|
if (targetAndAncestorsData != null) {
|
|
if (targetAndAncestorsData != null) {
|
|
|
const initialNode = generateInitialNodeBeforeResponse(targetAndAncestorsData.targetAndAncestors);
|
|
const initialNode = generateInitialNodeBeforeResponse(targetAndAncestorsData.targetAndAncestors);
|
|
|
- return renderByInitialNode(initialNode, isEnableActions, targetPathOrId, onClickDuplicateMenuItem, onClickDeleteByPage);
|
|
|
|
|
|
|
+ return renderByInitialNode(initialNode, isEnableActions, targetPathOrId, onClickDuplicateMenuItem, onClickRenameMenuItem, onClickDeleteByPage);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
return null;
|