|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useCallback } from 'react';
|
|
|
|
|
|
|
+import React, { useState, useCallback } from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useTranslation } from 'react-i18next';
|
|
@@ -9,12 +9,17 @@ import { withUnstatedContainers } from '../UnstatedUtils';
|
|
|
import EditorContainer from '~/client/services/EditorContainer';
|
|
import EditorContainer from '~/client/services/EditorContainer';
|
|
|
import {
|
|
import {
|
|
|
EditorMode, useDrawerMode, useEditorMode, useIsDeviceSmallerThanMd, useIsAbleToShowPageManagement, useIsAbleToShowTagLabel,
|
|
EditorMode, useDrawerMode, useEditorMode, useIsDeviceSmallerThanMd, useIsAbleToShowPageManagement, useIsAbleToShowTagLabel,
|
|
|
- useIsAbleToShowPageEditorModeManager, useIsAbleToShowPageAuthors, usePageAccessoriesModal, PageAccessoriesModalContents,
|
|
|
|
|
- usePageRenameModalStatus, usePageDeleteModal,
|
|
|
|
|
|
|
+ useIsAbleToShowPageEditorModeManager, useIsAbleToShowPageAuthors,
|
|
|
} from '~/stores/ui';
|
|
} from '~/stores/ui';
|
|
|
|
|
+import {
|
|
|
|
|
+ usePageAccessoriesModal, PageAccessoriesModalContents,
|
|
|
|
|
+ usePageDuplicateModal, usePageRenameModal, usePageDeleteModal, usePagePresentationModal,
|
|
|
|
|
+} from '~/stores/modal';
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
import {
|
|
import {
|
|
|
useCurrentCreatedAt, useCurrentUpdatedAt, useCurrentPageId, useRevisionId, useCurrentPagePath,
|
|
useCurrentCreatedAt, useCurrentUpdatedAt, useCurrentPageId, useRevisionId, useCurrentPagePath,
|
|
|
- useCreator, useRevisionAuthor, useIsGuestUser, useIsSharedUser, useShareLinkId,
|
|
|
|
|
|
|
+ useCreator, useRevisionAuthor, useCurrentUser, useIsGuestUser, useIsSharedUser, useShareLinkId,
|
|
|
} from '~/stores/context';
|
|
} from '~/stores/context';
|
|
|
import { useSWRTagsInfo } from '~/stores/page';
|
|
import { useSWRTagsInfo } from '~/stores/page';
|
|
|
|
|
|
|
@@ -31,6 +36,7 @@ import { SubNavButtons } from './SubNavButtons';
|
|
|
import PageEditorModeManager from './PageEditorModeManager';
|
|
import PageEditorModeManager from './PageEditorModeManager';
|
|
|
import { GrowiSubNavigation } from './GrowiSubNavigation';
|
|
import { GrowiSubNavigation } from './GrowiSubNavigation';
|
|
|
import PresentationIcon from '../Icons/PresentationIcon';
|
|
import PresentationIcon from '../Icons/PresentationIcon';
|
|
|
|
|
+import CreateTemplateModal from '../CreateTemplateModal';
|
|
|
import { exportAsMarkdown } from '~/client/services/page-operation';
|
|
import { exportAsMarkdown } from '~/client/services/page-operation';
|
|
|
|
|
|
|
|
|
|
|
|
@@ -38,22 +44,33 @@ type AdditionalMenuItemsProps = AdditionalMenuItemsRendererProps & {
|
|
|
pageId: string,
|
|
pageId: string,
|
|
|
revisionId: string,
|
|
revisionId: string,
|
|
|
isLinkSharingDisabled?: boolean,
|
|
isLinkSharingDisabled?: boolean,
|
|
|
|
|
+ onClickTemplateMenuItem: (isPageTemplateModalShown: boolean) => void,
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const AdditionalMenuItems = (props: AdditionalMenuItemsProps): JSX.Element => {
|
|
const AdditionalMenuItems = (props: AdditionalMenuItemsProps): JSX.Element => {
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
- const { pageId, revisionId, isLinkSharingDisabled } = props;
|
|
|
|
|
|
|
+ const {
|
|
|
|
|
+ pageId, revisionId, isLinkSharingDisabled, onClickTemplateMenuItem,
|
|
|
|
|
+ } = props;
|
|
|
|
|
+
|
|
|
|
|
+ const openPageTemplateModalHandler = () => {
|
|
|
|
|
+ onClickTemplateMenuItem(true);
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
const { data: isGuestUser } = useIsGuestUser();
|
|
const { data: isGuestUser } = useIsGuestUser();
|
|
|
const { data: isSharedUser } = useIsSharedUser();
|
|
const { data: isSharedUser } = useIsSharedUser();
|
|
|
|
|
|
|
|
- const { open } = usePageAccessoriesModal();
|
|
|
|
|
|
|
+ const { open: openPresentationModal } = usePagePresentationModal();
|
|
|
|
|
+ const { open: openAccessoriesModal } = usePageAccessoriesModal();
|
|
|
|
|
+
|
|
|
|
|
+ const hrefForPresentationModal = '?presentation=1';
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
{/* Presentation */}
|
|
{/* Presentation */}
|
|
|
- <DropdownItem onClick={() => { /* TODO: implement in https://redmine.weseek.co.jp/issues/87672 */ }}>
|
|
|
|
|
|
|
+ <DropdownItem onClick={() => openPresentationModal(hrefForPresentationModal)}>
|
|
|
<i className="icon-fw"><PresentationIcon /></i>
|
|
<i className="icon-fw"><PresentationIcon /></i>
|
|
|
{ t('Presentation Mode') }
|
|
{ t('Presentation Mode') }
|
|
|
</DropdownItem>
|
|
</DropdownItem>
|
|
@@ -71,7 +88,7 @@ const AdditionalMenuItems = (props: AdditionalMenuItemsProps): JSX.Element => {
|
|
|
refs: PageAccessoriesModalControl
|
|
refs: PageAccessoriesModalControl
|
|
|
*/}
|
|
*/}
|
|
|
<DropdownItem
|
|
<DropdownItem
|
|
|
- onClick={() => open(PageAccessoriesModalContents.PageHistory)}
|
|
|
|
|
|
|
+ onClick={() => openAccessoriesModal(PageAccessoriesModalContents.PageHistory)}
|
|
|
disabled={isGuestUser || isSharedUser}
|
|
disabled={isGuestUser || isSharedUser}
|
|
|
>
|
|
>
|
|
|
<span className="mr-1"><HistoryIcon /></span>
|
|
<span className="mr-1"><HistoryIcon /></span>
|
|
@@ -79,14 +96,14 @@ const AdditionalMenuItems = (props: AdditionalMenuItemsProps): JSX.Element => {
|
|
|
</DropdownItem>
|
|
</DropdownItem>
|
|
|
|
|
|
|
|
<DropdownItem
|
|
<DropdownItem
|
|
|
- onClick={() => open(PageAccessoriesModalContents.Attachment)}
|
|
|
|
|
|
|
+ onClick={() => openAccessoriesModal(PageAccessoriesModalContents.Attachment)}
|
|
|
>
|
|
>
|
|
|
<span className="mr-1"><AttachmentIcon /></span>
|
|
<span className="mr-1"><AttachmentIcon /></span>
|
|
|
{t('attachment_data')}
|
|
{t('attachment_data')}
|
|
|
</DropdownItem>
|
|
</DropdownItem>
|
|
|
|
|
|
|
|
<DropdownItem
|
|
<DropdownItem
|
|
|
- onClick={() => open(PageAccessoriesModalContents.ShareLink)}
|
|
|
|
|
|
|
+ onClick={() => openAccessoriesModal(PageAccessoriesModalContents.ShareLink)}
|
|
|
disabled={isGuestUser || isSharedUser || isLinkSharingDisabled}
|
|
disabled={isGuestUser || isSharedUser || isLinkSharingDisabled}
|
|
|
>
|
|
>
|
|
|
<span className="mr-1"><ShareLinkIcon /></span>
|
|
<span className="mr-1"><ShareLinkIcon /></span>
|
|
@@ -96,7 +113,7 @@ const AdditionalMenuItems = (props: AdditionalMenuItemsProps): JSX.Element => {
|
|
|
<DropdownItem divider />
|
|
<DropdownItem divider />
|
|
|
|
|
|
|
|
{/* Create template */}
|
|
{/* Create template */}
|
|
|
- <DropdownItem onClick={() => { /* TODO: implement in https://redmine.weseek.co.jp/issues/87673 */ }}>
|
|
|
|
|
|
|
+ <DropdownItem onClick={openPageTemplateModalHandler}>
|
|
|
<i className="icon-fw icon-magic-wand"></i> { t('template.option_label.create/edit') }
|
|
<i className="icon-fw icon-magic-wand"></i> { t('template.option_label.create/edit') }
|
|
|
</DropdownItem>
|
|
</DropdownItem>
|
|
|
</>
|
|
</>
|
|
@@ -115,6 +132,7 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
const { data: path } = useCurrentPagePath();
|
|
const { data: path } = useCurrentPagePath();
|
|
|
const { data: creator } = useCreator();
|
|
const { data: creator } = useCreator();
|
|
|
const { data: revisionAuthor } = useRevisionAuthor();
|
|
const { data: revisionAuthor } = useRevisionAuthor();
|
|
|
|
|
+ const { data: currentUser } = useCurrentUser();
|
|
|
const { data: isGuestUser } = useIsGuestUser();
|
|
const { data: isGuestUser } = useIsGuestUser();
|
|
|
const { data: isSharedUser } = useIsSharedUser();
|
|
const { data: isSharedUser } = useIsSharedUser();
|
|
|
const { data: shareLinkId } = useShareLinkId();
|
|
const { data: shareLinkId } = useShareLinkId();
|
|
@@ -126,9 +144,12 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
|
|
|
|
|
const { mutate: mutateSWRTagsInfo, data: tagsInfoData } = useSWRTagsInfo(pageId);
|
|
const { mutate: mutateSWRTagsInfo, data: tagsInfoData } = useSWRTagsInfo(pageId);
|
|
|
|
|
|
|
|
- const { open: openRenameModal } = usePageRenameModalStatus();
|
|
|
|
|
|
|
+ const { open: openDuplicateModal } = usePageDuplicateModal();
|
|
|
|
|
+ const { open: openRenameModal } = usePageRenameModal();
|
|
|
const { open: openDeleteModal } = usePageDeleteModal();
|
|
const { open: openDeleteModal } = usePageDeleteModal();
|
|
|
|
|
|
|
|
|
|
+ const [isPageTemplateModalShown, setIsPageTempleteModalShown] = useState(false);
|
|
|
|
|
+
|
|
|
const {
|
|
const {
|
|
|
editorContainer, isCompactMode, isLinkSharingDisabled,
|
|
editorContainer, isCompactMode, isLinkSharingDisabled,
|
|
|
} = props;
|
|
} = props;
|
|
@@ -157,6 +178,10 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
}, [pageId]);
|
|
}, [pageId]);
|
|
|
|
|
|
|
|
|
|
+ const duplicateItemClickedHandler = useCallback(async(pageId, path) => {
|
|
|
|
|
+ openDuplicateModal(pageId, path);
|
|
|
|
|
+ }, [openDuplicateModal]);
|
|
|
|
|
+
|
|
|
const renameItemClickedHandler = useCallback(async(pageId, revisionId, path) => {
|
|
const renameItemClickedHandler = useCallback(async(pageId, revisionId, path) => {
|
|
|
openRenameModal(pageId, revisionId, path);
|
|
openRenameModal(pageId, revisionId, path);
|
|
|
}, [openRenameModal]);
|
|
}, [openRenameModal]);
|
|
@@ -165,6 +190,11 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
openDeleteModal([pageToDelete]);
|
|
openDeleteModal([pageToDelete]);
|
|
|
}, [openDeleteModal]);
|
|
}, [openDeleteModal]);
|
|
|
|
|
|
|
|
|
|
+ const templateMenuItemClickHandler = useCallback(() => {
|
|
|
|
|
+ setIsPageTempleteModalShown(true);
|
|
|
|
|
+ }, []);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
const ControlComponents = useCallback(() => {
|
|
const ControlComponents = useCallback(() => {
|
|
|
function onPageEditorModeButtonClicked(viewType) {
|
|
function onPageEditorModeButtonClicked(viewType) {
|
|
|
mutateEditorMode(viewType);
|
|
mutateEditorMode(viewType);
|
|
@@ -183,8 +213,15 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
disableSeenUserInfoPopover={isSharedUser}
|
|
disableSeenUserInfoPopover={isSharedUser}
|
|
|
showPageControlDropdown={isAbleToShowPageManagement}
|
|
showPageControlDropdown={isAbleToShowPageManagement}
|
|
|
additionalMenuItemRenderer={props => (
|
|
additionalMenuItemRenderer={props => (
|
|
|
- <AdditionalMenuItems {...props} pageId={pageId} revisionId={revisionId} isLinkSharingDisabled={isLinkSharingDisabled} />
|
|
|
|
|
|
|
+ <AdditionalMenuItems
|
|
|
|
|
+ {...props}
|
|
|
|
|
+ pageId={pageId}
|
|
|
|
|
+ revisionId={revisionId}
|
|
|
|
|
+ isLinkSharingDisabled={isLinkSharingDisabled}
|
|
|
|
|
+ onClickTemplateMenuItem={templateMenuItemClickHandler}
|
|
|
|
|
+ />
|
|
|
)}
|
|
)}
|
|
|
|
|
+ onClickDuplicateMenuItem={duplicateItemClickedHandler}
|
|
|
onClickRenameMenuItem={renameItemClickedHandler}
|
|
onClickRenameMenuItem={renameItemClickedHandler}
|
|
|
onClickDeleteMenuItem={deleteItemClickedHandler}
|
|
onClickDeleteMenuItem={deleteItemClickedHandler}
|
|
|
/>
|
|
/>
|
|
@@ -200,15 +237,21 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ {currentUser != null && (
|
|
|
|
|
+ <CreateTemplateModal
|
|
|
|
|
+ path={path}
|
|
|
|
|
+ isOpen={isPageTemplateModalShown}
|
|
|
|
|
+ onClose={() => setIsPageTempleteModalShown(false)}
|
|
|
|
|
+ />
|
|
|
|
|
+ )}
|
|
|
</>
|
|
</>
|
|
|
);
|
|
);
|
|
|
}, [
|
|
}, [
|
|
|
- pageId, revisionId, shareLinkId,
|
|
|
|
|
- editorMode, mutateEditorMode,
|
|
|
|
|
- isCompactMode, isLinkSharingDisabled,
|
|
|
|
|
- isDeviceSmallerThanMd, isGuestUser, isSharedUser,
|
|
|
|
|
|
|
+ pageId, revisionId, shareLinkId, editorMode, mutateEditorMode, isCompactMode,
|
|
|
|
|
+ isLinkSharingDisabled, isDeviceSmallerThanMd, isGuestUser, isSharedUser, currentUser,
|
|
|
isViewMode, isAbleToShowPageEditorModeManager, isAbleToShowPageManagement,
|
|
isViewMode, isAbleToShowPageEditorModeManager, isAbleToShowPageManagement,
|
|
|
- renameItemClickedHandler, deleteItemClickedHandler, path,
|
|
|
|
|
|
|
+ duplicateItemClickedHandler, renameItemClickedHandler, deleteItemClickedHandler,
|
|
|
|
|
+ path, templateMenuItemClickHandler, isPageTemplateModalShown,
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
|
|
|