|
@@ -7,6 +7,7 @@ import {
|
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
import { useIsGuestUser, useIsSharedUser } from '~/stores/context';
|
|
import { useIsGuestUser, useIsSharedUser } from '~/stores/context';
|
|
|
|
|
+import { usePageAccessoriesModal, PageAccessoriesModalContents } from '~/stores/ui';
|
|
|
import AppContainer from '~/client/services/AppContainer';
|
|
import AppContainer from '~/client/services/AppContainer';
|
|
|
|
|
|
|
|
import HistoryIcon from './Icons/HistoryIcon';
|
|
import HistoryIcon from './Icons/HistoryIcon';
|
|
@@ -18,7 +19,6 @@ import PageHistory from './PageHistory';
|
|
|
import ShareLink from './ShareLink/ShareLink';
|
|
import ShareLink from './ShareLink/ShareLink';
|
|
|
import { CustomNavTab } from './CustomNavigation/CustomNav';
|
|
import { CustomNavTab } from './CustomNavigation/CustomNav';
|
|
|
import ExpandOrContractButton from './ExpandOrContractButton';
|
|
import ExpandOrContractButton from './ExpandOrContractButton';
|
|
|
-import { usePageAccessoriesModal } from '~/stores/ui';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
@@ -35,31 +35,31 @@ const PageAccessoriesModal = (props: Props): JSX.Element => {
|
|
|
|
|
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
- const [activeTab, setActiveTab] = useState('pageHistory');
|
|
|
|
|
|
|
+ const [activeTab, setActiveTab] = useState(PageAccessoriesModalContents.PageHistory);
|
|
|
const [isWindowExpanded, setIsWindowExpanded] = useState(false);
|
|
const [isWindowExpanded, setIsWindowExpanded] = useState(false);
|
|
|
|
|
|
|
|
const { data: isSharedUser } = useIsSharedUser();
|
|
const { data: isSharedUser } = useIsSharedUser();
|
|
|
const { data: isGuestUser } = useIsGuestUser();
|
|
const { data: isGuestUser } = useIsGuestUser();
|
|
|
|
|
|
|
|
- const { data: status, close } = usePageAccessoriesModal();
|
|
|
|
|
|
|
+ const { data: status, open, close } = usePageAccessoriesModal();
|
|
|
|
|
|
|
|
const navTabMapping = useMemo(() => {
|
|
const navTabMapping = useMemo(() => {
|
|
|
return {
|
|
return {
|
|
|
- pageHistory: {
|
|
|
|
|
|
|
+ [PageAccessoriesModalContents.PageHistory]: {
|
|
|
Icon: HistoryIcon,
|
|
Icon: HistoryIcon,
|
|
|
i18n: t('History'),
|
|
i18n: t('History'),
|
|
|
- index: 2,
|
|
|
|
|
|
|
+ index: 0,
|
|
|
isLinkEnabled: () => !isGuestUser && !isSharedUser,
|
|
isLinkEnabled: () => !isGuestUser && !isSharedUser,
|
|
|
},
|
|
},
|
|
|
- attachment: {
|
|
|
|
|
|
|
+ [PageAccessoriesModalContents.Attachment]: {
|
|
|
Icon: AttachmentIcon,
|
|
Icon: AttachmentIcon,
|
|
|
i18n: t('attachment_data'),
|
|
i18n: t('attachment_data'),
|
|
|
- index: 3,
|
|
|
|
|
|
|
+ index: 1,
|
|
|
},
|
|
},
|
|
|
- shareLink: {
|
|
|
|
|
|
|
+ [PageAccessoriesModalContents.ShareLink]: {
|
|
|
Icon: ShareLinkIcon,
|
|
Icon: ShareLinkIcon,
|
|
|
i18n: t('share_links.share_link_management'),
|
|
i18n: t('share_links.share_link_management'),
|
|
|
- index: 4,
|
|
|
|
|
|
|
+ index: 2,
|
|
|
isLinkEnabled: () => !isGuestUser && !isSharedUser && !isLinkSharingDisabled,
|
|
isLinkEnabled: () => !isGuestUser && !isSharedUser && !isLinkSharingDisabled,
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
@@ -82,7 +82,7 @@ const PageAccessoriesModal = (props: Props): JSX.Element => {
|
|
|
return <></>;
|
|
return <></>;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const { isOpened, activeComponents } = status;
|
|
|
|
|
|
|
+ const { isOpened, activatedContents } = status;
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<Modal
|
|
<Modal
|
|
@@ -96,25 +96,28 @@ const PageAccessoriesModal = (props: Props): JSX.Element => {
|
|
|
activeTab={activeTab}
|
|
activeTab={activeTab}
|
|
|
navTabMapping={navTabMapping}
|
|
navTabMapping={navTabMapping}
|
|
|
breakpointToHideInactiveTabsDown="md"
|
|
breakpointToHideInactiveTabsDown="md"
|
|
|
- onNavSelected={v => setActiveTab(v)}
|
|
|
|
|
|
|
+ onNavSelected={(v) => {
|
|
|
|
|
+ setActiveTab(v);
|
|
|
|
|
+ open(v);
|
|
|
|
|
+ }}
|
|
|
hideBorderBottom
|
|
hideBorderBottom
|
|
|
/>
|
|
/>
|
|
|
</ModalHeader>
|
|
</ModalHeader>
|
|
|
<ModalBody className="overflow-auto grw-modal-body-style">
|
|
<ModalBody className="overflow-auto grw-modal-body-style">
|
|
|
{/* Do not use CustomTabContent because of performance problem:
|
|
{/* Do not use CustomTabContent because of performance problem:
|
|
|
- the 'navTabMapping[tabId].Content' for PageAccessoriesModal depends on activeComponents */}
|
|
|
|
|
|
|
+ the 'navTabMapping[tabId].Content' for PageAccessoriesModal depends on activatedContents */}
|
|
|
<TabContent activeTab={activeTab}>
|
|
<TabContent activeTab={activeTab}>
|
|
|
{!isGuestUser && (
|
|
{!isGuestUser && (
|
|
|
- <TabPane tabId="pageHistory">
|
|
|
|
|
- {activeComponents.has('pageHistory') && <PageHistory /> }
|
|
|
|
|
|
|
+ <TabPane tabId={PageAccessoriesModalContents.PageHistory}>
|
|
|
|
|
+ {activatedContents.has(PageAccessoriesModalContents.PageHistory) && <PageHistory /> }
|
|
|
</TabPane>
|
|
</TabPane>
|
|
|
)}
|
|
)}
|
|
|
- <TabPane tabId="attachment">
|
|
|
|
|
- {activeComponents.has('attachment') && <PageAttachment />}
|
|
|
|
|
|
|
+ <TabPane tabId={PageAccessoriesModalContents.Attachment}>
|
|
|
|
|
+ {activatedContents.has(PageAccessoriesModalContents.Attachment) && <PageAttachment />}
|
|
|
</TabPane>
|
|
</TabPane>
|
|
|
{!isGuestUser && (
|
|
{!isGuestUser && (
|
|
|
- <TabPane tabId="shareLink">
|
|
|
|
|
- {activeComponents.has('shareLink') && <ShareLink />}
|
|
|
|
|
|
|
+ <TabPane tabId={PageAccessoriesModalContents.ShareLink}>
|
|
|
|
|
+ {activatedContents.has(PageAccessoriesModalContents.ShareLink) && <ShareLink />}
|
|
|
</TabPane>
|
|
</TabPane>
|
|
|
)}
|
|
)}
|
|
|
</TabContent>
|
|
</TabContent>
|