|
|
@@ -9,7 +9,7 @@ import { withUnstatedContainers } from '../UnstatedUtils';
|
|
|
import EditorContainer from '~/client/services/EditorContainer';
|
|
|
import {
|
|
|
EditorMode, useDrawerMode, useEditorMode, useIsDeviceSmallerThanMd, useIsAbleToShowPageManagement, useIsAbleToShowTagLabel,
|
|
|
- useIsAbleToShowPageEditorModeManager, useIsAbleToShowPageAuthors,
|
|
|
+ useIsAbleToShowPageEditorModeManager, useIsAbleToShowPageAuthors, usePageAccessoriesModal, PageAccessoriesModalContents,
|
|
|
} from '~/stores/ui';
|
|
|
import {
|
|
|
useCurrentCreatedAt, useCurrentUpdatedAt, useCurrentPageId, useRevisionId, useCurrentPagePath,
|
|
|
@@ -17,13 +17,17 @@ import {
|
|
|
} from '~/stores/context';
|
|
|
import { useSWRTagsInfo } from '~/stores/page';
|
|
|
|
|
|
-import { AdditionalMenuItemsRendererProps } from '../Common/Dropdown/PageItemControl';
|
|
|
-import { SubNavButtons } from './SubNavButtons';
|
|
|
-import PageEditorModeManager from './PageEditorModeManager';
|
|
|
|
|
|
import { toastSuccess, toastError } from '~/client/util/apiNotification';
|
|
|
import { apiPost } from '~/client/util/apiv1-client';
|
|
|
import { IPageHasId } from '~/interfaces/page';
|
|
|
+
|
|
|
+import HistoryIcon from '../Icons/HistoryIcon';
|
|
|
+import AttachmentIcon from '../Icons/AttachmentIcon';
|
|
|
+import ShareLinkIcon from '../Icons/ShareLinkIcon';
|
|
|
+import { AdditionalMenuItemsRendererProps } from '../Common/Dropdown/PageItemControl';
|
|
|
+import { SubNavButtons } from './SubNavButtons';
|
|
|
+import PageEditorModeManager from './PageEditorModeManager';
|
|
|
import { GrowiSubNavigation } from './GrowiSubNavigation';
|
|
|
import PresentationIcon from '../Icons/PresentationIcon';
|
|
|
import { exportAsMarkdown } from '~/client/services/page-operation';
|
|
|
@@ -32,17 +36,21 @@ import { exportAsMarkdown } from '~/client/services/page-operation';
|
|
|
type AdditionalMenuItemsProps = AdditionalMenuItemsRendererProps & {
|
|
|
pageId: string,
|
|
|
revisionId: string,
|
|
|
+ isLinkSharingDisabled?: boolean,
|
|
|
}
|
|
|
|
|
|
const AdditionalMenuItems = (props: AdditionalMenuItemsProps): JSX.Element => {
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
- const { pageId, revisionId } = props;
|
|
|
+ const { pageId, revisionId, isLinkSharingDisabled } = props;
|
|
|
+
|
|
|
+ const { data: isGuestUser } = useIsGuestUser();
|
|
|
+ const { data: isSharedUser } = useIsSharedUser();
|
|
|
+
|
|
|
+ const { open } = usePageAccessoriesModal();
|
|
|
|
|
|
return (
|
|
|
<>
|
|
|
- <DropdownItem divider />
|
|
|
-
|
|
|
{/* Presentation */}
|
|
|
<DropdownItem onClick={() => { /* TODO: implement in https://redmine.weseek.co.jp/issues/87672 */ }}>
|
|
|
<i className="icon-fw"><PresentationIcon /></i>
|
|
|
@@ -57,6 +65,35 @@ const AdditionalMenuItems = (props: AdditionalMenuItemsProps): JSX.Element => {
|
|
|
|
|
|
<DropdownItem divider />
|
|
|
|
|
|
+ {/*
|
|
|
+ TODO: show Tooltip when menu is disabled
|
|
|
+ refs: PageAccessoriesModalControl
|
|
|
+ */}
|
|
|
+ <DropdownItem
|
|
|
+ onClick={() => open(PageAccessoriesModalContents.PageHistory)}
|
|
|
+ disabled={isGuestUser || isSharedUser}
|
|
|
+ >
|
|
|
+ <span className="mr-1"><HistoryIcon /></span>
|
|
|
+ {t('History')}
|
|
|
+ </DropdownItem>
|
|
|
+
|
|
|
+ <DropdownItem
|
|
|
+ onClick={() => open(PageAccessoriesModalContents.Attachment)}
|
|
|
+ >
|
|
|
+ <span className="mr-1"><AttachmentIcon /></span>
|
|
|
+ {t('attachment_data')}
|
|
|
+ </DropdownItem>
|
|
|
+
|
|
|
+ <DropdownItem
|
|
|
+ onClick={() => open(PageAccessoriesModalContents.ShareLink)}
|
|
|
+ disabled={isGuestUser || isSharedUser || isLinkSharingDisabled}
|
|
|
+ >
|
|
|
+ <span className="mr-1"><ShareLinkIcon /></span>
|
|
|
+ {t('share_links.share_link_management')}
|
|
|
+ </DropdownItem>
|
|
|
+
|
|
|
+ <DropdownItem divider />
|
|
|
+
|
|
|
{/* Create template */}
|
|
|
<DropdownItem onClick={() => { /* TODO: implement in https://redmine.weseek.co.jp/issues/87673 */ }}>
|
|
|
<i className="icon-fw icon-magic-wand"></i> { t('template.option_label.create/edit') }
|
|
|
@@ -88,7 +125,7 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
const { mutate: mutateSWRTagsInfo, data: tagsInfoData } = useSWRTagsInfo(pageId);
|
|
|
|
|
|
const {
|
|
|
- editorContainer, isCompactMode,
|
|
|
+ editorContainer, isCompactMode, isLinkSharingDisabled,
|
|
|
} = props;
|
|
|
|
|
|
const isViewMode = editorMode === EditorMode.View;
|
|
|
@@ -130,7 +167,9 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
revisionId={revisionId}
|
|
|
disableSeenUserInfoPopover={isSharedUser}
|
|
|
showPageControlDropdown={isAbleToShowPageManagement}
|
|
|
- additionalMenuItemRenderer={props => <AdditionalMenuItems {...props} pageId={pageId} revisionId={revisionId} />}
|
|
|
+ additionalMenuItemRenderer={props => (
|
|
|
+ <AdditionalMenuItems {...props} pageId={pageId} revisionId={revisionId} isLinkSharingDisabled={isLinkSharingDisabled} />
|
|
|
+ )}
|
|
|
/>
|
|
|
) }
|
|
|
</div>
|
|
|
@@ -149,7 +188,8 @@ const GrowiContextualSubNavigation = (props) => {
|
|
|
}, [
|
|
|
pageId, revisionId,
|
|
|
editorMode, mutateEditorMode,
|
|
|
- isCompactMode, isDeviceSmallerThanMd, isGuestUser, isSharedUser,
|
|
|
+ isCompactMode, isLinkSharingDisabled,
|
|
|
+ isDeviceSmallerThanMd, isGuestUser, isSharedUser,
|
|
|
isViewMode, isAbleToShowPageEditorModeManager, isAbleToShowPageManagement,
|
|
|
]);
|
|
|
|
|
|
@@ -195,6 +235,7 @@ GrowiContextualSubNavigation.propTypes = {
|
|
|
editorContainer: PropTypes.instanceOf(EditorContainer).isRequired,
|
|
|
|
|
|
isCompactMode: PropTypes.bool,
|
|
|
+ isLinkSharingDisabled: PropTypes.bool,
|
|
|
};
|
|
|
|
|
|
export default GrowiContextualSubNavigationWrapper;
|