|
@@ -6,8 +6,7 @@ import {
|
|
|
} from 'reactstrap';
|
|
} from 'reactstrap';
|
|
|
|
|
|
|
|
|
|
|
|
|
-import AppContainer from '~/client/services/AppContainer';
|
|
|
|
|
-import { useIsGuestUser, useIsSharedUser } from '~/stores/context';
|
|
|
|
|
|
|
+import { useDisableLinkSharing, useIsGuestUser, useIsSharedUser } from '~/stores/context';
|
|
|
import { usePageAccessoriesModal, PageAccessoriesModalContents } from '~/stores/modal';
|
|
import { usePageAccessoriesModal, PageAccessoriesModalContents } from '~/stores/modal';
|
|
|
|
|
|
|
|
import { CustomNavTab } from './CustomNavigation/CustomNav';
|
|
import { CustomNavTab } from './CustomNavigation/CustomNav';
|
|
@@ -19,21 +18,10 @@ import ShareLinkIcon from './Icons/ShareLinkIcon';
|
|
|
import PageAttachment from './PageAttachment';
|
|
import PageAttachment from './PageAttachment';
|
|
|
import PageHistory from './PageHistory';
|
|
import PageHistory from './PageHistory';
|
|
|
import ShareLink from './ShareLink/ShareLink';
|
|
import ShareLink from './ShareLink/ShareLink';
|
|
|
-import { withUnstatedContainers } from './UnstatedUtils';
|
|
|
|
|
|
|
|
|
|
import styles from './PageAccessoriesModal.module.scss';
|
|
import styles from './PageAccessoriesModal.module.scss';
|
|
|
|
|
|
|
|
-type Props = {
|
|
|
|
|
- appContainer: AppContainer,
|
|
|
|
|
- isLinkSharingDisabled: boolean,
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-const PageAccessoriesModal = (props: Props): JSX.Element => {
|
|
|
|
|
- const {
|
|
|
|
|
- appContainer,
|
|
|
|
|
- } = props;
|
|
|
|
|
-
|
|
|
|
|
- const isLinkSharingDisabled = appContainer.config.disableLinkSharing;
|
|
|
|
|
|
|
+const PageAccessoriesModal = (): JSX.Element => {
|
|
|
|
|
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
@@ -42,6 +30,7 @@ const PageAccessoriesModal = (props: Props): JSX.Element => {
|
|
|
|
|
|
|
|
const { data: isSharedUser } = useIsSharedUser();
|
|
const { data: isSharedUser } = useIsSharedUser();
|
|
|
const { data: isGuestUser } = useIsGuestUser();
|
|
const { data: isGuestUser } = useIsGuestUser();
|
|
|
|
|
+ const { data: isLinkSharingDisabled } = useDisableLinkSharing();
|
|
|
|
|
|
|
|
const { data: status, mutate, close } = usePageAccessoriesModal();
|
|
const { data: status, mutate, close } = usePageAccessoriesModal();
|
|
|
|
|
|
|
@@ -59,29 +48,45 @@ const PageAccessoriesModal = (props: Props): JSX.Element => {
|
|
|
}, [mutate, status]);
|
|
}, [mutate, status]);
|
|
|
|
|
|
|
|
const navTabMapping = useMemo(() => {
|
|
const navTabMapping = useMemo(() => {
|
|
|
|
|
+ const isOpened = status == null ? false : status.isOpened;
|
|
|
return {
|
|
return {
|
|
|
[PageAccessoriesModalContents.PageHistory]: {
|
|
[PageAccessoriesModalContents.PageHistory]: {
|
|
|
Icon: HistoryIcon,
|
|
Icon: HistoryIcon,
|
|
|
- Content: () => <PageHistory />,
|
|
|
|
|
|
|
+ Content: () => {
|
|
|
|
|
+ if (!isOpened) {
|
|
|
|
|
+ return <></>;
|
|
|
|
|
+ }
|
|
|
|
|
+ return <PageHistory />;
|
|
|
|
|
+ },
|
|
|
i18n: t('History'),
|
|
i18n: t('History'),
|
|
|
index: 0,
|
|
index: 0,
|
|
|
isLinkEnabled: () => !isGuestUser && !isSharedUser,
|
|
isLinkEnabled: () => !isGuestUser && !isSharedUser,
|
|
|
},
|
|
},
|
|
|
[PageAccessoriesModalContents.Attachment]: {
|
|
[PageAccessoriesModalContents.Attachment]: {
|
|
|
Icon: AttachmentIcon,
|
|
Icon: AttachmentIcon,
|
|
|
- Content: () => <PageAttachment />,
|
|
|
|
|
|
|
+ Content: () => {
|
|
|
|
|
+ if (!isOpened) {
|
|
|
|
|
+ return <></>;
|
|
|
|
|
+ }
|
|
|
|
|
+ return <PageAttachment />;
|
|
|
|
|
+ },
|
|
|
i18n: t('attachment_data'),
|
|
i18n: t('attachment_data'),
|
|
|
index: 1,
|
|
index: 1,
|
|
|
},
|
|
},
|
|
|
[PageAccessoriesModalContents.ShareLink]: {
|
|
[PageAccessoriesModalContents.ShareLink]: {
|
|
|
Icon: ShareLinkIcon,
|
|
Icon: ShareLinkIcon,
|
|
|
- Content: () => <ShareLink />,
|
|
|
|
|
|
|
+ Content: () => {
|
|
|
|
|
+ if (!isOpened) {
|
|
|
|
|
+ return <></>;
|
|
|
|
|
+ }
|
|
|
|
|
+ return <ShareLink />;
|
|
|
|
|
+ },
|
|
|
i18n: t('share_links.share_link_management'),
|
|
i18n: t('share_links.share_link_management'),
|
|
|
index: 2,
|
|
index: 2,
|
|
|
isLinkEnabled: () => !isGuestUser && !isSharedUser && !isLinkSharingDisabled,
|
|
isLinkEnabled: () => !isGuestUser && !isSharedUser && !isLinkSharingDisabled,
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
- }, [t, isGuestUser, isSharedUser, isLinkSharingDisabled]);
|
|
|
|
|
|
|
+ }, [status, t, isGuestUser, isSharedUser, isLinkSharingDisabled]);
|
|
|
|
|
|
|
|
const buttons = useMemo(() => (
|
|
const buttons = useMemo(() => (
|
|
|
<div className="d-flex flex-nowrap">
|
|
<div className="d-flex flex-nowrap">
|
|
@@ -128,9 +133,4 @@ const PageAccessoriesModal = (props: Props): JSX.Element => {
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-/**
|
|
|
|
|
- * Wrapper component for using unstated
|
|
|
|
|
- */
|
|
|
|
|
-const PageAccessoriesModalWrapper = withUnstatedContainers(PageAccessoriesModal, [AppContainer]);
|
|
|
|
|
-
|
|
|
|
|
-export default PageAccessoriesModalWrapper;
|
|
|
|
|
|
|
+export default PageAccessoriesModal;
|