|
|
@@ -1,6 +1,6 @@
|
|
|
import React, { useState, useEffect, useCallback } from 'react';
|
|
|
|
|
|
-import { isPopulated } from '@growi/core';
|
|
|
+import { isPopulated, IUser } from '@growi/core';
|
|
|
import { useTranslation } from 'next-i18next';
|
|
|
import dynamic from 'next/dynamic';
|
|
|
import { DropdownItem } from 'reactstrap';
|
|
|
@@ -39,9 +39,13 @@ import { Skelton } from '../Skelton';
|
|
|
import { GrowiSubNavigation } from './GrowiSubNavigation';
|
|
|
import { SubNavButtonsProps } from './SubNavButtons';
|
|
|
|
|
|
+import AuthorInfoStyles from './AuthorInfo.module.scss';
|
|
|
import PageEditorModeManagerStyles from './PageEditorModeManager.module.scss';
|
|
|
|
|
|
|
|
|
+const AuthorInfoSkelton = () => <Skelton additionalClass={`${AuthorInfoStyles['grw-author-info-skelton']} py-1`} />;
|
|
|
+
|
|
|
+
|
|
|
const PageEditorModeManager = dynamic(
|
|
|
() => import('./PageEditorModeManager'),
|
|
|
{ ssr: false, loading: () => <Skelton additionalClass={`${PageEditorModeManagerStyles['grw-page-editor-mode-manager-skelton']}`} /> },
|
|
|
@@ -52,7 +56,10 @@ const SubNavButtons = dynamic<SubNavButtonsProps>(
|
|
|
() => import('./SubNavButtons').then(mod => mod.SubNavButtons),
|
|
|
{ ssr: false, loading: () => <></> },
|
|
|
);
|
|
|
-
|
|
|
+const AuthorInfo = dynamic(() => import('./AuthorInfo'), {
|
|
|
+ ssr: false,
|
|
|
+ loading: AuthorInfoSkelton,
|
|
|
+});
|
|
|
|
|
|
type AdditionalMenuItemsProps = {
|
|
|
pageId: string,
|
|
|
@@ -312,34 +319,53 @@ const GrowiContextualSubNavigation = (props: GrowiContextualSubNavigationProps):
|
|
|
|
|
|
return (
|
|
|
<>
|
|
|
- <div className="d-flex flex-column align-items-end justify-content-center py-md-2" style={{ gap: `${isCompactMode ? '5px' : '7px'}` }}>
|
|
|
- { isViewMode && (
|
|
|
- <div className="h-50 w-100">
|
|
|
- { pageId != null && (
|
|
|
- <SubNavButtons
|
|
|
- isCompactMode={isCompactMode}
|
|
|
- pageId={pageId}
|
|
|
- revisionId={revisionId}
|
|
|
- shareLinkId={shareLinkId}
|
|
|
- path={path}
|
|
|
- disableSeenUserInfoPopover={isSharedUser}
|
|
|
- showPageControlDropdown={isAbleToShowPageManagement}
|
|
|
- additionalMenuItemRenderer={additionalMenuItemsRenderer}
|
|
|
- onClickDuplicateMenuItem={duplicateItemClickedHandler}
|
|
|
- onClickRenameMenuItem={renameItemClickedHandler}
|
|
|
- onClickDeleteMenuItem={deleteItemClickedHandler}
|
|
|
- />
|
|
|
- ) }
|
|
|
- </div>
|
|
|
+ <div className="d-flex">
|
|
|
+ <div className="d-flex flex-column align-items-end justify-content-center py-md-2" style={{ gap: `${isCompactMode ? '5px' : '7px'}` }}>
|
|
|
+ { isViewMode && (
|
|
|
+ <div className="h-50 w-100">
|
|
|
+ { pageId != null && (
|
|
|
+ <SubNavButtons
|
|
|
+ isCompactMode={isCompactMode}
|
|
|
+ pageId={pageId}
|
|
|
+ revisionId={revisionId}
|
|
|
+ shareLinkId={shareLinkId}
|
|
|
+ path={path}
|
|
|
+ disableSeenUserInfoPopover={isSharedUser}
|
|
|
+ showPageControlDropdown={isAbleToShowPageManagement}
|
|
|
+ additionalMenuItemRenderer={additionalMenuItemsRenderer}
|
|
|
+ onClickDuplicateMenuItem={duplicateItemClickedHandler}
|
|
|
+ onClickRenameMenuItem={renameItemClickedHandler}
|
|
|
+ onClickDeleteMenuItem={deleteItemClickedHandler}
|
|
|
+ />
|
|
|
+ ) }
|
|
|
+ </div>
|
|
|
+ ) }
|
|
|
+ {isAbleToShowPageEditorModeManager && (
|
|
|
+ <PageEditorModeManager
|
|
|
+ onPageEditorModeButtonClicked={viewType => mutateEditorMode(viewType)}
|
|
|
+ isBtnDisabled={isGuestUser}
|
|
|
+ editorMode={editorMode}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ { (isAbleToShowPageAuthors && !isCompactMode) && (
|
|
|
+ <ul className={`${AuthorInfoStyles['grw-author-info']} text-nowrap border-left d-none d-lg-block d-edit-none py-2 pl-4 mb-0 ml-3`}>
|
|
|
+ <li className="pb-1">
|
|
|
+ { currentPage != null
|
|
|
+ ? <AuthorInfo user={currentPage.creator as IUser} date={currentPage.createdAt} locate="subnav" />
|
|
|
+ : <AuthorInfoSkelton />
|
|
|
+ }
|
|
|
+ </li>
|
|
|
+ <li className="mt-1 pt-1 border-top">
|
|
|
+ { currentPage != null
|
|
|
+ ? <AuthorInfo user={currentPage.lastUpdateUser as IUser} date={currentPage.updatedAt} mode="update" locate="subnav" />
|
|
|
+ : <AuthorInfoSkelton />
|
|
|
+ }
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
) }
|
|
|
- {isAbleToShowPageEditorModeManager && (
|
|
|
- <PageEditorModeManager
|
|
|
- onPageEditorModeButtonClicked={viewType => mutateEditorMode(viewType)}
|
|
|
- isBtnDisabled={isGuestUser}
|
|
|
- editorMode={editorMode}
|
|
|
- />
|
|
|
- )}
|
|
|
</div>
|
|
|
+
|
|
|
{path != null && currentUser != null && (
|
|
|
<CreateTemplateModal
|
|
|
path={path}
|
|
|
@@ -350,7 +376,7 @@ const GrowiContextualSubNavigation = (props: GrowiContextualSubNavigationProps):
|
|
|
</>
|
|
|
);
|
|
|
// eslint-disable-next-line max-len
|
|
|
- }, [currentUser, pageId, revisionId, shareLinkId, path, editorMode, isCompactMode, isViewMode, isSharedUser, isAbleToShowPageManagement, isAbleToShowPageEditorModeManager, isLinkSharingDisabled, isGuestUser, isPageTemplateModalShown, duplicateItemClickedHandler, renameItemClickedHandler, deleteItemClickedHandler, mutateEditorMode, templateMenuItemClickHandler]);
|
|
|
+ }, [isCompactMode, isViewMode, pageId, revisionId, shareLinkId, path, isSharedUser, isAbleToShowPageManagement, duplicateItemClickedHandler, renameItemClickedHandler, deleteItemClickedHandler, isAbleToShowPageEditorModeManager, isGuestUser, editorMode, isAbleToShowPageAuthors, currentPage, currentUser, isPageTemplateModalShown, isLinkSharingDisabled, templateMenuItemClickHandler, mutateEditorMode]);
|
|
|
|
|
|
return (
|
|
|
<GrowiSubNavigation
|
|
|
@@ -358,7 +384,6 @@ const GrowiContextualSubNavigation = (props: GrowiContextualSubNavigationProps):
|
|
|
pageId={currentPage?._id}
|
|
|
showDrawerToggler={isDrawerMode}
|
|
|
showTagLabel={isAbleToShowTagLabel}
|
|
|
- showPageAuthors={isAbleToShowPageAuthors}
|
|
|
isGuestUser={isGuestUser}
|
|
|
isDrawerMode={isDrawerMode}
|
|
|
isCompactMode={isCompactMode}
|