|
@@ -12,7 +12,7 @@ import urljoin from 'url-join';
|
|
|
import { UserPicture, PageListMeta } from '@growi/ui';
|
|
import { UserPicture, PageListMeta } from '@growi/ui';
|
|
|
import { DevidedPagePath } from '@growi/core';
|
|
import { DevidedPagePath } from '@growi/core';
|
|
|
import { useIsDeviceSmallerThanLg } from '~/stores/ui';
|
|
import { useIsDeviceSmallerThanLg } from '~/stores/ui';
|
|
|
-import { usePageRenameModal, usePageDuplicateModal } from '~/stores/modal';
|
|
|
|
|
|
|
+import { usePageRenameModal, usePageDuplicateModal, usePageDeleteModal } from '~/stores/modal';
|
|
|
import {
|
|
import {
|
|
|
IPageInfoAll, IPageWithMeta, isIPageInfoForEntity, isIPageInfoForListing,
|
|
IPageInfoAll, IPageWithMeta, isIPageInfoForEntity, isIPageInfoForListing,
|
|
|
} from '~/interfaces/page';
|
|
} from '~/interfaces/page';
|
|
@@ -30,7 +30,6 @@ type Props = {
|
|
|
showPageUpdatedTime?: boolean, // whether to show page's updated time at the top-right corner of item
|
|
showPageUpdatedTime?: boolean, // whether to show page's updated time at the top-right corner of item
|
|
|
onCheckboxChanged?: (isChecked: boolean, pageId: string) => void,
|
|
onCheckboxChanged?: (isChecked: boolean, pageId: string) => void,
|
|
|
onClickItem?: (pageId: string) => void,
|
|
onClickItem?: (pageId: string) => void,
|
|
|
- onClickDeleteButton?: (pageId: string) => void,
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const PageListItemLSubstance: ForwardRefRenderFunction<ISelectable, Props> = (props: Props, ref): JSX.Element => {
|
|
const PageListItemLSubstance: ForwardRefRenderFunction<ISelectable, Props> = (props: Props, ref): JSX.Element => {
|
|
@@ -62,6 +61,7 @@ const PageListItemLSubstance: ForwardRefRenderFunction<ISelectable, Props> = (pr
|
|
|
const { data: isDeviceSmallerThanLg } = useIsDeviceSmallerThanLg();
|
|
const { data: isDeviceSmallerThanLg } = useIsDeviceSmallerThanLg();
|
|
|
const { open: openDuplicateModal } = usePageDuplicateModal();
|
|
const { open: openDuplicateModal } = usePageDuplicateModal();
|
|
|
const { open: openRenameModal } = usePageRenameModal();
|
|
const { open: openRenameModal } = usePageRenameModal();
|
|
|
|
|
+ const { open: openDeleteModal } = usePageDeleteModal();
|
|
|
|
|
|
|
|
const elasticSearchResult = isIPageSearchMeta(pageMeta) ? pageMeta.elasticSearchResult : null;
|
|
const elasticSearchResult = isIPageSearchMeta(pageMeta) ? pageMeta.elasticSearchResult : null;
|
|
|
const revisionShortBody = isIPageInfoForListing(pageMeta) ? pageMeta.revisionShortBody : null;
|
|
const revisionShortBody = isIPageInfoForListing(pageMeta) ? pageMeta.revisionShortBody : null;
|
|
@@ -94,6 +94,11 @@ const PageListItemLSubstance: ForwardRefRenderFunction<ISelectable, Props> = (pr
|
|
|
openRenameModal(pageId, revisionId as string, path);
|
|
openRenameModal(pageId, revisionId as string, path);
|
|
|
}, [openRenameModal, pageData]);
|
|
}, [openRenameModal, pageData]);
|
|
|
|
|
|
|
|
|
|
+ const deleteMenuItemClickHandler = useCallback(() => {
|
|
|
|
|
+ const { _id: pageId, revision: revisionId, path } = pageData;
|
|
|
|
|
+ openDeleteModal([{ pageId, revisionId: revisionId as string, path }]);
|
|
|
|
|
+ }, [openDeleteModal, pageData]);
|
|
|
|
|
+
|
|
|
const styleListGroupItem = (!isDeviceSmallerThanLg && onClickItem != null) ? 'list-group-item-action' : '';
|
|
const styleListGroupItem = (!isDeviceSmallerThanLg && onClickItem != null) ? 'list-group-item-action' : '';
|
|
|
// background color of list item changes when class "active" exists under 'list-group-item'
|
|
// background color of list item changes when class "active" exists under 'list-group-item'
|
|
|
const styleActive = !isDeviceSmallerThanLg && isSelected ? 'active' : '';
|
|
const styleActive = !isDeviceSmallerThanLg && isSelected ? 'active' : '';
|
|
@@ -156,7 +161,7 @@ const PageListItemLSubstance: ForwardRefRenderFunction<ISelectable, Props> = (pr
|
|
|
<PageItemControl
|
|
<PageItemControl
|
|
|
pageId={pageData._id}
|
|
pageId={pageData._id}
|
|
|
pageInfo={pageMeta}
|
|
pageInfo={pageMeta}
|
|
|
- onClickDeleteMenuItem={props.onClickDeleteButton}
|
|
|
|
|
|
|
+ onClickDeleteMenuItem={deleteMenuItemClickHandler}
|
|
|
onClickRenameMenuItem={renameMenuItemClickHandler}
|
|
onClickRenameMenuItem={renameMenuItemClickHandler}
|
|
|
isEnableActions={isEnableActions}
|
|
isEnableActions={isEnableActions}
|
|
|
onClickDuplicateMenuItem={duplicateMenuItemClickHandler}
|
|
onClickDuplicateMenuItem={duplicateMenuItemClickHandler}
|