|
|
@@ -3,7 +3,7 @@ import React, {
|
|
|
} from 'react';
|
|
|
|
|
|
import {
|
|
|
- type IPageInfoExt, isIPageInfoForOperation,
|
|
|
+ type IPageInfoExt, isIPageInfoForOperation, isIPageInfoForEmpty,
|
|
|
} from '@growi/core/dist/interfaces';
|
|
|
import { LoadingSpinner } from '@growi/ui/dist/components';
|
|
|
import { useTranslation } from 'next-i18next';
|
|
|
@@ -84,13 +84,13 @@ const PageItemControlDropdownMenu = React.memo((props: DropdownMenuProps): JSX.E
|
|
|
|
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
|
const renameItemClickedHandler = useCallback(async() => {
|
|
|
- if (onClickRenameMenuItem == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!isIPageInfoForOperation(pageInfo) || !pageInfo?.isMovable) {
|
|
|
+ if (onClickRenameMenuItem == null) return;
|
|
|
+
|
|
|
+ if (!(isIPageInfoForEmpty(pageInfo) || isIPageInfoForOperation(pageInfo)) || !pageInfo?.isMovable) {
|
|
|
logger.warn('This page could not be renamed.');
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
await onClickRenameMenuItem(pageId, pageInfo);
|
|
|
}, [onClickRenameMenuItem, pageId, pageInfo]);
|
|
|
|
|
|
@@ -111,10 +111,9 @@ const PageItemControlDropdownMenu = React.memo((props: DropdownMenuProps): JSX.E
|
|
|
|
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
|
const deleteItemClickedHandler = useCallback(async() => {
|
|
|
- if (pageInfo == null || onClickDeleteMenuItem == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!isIPageInfoForOperation(pageInfo) || !pageInfo?.isDeletable) {
|
|
|
+ if (onClickDeleteMenuItem == null) return;
|
|
|
+
|
|
|
+ if (!(isIPageInfoForEmpty(pageInfo) || isIPageInfoForOperation(pageInfo)) || !pageInfo?.isDeletable) {
|
|
|
logger.warn('This page could not be deleted.');
|
|
|
return;
|
|
|
}
|
|
|
@@ -186,7 +185,8 @@ const PageItemControlDropdownMenu = React.memo((props: DropdownMenuProps): JSX.E
|
|
|
|
|
|
{/* Move/Rename */}
|
|
|
{ !forceHideMenuItems?.includes(MenuItemType.RENAME) && isEnableActions && !isReadOnlyUser
|
|
|
- && isIPageInfoForOperation(pageInfo) && pageInfo.isMovable && (
|
|
|
+ && (isIPageInfoForEmpty(pageInfo) || isIPageInfoForOperation(pageInfo))
|
|
|
+ && pageInfo.isMovable && (
|
|
|
<DropdownItem
|
|
|
onClick={renameItemClickedHandler}
|
|
|
data-testid="rename-page-btn"
|
|
|
@@ -211,7 +211,8 @@ const PageItemControlDropdownMenu = React.memo((props: DropdownMenuProps): JSX.E
|
|
|
|
|
|
{/* Revert */}
|
|
|
{ !forceHideMenuItems?.includes(MenuItemType.REVERT) && isEnableActions && !isReadOnlyUser
|
|
|
- && isIPageInfoForOperation(pageInfo) && pageInfo.isRevertible && (
|
|
|
+ && (isIPageInfoForEmpty(pageInfo) || isIPageInfoForOperation(pageInfo))
|
|
|
+ && pageInfo.isRevertible && (
|
|
|
<DropdownItem
|
|
|
onClick={revertItemClickedHandler}
|
|
|
className="grw-page-control-dropdown-item"
|
|
|
@@ -242,7 +243,8 @@ const PageItemControlDropdownMenu = React.memo((props: DropdownMenuProps): JSX.E
|
|
|
{/* divider */}
|
|
|
{/* Delete */}
|
|
|
{ !forceHideMenuItems?.includes(MenuItemType.DELETE) && isEnableActions && !isReadOnlyUser
|
|
|
- && isIPageInfoForOperation(pageInfo) && pageInfo.isDeletable && (
|
|
|
+ && (isIPageInfoForEmpty(pageInfo) || isIPageInfoForOperation(pageInfo))
|
|
|
+ && pageInfo.isDeletable && (
|
|
|
<>
|
|
|
{ showDeviderBeforeDelete && <DropdownItem divider /> }
|
|
|
<DropdownItem
|