|
|
@@ -1,4 +1,4 @@
|
|
|
-import React from 'react';
|
|
|
+import React, { useMemo } from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
import { withTranslation } from 'react-i18next';
|
|
|
@@ -16,58 +16,62 @@ import SeenUserInfo from './User/SeenUserInfo';
|
|
|
import { withUnstatedContainers } from './UnstatedUtils';
|
|
|
|
|
|
const PageAccessoriesModalControl = (props) => {
|
|
|
- const { t, pageAccessoriesContainer, isGuestUserMode } = props;
|
|
|
+ const {
|
|
|
+ t, pageAccessoriesContainer, isGuestUserMode, isSharedUserMode,
|
|
|
+ } = props;
|
|
|
+
|
|
|
+ const accessoriesBtnList = useMemo(() => {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ name: 'pagelist',
|
|
|
+ Icon: <PageListIcon />,
|
|
|
+ disabled: isSharedUserMode,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'timeline',
|
|
|
+ Icon: <TimeLineIcon />,
|
|
|
+ disabled: isSharedUserMode,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'pageHistory',
|
|
|
+ Icon: <HistoryIcon />,
|
|
|
+ disabled: isSharedUserMode,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'attachment',
|
|
|
+ Icon: <AttachmentIcon />,
|
|
|
+ disabled: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'shareLink',
|
|
|
+ Icon: <ShareLinkIcon />,
|
|
|
+ disabled: isGuestUserMode || isSharedUserMode,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ }, [t, isGuestUserMode, isSharedUserMode]);
|
|
|
|
|
|
return (
|
|
|
<div className="grw-page-accessories-control d-flex align-items-center justify-content-between pb-1">
|
|
|
-
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- className="btn btn-link grw-btn-page-accessories"
|
|
|
- onClick={() => pageAccessoriesContainer.openPageAccessoriesModal('pagelist')}
|
|
|
- >
|
|
|
- <PageListIcon />
|
|
|
- </button>
|
|
|
-
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- className="btn btn-link grw-btn-page-accessories"
|
|
|
- onClick={() => pageAccessoriesContainer.openPageAccessoriesModal('timeline')}
|
|
|
- >
|
|
|
- <TimeLineIcon />
|
|
|
- </button>
|
|
|
-
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- className="btn btn-link grw-btn-page-accessories"
|
|
|
- onClick={() => pageAccessoriesContainer.openPageAccessoriesModal('pageHistory')}
|
|
|
- >
|
|
|
- <HistoryIcon />
|
|
|
- </button>
|
|
|
-
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- className="btn btn-link grw-btn-page-accessories"
|
|
|
- onClick={() => pageAccessoriesContainer.openPageAccessoriesModal('attachment')}
|
|
|
- >
|
|
|
- <AttachmentIcon />
|
|
|
- </button>
|
|
|
-
|
|
|
- <div id="shareLink-btn-wrapper-for-tooltip">
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- className={`btn btn-link grw-btn-page-accessories ${isGuestUserMode && 'disabled'}`}
|
|
|
- onClick={() => pageAccessoriesContainer.openPageAccessoriesModal('shareLink')}
|
|
|
- >
|
|
|
- <ShareLinkIcon />
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- {isGuestUserMode && (
|
|
|
- <UncontrolledTooltip placement="top" target="shareLink-btn-wrapper-for-tooltip" fade={false}>
|
|
|
- {t('Not available for guest')}
|
|
|
- </UncontrolledTooltip>
|
|
|
- )}
|
|
|
-
|
|
|
+ {accessoriesBtnList.map((accessory) => {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <div id={`shareLink-btn-wrapper-for-tooltip-for-${accessory.name}`}>
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ className={`btn btn-link grw-btn-page-accessories ${accessory.disabled && 'disabled'}`}
|
|
|
+ onClick={() => pageAccessoriesContainer.openPageAccessoriesModal(accessory.name)}
|
|
|
+ >
|
|
|
+ {accessory.Icon}
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ {accessory.disabled && (
|
|
|
+ <UncontrolledTooltip placement="top" target={`shareLink-btn-wrapper-for-tooltip-for-${accessory.name}`} fade={false}>
|
|
|
+ {t('Not available for guest')}
|
|
|
+ </UncontrolledTooltip>
|
|
|
+ )}
|
|
|
+ </>
|
|
|
+ );
|
|
|
+ })}
|
|
|
<div className="d-flex align-items-center">
|
|
|
<span className="border-left grw-border-vr"> </span>
|
|
|
<SeenUserInfo />
|
|
|
@@ -86,6 +90,7 @@ PageAccessoriesModalControl.propTypes = {
|
|
|
pageAccessoriesContainer: PropTypes.instanceOf(PageAccessoriesContainer).isRequired,
|
|
|
|
|
|
isGuestUserMode: PropTypes.bool.isRequired,
|
|
|
+ isSharedUserMode: PropTypes.bool.isRequired,
|
|
|
};
|
|
|
|
|
|
export default withTranslation()(PageAccessoriesModalControlWrapper);
|