|
|
@@ -2,22 +2,18 @@ import React from 'react';
|
|
|
|
|
|
import { IUserHasId } from '@growi/core';
|
|
|
import {
|
|
|
- NextPage, GetServerSideProps, GetServerSidePropsContext,
|
|
|
+ GetServerSideProps, GetServerSidePropsContext,
|
|
|
} from 'next';
|
|
|
-import { useTranslation } from 'next-i18next';
|
|
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
|
|
import dynamic from 'next/dynamic';
|
|
|
import Head from 'next/head';
|
|
|
|
|
|
import { useCurrentGrowiLayoutFluidClassName } from '~/client/services/layout';
|
|
|
-import CountBadge from '~/components/Common/CountBadge';
|
|
|
-import PageListIcon from '~/components/Icons/PageListIcon';
|
|
|
+import { MainPane } from '~/components/Layout/MainPane';
|
|
|
import { ShareLinkLayout } from '~/components/Layout/ShareLinkLayout';
|
|
|
import GrowiContextualSubNavigation from '~/components/Navbar/GrowiContextualSubNavigation';
|
|
|
import { Page } from '~/components/Page';
|
|
|
-import styles from '~/components/Page/DisplaySwitcher.module.scss'; // for PageList toc style
|
|
|
import { DrawioViewerScript } from '~/components/Script/DrawioViewerScript';
|
|
|
-import TableOfContents from '~/components/TableOfContents';
|
|
|
import { SupportedAction, SupportedActionType } from '~/interfaces/activity';
|
|
|
import { CrowiRequest } from '~/interfaces/crowi-request';
|
|
|
import { RendererConfig } from '~/interfaces/services/renderer';
|
|
|
@@ -26,7 +22,6 @@ import {
|
|
|
useCurrentUser, useCurrentPathname, useCurrentPageId, useRendererConfig, useIsSearchPage,
|
|
|
useShareLinkId, useIsSearchServiceConfigured, useIsSearchServiceReachable, useIsSearchScopeChildrenAsDefault, useDrawioUri, useIsContainerFluid,
|
|
|
} from '~/stores/context';
|
|
|
-import { useDescendantsPageListModal } from '~/stores/modal';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
import { NextPageWithLayout } from '../_app.page';
|
|
|
@@ -36,6 +31,8 @@ import {
|
|
|
|
|
|
const logger = loggerFactory('growi:next-page:share');
|
|
|
|
|
|
+const PageSideContents = dynamic(() => import('~/components/PageSideContents').then(mod => mod.PageSideContents), { ssr: false });
|
|
|
+// const Comments = dynamic(() => import('~/components/Comments').then(mod => mod.Comments), { ssr: false });
|
|
|
const ShareLinkAlert = dynamic(() => import('~/components/Page/ShareLinkAlert'), { ssr: false });
|
|
|
const ForbiddenPage = dynamic(() => import('~/components/ForbiddenPage'), { ssr: false });
|
|
|
|
|
|
@@ -63,8 +60,6 @@ const SharedPage: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
useDrawioUri(props.drawioUri);
|
|
|
useIsContainerFluid(props.isContainerFluid);
|
|
|
|
|
|
- const { open: openDescendantPageListModal } = useDescendantsPageListModal();
|
|
|
- const { t } = useTranslation();
|
|
|
|
|
|
const growiLayoutFluidClass = useCurrentGrowiLayoutFluidClassName();
|
|
|
|
|
|
@@ -74,6 +69,19 @@ const SharedPage: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
|
|
|
const title = generateCustomTitle(props, 'GROWI');
|
|
|
|
|
|
+
|
|
|
+ const sideContents = shareLink != null
|
|
|
+ ? <PageSideContents page={shareLink.relatedPage} />
|
|
|
+ : <></>;
|
|
|
+
|
|
|
+ // const footerContents = shareLink != null && isPopulated(shareLink.relatedPage.revision)
|
|
|
+ // ? (
|
|
|
+ // <>
|
|
|
+ // <Comments pageId={shareLink._id} pagePath={shareLink.relatedPage.path} revision={shareLink.relatedPage.revision} />
|
|
|
+ // </>
|
|
|
+ // )
|
|
|
+ // : <></>;
|
|
|
+
|
|
|
return (
|
|
|
<>
|
|
|
<Head>
|
|
|
@@ -87,74 +95,43 @@ const SharedPage: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
|
|
|
<div id="grw-fav-sticky-trigger" className="sticky-top"></div>
|
|
|
|
|
|
- <div className="flex-grow-1">
|
|
|
- <div id="content-main" className="content-main grw-container-convertible">
|
|
|
- { props.disableLinkSharing && (
|
|
|
- <div className="mt-4">
|
|
|
- <ForbiddenPage isLinkSharingDisabled={props.disableLinkSharing} />
|
|
|
- </div>
|
|
|
- )}
|
|
|
-
|
|
|
- { (isNotFound && !props.disableLinkSharing) && (
|
|
|
- <div className="container-lg">
|
|
|
- <h2 className="text-muted mt-4">
|
|
|
- <i className="icon-ban" aria-hidden="true" />
|
|
|
- <span> Page is not found</span>
|
|
|
- </h2>
|
|
|
- </div>
|
|
|
- )}
|
|
|
-
|
|
|
- { (props.isExpired && !props.disableLinkSharing && shareLink != null) && (
|
|
|
- <div className="container-lg">
|
|
|
- <ShareLinkAlert expiredAt={shareLink.expiredAt} createdAt={shareLink.createdAt} />
|
|
|
- <h2 className="text-muted mt-4">
|
|
|
- <i className="icon-ban" aria-hidden="true" />
|
|
|
- <span> Page is expired</span>
|
|
|
- </h2>
|
|
|
- </div>
|
|
|
- )}
|
|
|
-
|
|
|
- {(isShowSharedPage && shareLink != null) && (
|
|
|
- <>
|
|
|
- <ShareLinkAlert expiredAt={shareLink.expiredAt} createdAt={shareLink.createdAt} />
|
|
|
- <div className="d-flex flex-column flex-lg-row-reverse">
|
|
|
-
|
|
|
- <div className="grw-side-contents-container">
|
|
|
- <div className="grw-side-contents-sticky-container">
|
|
|
-
|
|
|
- {/* Page list */}
|
|
|
- <div className={`grw-page-accessories-control ${styles['grw-page-accessories-control']}`}>
|
|
|
- { shareLink.relatedPage.path != null && (
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- className="btn btn-block btn-outline-secondary grw-btn-page-accessories
|
|
|
- rounded-pill d-flex justify-content-between align-items-center"
|
|
|
- onClick={() => openDescendantPageListModal(shareLink.relatedPage.path)}
|
|
|
- data-testid="pageListButton"
|
|
|
- >
|
|
|
- <div className="grw-page-accessories-control-icon">
|
|
|
- <PageListIcon />
|
|
|
- </div>
|
|
|
- {t('page_list')}
|
|
|
- <CountBadge count={shareLink.relatedPage.descendantCount} offset={1} />
|
|
|
- </button>
|
|
|
- ) }
|
|
|
- </div>
|
|
|
-
|
|
|
- <div className="d-none d-lg-block">
|
|
|
- <TableOfContents />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div className="flex-grow-1 flex-basis-0 mw-0">
|
|
|
- <Page />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </>
|
|
|
- )}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <MainPane
|
|
|
+ sideContents={sideContents}
|
|
|
+ // footerContents={footerContents}
|
|
|
+ >
|
|
|
+ { props.disableLinkSharing && (
|
|
|
+ <div className="mt-4">
|
|
|
+ <ForbiddenPage isLinkSharingDisabled={props.disableLinkSharing} />
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+
|
|
|
+ { (isNotFound && !props.disableLinkSharing) && (
|
|
|
+ <div className="container-lg">
|
|
|
+ <h2 className="text-muted mt-4">
|
|
|
+ <i className="icon-ban" aria-hidden="true" />
|
|
|
+ <span> Page is not found</span>
|
|
|
+ </h2>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+
|
|
|
+ { (props.isExpired && !props.disableLinkSharing && shareLink != null) && (
|
|
|
+ <div className="container-lg">
|
|
|
+ <ShareLinkAlert expiredAt={shareLink.expiredAt} createdAt={shareLink.createdAt} />
|
|
|
+ <h2 className="text-muted mt-4">
|
|
|
+ <i className="icon-ban" aria-hidden="true" />
|
|
|
+ <span> Page is expired</span>
|
|
|
+ </h2>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+
|
|
|
+ {(isShowSharedPage && shareLink != null) && (
|
|
|
+ <>
|
|
|
+ <ShareLinkAlert expiredAt={shareLink.expiredAt} createdAt={shareLink.createdAt} />
|
|
|
+ <Page />
|
|
|
+ </>
|
|
|
+ )}
|
|
|
+ </MainPane>
|
|
|
+
|
|
|
</div>
|
|
|
</>
|
|
|
);
|
|
|
@@ -249,6 +226,7 @@ export const getServerSideProps: GetServerSideProps = async(context: GetServerSi
|
|
|
const ShareLinkModel = crowi.model('ShareLink');
|
|
|
const shareLink = await ShareLinkModel.findOne({ _id: params.linkId }).populate('relatedPage');
|
|
|
if (shareLink != null) {
|
|
|
+ await shareLink.relatedPage.populateDataToShowRevision();
|
|
|
props.isExpired = shareLink.isExpired();
|
|
|
props.shareLink = shareLink.toObject();
|
|
|
}
|