|
|
@@ -2,12 +2,12 @@ import React from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
|
import { withTranslation } from 'react-i18next';
|
|
|
|
|
|
-import { withUnstatedContainers } from '../UnstatedUtils';
|
|
|
-import PageContainer from '../../services/PageContainer';
|
|
|
+import { UncontrolledTooltip } from 'reactstrap';
|
|
|
|
|
|
-function RenderTagLabels(props) {
|
|
|
- const { t, tags, pageContainer } = props;
|
|
|
- const { pageId } = pageContainer;
|
|
|
+const RenderTagLabels = React.memo((props) => {
|
|
|
+ const {
|
|
|
+ t, tags, pageId, isGuestUser,
|
|
|
+ } = props;
|
|
|
|
|
|
function openEditorHandler() {
|
|
|
if (props.openEditorModal == null) {
|
|
|
@@ -35,35 +35,32 @@ function RenderTagLabels(props) {
|
|
|
<>
|
|
|
{tagElements}
|
|
|
|
|
|
- <a className={`btn btn-link btn-edit-tags p-0 text-muted ${isTagsEmpty ? 'no-tags' : ''}`} onClick={openEditorHandler}>
|
|
|
- { isTagsEmpty
|
|
|
- ? (
|
|
|
- <>{ t('Add tags for this page') }<i className="ml-1 icon-plus"></i></>
|
|
|
- )
|
|
|
- : (
|
|
|
- <i className="icon-plus"></i>
|
|
|
- )
|
|
|
- }
|
|
|
- </a>
|
|
|
+ <div id="edit-tags-btn-wrapper-for-tooltip">
|
|
|
+ <a
|
|
|
+ className={`btn btn-link btn-edit-tags p-0 text-muted ${isTagsEmpty && 'no-tags'} ${isGuestUser && 'disabled'}`}
|
|
|
+ onClick={openEditorHandler}
|
|
|
+ >
|
|
|
+ { isTagsEmpty && <>{ t('Add tags for this page') }</>}
|
|
|
+ <i className="ml-1 icon-plus"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ {isGuestUser && (
|
|
|
+ <UncontrolledTooltip placement="top" target="edit-tags-btn-wrapper-for-tooltip" fade={false}>
|
|
|
+ {t('Not available for guest')}
|
|
|
+ </UncontrolledTooltip>
|
|
|
+ )}
|
|
|
</>
|
|
|
);
|
|
|
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Wrapper component for using unstated
|
|
|
- */
|
|
|
-const RenderTagLabelsWrapper = withUnstatedContainers(RenderTagLabels, [PageContainer]);
|
|
|
-
|
|
|
+});
|
|
|
|
|
|
RenderTagLabels.propTypes = {
|
|
|
t: PropTypes.func.isRequired, // i18next
|
|
|
|
|
|
tags: PropTypes.array,
|
|
|
openEditorModal: PropTypes.func,
|
|
|
-
|
|
|
- pageContainer: PropTypes.instanceOf(PageContainer).isRequired,
|
|
|
-
|
|
|
+ isGuestUser: PropTypes.bool.isRequired,
|
|
|
+ pageId: PropTypes.string.isRequired,
|
|
|
};
|
|
|
|
|
|
-export default withTranslation()(RenderTagLabelsWrapper);
|
|
|
+export default withTranslation()(RenderTagLabels);
|