|
@@ -2,10 +2,11 @@ import React, { memo, useCallback } from 'react';
|
|
|
|
|
|
|
|
import Clamp from 'react-multiline-clamp';
|
|
import Clamp from 'react-multiline-clamp';
|
|
|
import { format } from 'date-fns';
|
|
import { format } from 'date-fns';
|
|
|
|
|
+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, usePageRenameModalStatus, usePageDuplicateModalStatus } from '~/stores/ui';
|
|
|
import {
|
|
import {
|
|
|
IPageInfoAll, IPageWithMeta, isIPageInfoForEntity, isIPageInfoForListing,
|
|
IPageInfoAll, IPageWithMeta, isIPageInfoForEntity, isIPageInfoForListing,
|
|
|
} from '~/interfaces/page';
|
|
} from '~/interfaces/page';
|
|
@@ -34,6 +35,8 @@ export const PageListItemL = memo((props: Props): JSX.Element => {
|
|
|
} = props;
|
|
} = props;
|
|
|
|
|
|
|
|
const { data: isDeviceSmallerThanLg } = useIsDeviceSmallerThanLg();
|
|
const { data: isDeviceSmallerThanLg } = useIsDeviceSmallerThanLg();
|
|
|
|
|
+ const { open: openDuplicateModal } = usePageDuplicateModalStatus();
|
|
|
|
|
+ const { open: openRenameModal } = usePageRenameModalStatus();
|
|
|
|
|
|
|
|
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;
|
|
@@ -56,6 +59,16 @@ export const PageListItemL = memo((props: Props): JSX.Element => {
|
|
|
}
|
|
}
|
|
|
}, [isDeviceSmallerThanLg, onClickItem, pageData._id]);
|
|
}, [isDeviceSmallerThanLg, onClickItem, pageData._id]);
|
|
|
|
|
|
|
|
|
|
+ const duplicateMenuItemClickHandler = useCallback(() => {
|
|
|
|
|
+ const { _id: pageId, path } = pageData;
|
|
|
|
|
+ openDuplicateModal(pageId, path);
|
|
|
|
|
+ }, [openDuplicateModal, pageData]);
|
|
|
|
|
+
|
|
|
|
|
+ const renameMenuItemClickHandler = useCallback(() => {
|
|
|
|
|
+ const { _id: pageId, revision: revisionId, path } = pageData;
|
|
|
|
|
+ openRenameModal(pageId, revisionId as string, path);
|
|
|
|
|
+ }, [openRenameModal, pageData]);
|
|
|
|
|
+
|
|
|
const styleListGroupItem = (!isDeviceSmallerThanLg && onClickCheckbox != null) ? 'list-group-item-action' : '';
|
|
const styleListGroupItem = (!isDeviceSmallerThanLg && onClickCheckbox != 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' : '';
|
|
@@ -99,7 +112,10 @@ export const PageListItemL = memo((props: Props): JSX.Element => {
|
|
|
{/* page title */}
|
|
{/* page title */}
|
|
|
<Clamp lines={1}>
|
|
<Clamp lines={1}>
|
|
|
<span className="h5 mb-0">
|
|
<span className="h5 mb-0">
|
|
|
- <PagePathHierarchicalLink linkedPagePath={linkedPagePathLatter} basePath={dPagePath.former} />
|
|
|
|
|
|
|
+ {/* Use permanent links to care for pages with the same name (Cannot use page path url) */}
|
|
|
|
|
+ <span className="grw-page-path-hierarchical-link text-break">
|
|
|
|
|
+ <a className="page-segment" href={encodeURI(urljoin('/', pageData._id))}>{linkedPagePathLatter.pathName}</a>
|
|
|
|
|
+ </span>
|
|
|
</span>
|
|
</span>
|
|
|
</Clamp>
|
|
</Clamp>
|
|
|
|
|
|
|
@@ -116,7 +132,9 @@ export const PageListItemL = memo((props: Props): JSX.Element => {
|
|
|
pageId={pageData._id}
|
|
pageId={pageData._id}
|
|
|
pageInfo={pageMeta}
|
|
pageInfo={pageMeta}
|
|
|
onClickDeleteMenuItem={props.onClickDeleteButton}
|
|
onClickDeleteMenuItem={props.onClickDeleteButton}
|
|
|
|
|
+ onClickRenameMenuItem={renameMenuItemClickHandler}
|
|
|
isEnableActions={isEnableActions}
|
|
isEnableActions={isEnableActions}
|
|
|
|
|
+ onClickDuplicateMenuItem={duplicateMenuItemClickHandler}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|