import React from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import DevidedPagePath from '@commons/models/devided-page-path'; import LinkedPagePath from '@commons/models/linked-page-path'; import PagePathHierarchicalLink from '@commons/components/PagePathHierarchicalLink'; import { withUnstatedContainers } from '../UnstatedUtils'; import AppContainer from '../../services/AppContainer'; import NavigationContainer from '../../services/NavigationContainer'; import PageContainer from '../../services/PageContainer'; import RevisionPathControls from '../Page/RevisionPathControls'; import TagLabels from '../Page/TagLabels'; import LikeButton from '../LikeButton'; import BookmarkButton from '../BookmarkButton'; import PageEditorModeManager from './PageEditorModeManager'; import AuthorInfo from './AuthorInfo'; import DrawerToggler from './DrawerToggler'; import PageManagement from '../Page/PageManagement'; const PagePathNav = ({ // eslint-disable-next-line react/prop-types pageId, pagePath, isEditorMode, }) => { const dPagePath = new DevidedPagePath(pagePath, false, true); let formerLink; let latterLink; // one line if (dPagePath.isRoot || dPagePath.isFormerRoot || isEditorMode) { const linkedPagePath = new LinkedPagePath(pagePath); latterLink = ; } // two line else { const linkedPagePathFormer = new LinkedPagePath(dPagePath.former); const linkedPagePathLatter = new LinkedPagePath(dPagePath.latter); formerLink = ; latterLink = ; } return (
{formerLink}

{latterLink}

); }; /* eslint-enable react/prop-types */ /* eslint-disable react/prop-types */ const PageReactionButtons = ({ appContainer, pageContainer }) => { return ( <> {pageContainer.isAbleToShowLikeButton && ( )} ); }; /* eslint-enable react/prop-types */ const GrowiSubNavigation = (props) => { const { appContainer, navigationContainer, pageContainer, isCompactMode, } = props; const { isDrawerMode, editorMode, isDeviceSmallerThanMd } = navigationContainer.state; const { pageId, path, createdAt, creator, updatedAt, revisionAuthor, isPageExist, } = pageContainer.state; const { isGuestUser } = appContainer; const isEditorMode = editorMode !== 'view'; // Tags cannot be edited while the new page and editorMode is view const isTagLabelHidden = (editorMode !== 'edit' && !isPageExist); function onThreeStrandedButtonClicked(viewType) { navigationContainer.setEditorMode(viewType); } return (
{/* Left side */}
{ isDrawerMode && (
) }
{ pageContainer.isAbleToShowTagLabel && !isCompactMode && !isTagLabelHidden && (
) }
{/* Right side */}
{ pageContainer.isAbleToShowPageReactionButtons && } { pageContainer.isAbleToShowPageManagement && }
{pageContainer.isAbleToShowThreeStrandedButton && ( )}
{/* Page Authors */} { (pageContainer.isAbleToShowPageAuthors && !isCompactMode) && (
) }
); }; /** * Wrapper component for using unstated */ const GrowiSubNavigationWrapper = withUnstatedContainers(GrowiSubNavigation, [AppContainer, NavigationContainer, PageContainer]); GrowiSubNavigation.propTypes = { t: PropTypes.func.isRequired, // i18next appContainer: PropTypes.instanceOf(AppContainer).isRequired, navigationContainer: PropTypes.instanceOf(NavigationContainer).isRequired, pageContainer: PropTypes.instanceOf(PageContainer).isRequired, isCompactMode: PropTypes.bool, }; export default withTranslation()(GrowiSubNavigationWrapper);