|
@@ -24,13 +24,13 @@ import {
|
|
|
OnDuplicatedFunction, OnRenamedFunction, OnDeletedFunction, OnPutBackedFunction,
|
|
OnDuplicatedFunction, OnRenamedFunction, OnDeletedFunction, OnPutBackedFunction,
|
|
|
} from '~/interfaces/ui';
|
|
} from '~/interfaces/ui';
|
|
|
import LinkedPagePath from '~/models/linked-page-path';
|
|
import LinkedPagePath from '~/models/linked-page-path';
|
|
|
-import { useSWRBookmarkInfo, useSWRxUserBookmarks } from '~/stores/bookmark';
|
|
|
|
|
|
|
+import { useSWRMUTxCurrentUserBookmarks } from '~/stores/bookmark';
|
|
|
import {
|
|
import {
|
|
|
usePageRenameModal, usePageDuplicateModal, usePageDeleteModal, usePutBackPageModal,
|
|
usePageRenameModal, usePageDuplicateModal, usePageDeleteModal, usePutBackPageModal,
|
|
|
} from '~/stores/modal';
|
|
} from '~/stores/modal';
|
|
|
import { useIsDeviceSmallerThanLg } from '~/stores/ui';
|
|
import { useIsDeviceSmallerThanLg } from '~/stores/ui';
|
|
|
|
|
|
|
|
-import { useSWRxPageInfo } from '../../stores/page';
|
|
|
|
|
|
|
+import { useSWRMUTxPageInfo, useSWRxPageInfo } from '../../stores/page';
|
|
|
import { ForceHideMenuItems, PageItemControl } from '../Common/Dropdown/PageItemControl';
|
|
import { ForceHideMenuItems, PageItemControl } from '../Common/Dropdown/PageItemControl';
|
|
|
import PagePathHierarchicalLink from '../PagePathHierarchicalLink';
|
|
import PagePathHierarchicalLink from '../PagePathHierarchicalLink';
|
|
|
import { useCurrentUser } from '~/stores/context';
|
|
import { useCurrentUser } from '~/stores/context';
|
|
@@ -94,10 +94,8 @@ const PageListItemLSubstance: ForwardRefRenderFunction<ISelectable, Props> = (pr
|
|
|
const { data: currentUser } = useCurrentUser();
|
|
const { data: currentUser } = useCurrentUser();
|
|
|
const shouldFetch = isSelected && (pageData != null || pageMeta != null);
|
|
const shouldFetch = isSelected && (pageData != null || pageMeta != null);
|
|
|
const { data: pageInfo } = useSWRxPageInfo(shouldFetch ? pageData?._id : null);
|
|
const { data: pageInfo } = useSWRxPageInfo(shouldFetch ? pageData?._id : null);
|
|
|
- const { mutate: mutateUserBookmark } = useSWRxUserBookmarks(currentUser?._id);
|
|
|
|
|
- const { mutate: mutateBookmarkInfo } = useSWRBookmarkInfo(pageData?._id);
|
|
|
|
|
- const { mutate: mutatePageInfo } = useSWRxPageInfo(pageData._id);
|
|
|
|
|
- const { mutate: mutateBookmarkFolders } = useSWRxBookmarkFolderAndChild(currentUser?._id);
|
|
|
|
|
|
|
+ const { trigger: mutatePageInfo } = useSWRMUTxPageInfo(pageData?._id ?? null);
|
|
|
|
|
+ const { trigger: mutateCurrentUserBookmarks } = useSWRMUTxCurrentUserBookmarks();
|
|
|
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;
|
|
|
|
|
|
|
@@ -131,11 +129,11 @@ const PageListItemLSubstance: ForwardRefRenderFunction<ISelectable, Props> = (pr
|
|
|
}
|
|
}
|
|
|
}, [isDeviceSmallerThanLg, onClickItem, pageData._id]);
|
|
}, [isDeviceSmallerThanLg, onClickItem, pageData._id]);
|
|
|
|
|
|
|
|
- const bookmarkMenuItemClickHandler = async(_pageId: string, _newValue: boolean): Promise<void> => {
|
|
|
|
|
|
|
+ const bookmarkMenuItemClickHandler = async (_pageId: string, _newValue: boolean): Promise<void> => {
|
|
|
const bookmarkOperation = _newValue ? bookmark : unbookmark;
|
|
const bookmarkOperation = _newValue ? bookmark : unbookmark;
|
|
|
await bookmarkOperation(_pageId);
|
|
await bookmarkOperation(_pageId);
|
|
|
- mutateUserBookmark();
|
|
|
|
|
- mutateBookmarkInfo();
|
|
|
|
|
|
|
+ mutateCurrentUserBookmarks();
|
|
|
|
|
+ mutatePageInfo();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const duplicateMenuItemClickHandler = useCallback(() => {
|
|
const duplicateMenuItemClickHandler = useCallback(() => {
|
|
@@ -159,10 +157,10 @@ const PageListItemLSubstance: ForwardRefRenderFunction<ISelectable, Props> = (pr
|
|
|
openDeleteModal([pageToDelete], { onDeleted: onPageDeleted });
|
|
openDeleteModal([pageToDelete], { onDeleted: onPageDeleted });
|
|
|
}, [pageData, openDeleteModal, onPageDeleted]);
|
|
}, [pageData, openDeleteModal, onPageDeleted]);
|
|
|
|
|
|
|
|
- const revertMenuItemClickHandler = useCallback(async() => {
|
|
|
|
|
|
|
+ const revertMenuItemClickHandler = useCallback(async () => {
|
|
|
const { _id: pageId, path } = pageData;
|
|
const { _id: pageId, path } = pageData;
|
|
|
|
|
|
|
|
- const putBackedHandler = async(path) => {
|
|
|
|
|
|
|
+ const putBackedHandler = async (path) => {
|
|
|
try {
|
|
try {
|
|
|
// pageData path should be `/trash/fuga` (`/trash` should be included to the prefix)
|
|
// pageData path should be `/trash/fuga` (`/trash` should be included to the prefix)
|
|
|
await unlink(pageData.path);
|
|
await unlink(pageData.path);
|
|
@@ -224,9 +222,9 @@ const PageListItemLSubstance: ForwardRefRenderFunction<ISelectable, Props> = (pr
|
|
|
linkedPagePath={linkedPagePathFormer}
|
|
linkedPagePath={linkedPagePathFormer}
|
|
|
linkedPagePathByHtml={linkedPagePathHighlightedFormer}
|
|
linkedPagePathByHtml={linkedPagePathHighlightedFormer}
|
|
|
/>
|
|
/>
|
|
|
- { showPageUpdatedTime && (
|
|
|
|
|
|
|
+ {showPageUpdatedTime && (
|
|
|
<span className="page-list-updated-at text-muted">Last update: {lastUpdateDate}</span>
|
|
<span className="page-list-updated-at text-muted">Last update: {lastUpdateDate}</span>
|
|
|
- ) }
|
|
|
|
|
|
|
+ )}
|
|
|
</div>
|
|
</div>
|
|
|
<div className="d-flex align-items-center mb-1">
|
|
<div className="d-flex align-items-center mb-1">
|
|
|
{/* Picture */}
|
|
{/* Picture */}
|
|
@@ -265,32 +263,32 @@ const PageListItemLSubstance: ForwardRefRenderFunction<ISelectable, Props> = (pr
|
|
|
|
|
|
|
|
{/* doropdown icon includes page control buttons */}
|
|
{/* doropdown icon includes page control buttons */}
|
|
|
{hasBrowsingRights
|
|
{hasBrowsingRights
|
|
|
- && <div className="ml-auto">
|
|
|
|
|
- <PageItemControl
|
|
|
|
|
- alignRight
|
|
|
|
|
- pageId={pageData._id}
|
|
|
|
|
- pageInfo={isIPageInfoForListing(pageMeta) ? pageMeta : undefined}
|
|
|
|
|
- isEnableActions={isEnableActions}
|
|
|
|
|
- isReadOnlyUser={isReadOnlyUser}
|
|
|
|
|
- forceHideMenuItems={forceHideMenuItems}
|
|
|
|
|
- onClickBookmarkMenuItem={bookmarkMenuItemClickHandler}
|
|
|
|
|
- onClickRenameMenuItem={renameMenuItemClickHandler}
|
|
|
|
|
- onClickDuplicateMenuItem={duplicateMenuItemClickHandler}
|
|
|
|
|
- onClickDeleteMenuItem={deleteMenuItemClickHandler}
|
|
|
|
|
- onClickRevertMenuItem={revertMenuItemClickHandler}
|
|
|
|
|
- />
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ && <div className="ml-auto">
|
|
|
|
|
+ <PageItemControl
|
|
|
|
|
+ alignRight
|
|
|
|
|
+ pageId={pageData._id}
|
|
|
|
|
+ pageInfo={isIPageInfoForListing(pageMeta) ? pageMeta : undefined}
|
|
|
|
|
+ isEnableActions={isEnableActions}
|
|
|
|
|
+ isReadOnlyUser={isReadOnlyUser}
|
|
|
|
|
+ forceHideMenuItems={forceHideMenuItems}
|
|
|
|
|
+ onClickBookmarkMenuItem={bookmarkMenuItemClickHandler}
|
|
|
|
|
+ onClickRenameMenuItem={renameMenuItemClickHandler}
|
|
|
|
|
+ onClickDuplicateMenuItem={duplicateMenuItemClickHandler}
|
|
|
|
|
+ onClickDeleteMenuItem={deleteMenuItemClickHandler}
|
|
|
|
|
+ onClickRevertMenuItem={revertMenuItemClickHandler}
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
}
|
|
}
|
|
|
</div>
|
|
</div>
|
|
|
<div className="page-list-snippet py-1">
|
|
<div className="page-list-snippet py-1">
|
|
|
<Clamp lines={2}>
|
|
<Clamp lines={2}>
|
|
|
- { elasticSearchResult != null && elasticSearchResult.snippet != null && (
|
|
|
|
|
|
|
+ {elasticSearchResult != null && elasticSearchResult.snippet != null && (
|
|
|
// eslint-disable-next-line react/no-danger
|
|
// eslint-disable-next-line react/no-danger
|
|
|
<div dangerouslySetInnerHTML={{ __html: elasticSearchResult.snippet }}></div>
|
|
<div dangerouslySetInnerHTML={{ __html: elasticSearchResult.snippet }}></div>
|
|
|
- ) }
|
|
|
|
|
- { revisionShortBody != null && (
|
|
|
|
|
|
|
+ )}
|
|
|
|
|
+ {revisionShortBody != null && (
|
|
|
<div data-testid="revision-short-body-in-page-list-item-L">{revisionShortBody}</div>
|
|
<div data-testid="revision-short-body-in-page-list-item-L">{revisionShortBody}</div>
|
|
|
- ) }
|
|
|
|
|
|
|
+ )}
|
|
|
{
|
|
{
|
|
|
!hasBrowsingRights && (
|
|
!hasBrowsingRights && (
|
|
|
<>
|
|
<>
|