|
@@ -12,7 +12,7 @@ import PagePathHierarchicalLink from '@commons/components/PagePathHierarchicalLi
|
|
|
import { createSubscribedElement } from '../UnstatedUtils';
|
|
import { createSubscribedElement } from '../UnstatedUtils';
|
|
|
import AppContainer from '../../services/AppContainer';
|
|
import AppContainer from '../../services/AppContainer';
|
|
|
|
|
|
|
|
-import RevisionPath from '../Page/RevisionPath';
|
|
|
|
|
|
|
+import RevisionPathControls from '../Page/RevisionPathControls';
|
|
|
import PageContainer from '../../services/PageContainer';
|
|
import PageContainer from '../../services/PageContainer';
|
|
|
import TagLabels from '../Page/TagLabels';
|
|
import TagLabels from '../Page/TagLabels';
|
|
|
import LikeButton from '../LikeButton';
|
|
import LikeButton from '../LikeButton';
|
|
@@ -21,6 +21,42 @@ import BookmarkButton from '../BookmarkButton';
|
|
|
import PageCreator from './PageCreator';
|
|
import PageCreator from './PageCreator';
|
|
|
import RevisionAuthor from './RevisionAuthor';
|
|
import RevisionAuthor from './RevisionAuthor';
|
|
|
|
|
|
|
|
|
|
+// eslint-disable-next-line react/prop-types
|
|
|
|
|
+const PagePathNav = ({ pageId, pagePath, isPageForbidden }) => {
|
|
|
|
|
+
|
|
|
|
|
+ const dPagePath = new DevidedPagePath(pagePath, false, true);
|
|
|
|
|
+
|
|
|
|
|
+ let formerLink;
|
|
|
|
|
+ let latterLink;
|
|
|
|
|
+
|
|
|
|
|
+ // when the path is root or first level
|
|
|
|
|
+ if (dPagePath.isRoot || dPagePath.isFormerRoot) {
|
|
|
|
|
+ const linkedPagePath = new LinkedPagePath(pagePath);
|
|
|
|
|
+ latterLink = <PagePathHierarchicalLink linkedPagePath={linkedPagePath} />;
|
|
|
|
|
+ }
|
|
|
|
|
+ // when the path is second level or deeper
|
|
|
|
|
+ else {
|
|
|
|
|
+ const linkedPagePathFormer = new LinkedPagePath(dPagePath.former);
|
|
|
|
|
+ const linkedPagePathLatter = new LinkedPagePath(dPagePath.latter);
|
|
|
|
|
+ formerLink = <PagePathHierarchicalLink linkedPagePath={linkedPagePathFormer} />;
|
|
|
|
|
+ latterLink = <PagePathHierarchicalLink linkedPagePath={linkedPagePathLatter} basePath={dPagePath.former} />;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div className="grw-page-path-nav">
|
|
|
|
|
+ {formerLink}
|
|
|
|
|
+ <span className="d-flex align-items-center flex-wrap">
|
|
|
|
|
+ <h1 className="m-0">{latterLink}</h1>
|
|
|
|
|
+ <RevisionPathControls
|
|
|
|
|
+ pageId={pageId}
|
|
|
|
|
+ pagePath={pagePath}
|
|
|
|
|
+ isPageForbidden={isPageForbidden}
|
|
|
|
|
+ />
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ );
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
const GrowiSubNavigation = (props) => {
|
|
const GrowiSubNavigation = (props) => {
|
|
|
const isPageForbidden = document.querySelector('#grw-subnav').getAttribute('data-is-forbidden-page') === 'true';
|
|
const isPageForbidden = document.querySelector('#grw-subnav').getAttribute('data-is-forbidden-page') === 'true';
|
|
|
const { appContainer, pageContainer } = props;
|
|
const { appContainer, pageContainer } = props;
|
|
@@ -31,26 +67,11 @@ const GrowiSubNavigation = (props) => {
|
|
|
const isPageNotFound = pageId == null;
|
|
const isPageNotFound = pageId == null;
|
|
|
const isPageInTrash = isTrashPage(path);
|
|
const isPageInTrash = isTrashPage(path);
|
|
|
|
|
|
|
|
- const dPagePath = new DevidedPagePath(path, false, true);
|
|
|
|
|
- const linkedPagePathFormer = new LinkedPagePath(dPagePath.former);
|
|
|
|
|
- const renderFormerLink = () => (
|
|
|
|
|
- <>
|
|
|
|
|
- { !dPagePath.isRoot && <PagePathHierarchicalLink linkedPagePath={linkedPagePathFormer} /> }
|
|
|
|
|
- </>
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
// Display only the RevisionPath
|
|
// Display only the RevisionPath
|
|
|
if (isPageNotFound || isPageForbidden) {
|
|
if (isPageNotFound || isPageForbidden) {
|
|
|
return (
|
|
return (
|
|
|
<div className="px-3 py-3 grw-subnavbar">
|
|
<div className="px-3 py-3 grw-subnavbar">
|
|
|
- { renderFormerLink() }
|
|
|
|
|
- <h1 className="m-0">
|
|
|
|
|
- <RevisionPath
|
|
|
|
|
- pageId={pageId}
|
|
|
|
|
- pagePath={pageContainer.state.path}
|
|
|
|
|
- isPageForbidden={isPageForbidden}
|
|
|
|
|
- />
|
|
|
|
|
- </h1>
|
|
|
|
|
|
|
+ <PagePathNav pageId={pageId} pagePath={path} isPageForbidden={isPageForbidden} />
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
@@ -72,10 +93,7 @@ const GrowiSubNavigation = (props) => {
|
|
|
|
|
|
|
|
{/* Page Path */}
|
|
{/* Page Path */}
|
|
|
<div>
|
|
<div>
|
|
|
- { renderFormerLink() }
|
|
|
|
|
- <h1 className="m-0">
|
|
|
|
|
- <RevisionPath pageId={pageId} pagePath={pageContainer.state.path} />
|
|
|
|
|
- </h1>
|
|
|
|
|
|
|
+ <PagePathNav pageId={pageId} pagePath={path} isPageForbidden={isPageForbidden} />
|
|
|
{ !isPageNotFound && !isPageForbidden && (
|
|
{ !isPageNotFound && !isPageForbidden && (
|
|
|
<TagLabels />
|
|
<TagLabels />
|
|
|
) }
|
|
) }
|