jam411 3 лет назад
Родитель
Сommit
4a211162da

+ 20 - 19
packages/app/src/components/PageComment.tsx

@@ -110,25 +110,6 @@ const PageComment:FC<Props> = memo((props:Props):JSX.Element => {
     }
     }
   }, [commentToBeDeleted, onDeleteCommentAfterOperation]);
   }, [commentToBeDeleted, onDeleteCommentAfterOperation]);
 
 
-  const generateCommentInnerElement = (comment: ICommentHasId) => (
-    <Comment
-      rendererOptions={rendererOptions}
-      deleteBtnClicked={onClickDeleteButton}
-      comment={comment}
-      onComment={mutate}
-      isReadOnly={isReadOnly}
-    />
-  );
-
-  const generateAllRepliesElement = (replyComments: ICommentHasIdList) => (
-    <ReplayComments
-      replyList={replyComments}
-      deleteBtnClicked={onClickDeleteButton}
-      rendererOptions={rendererOptions}
-      isReadOnly={isReadOnly}
-    />
-  );
-
   const removeShowEditorId = useCallback((commentId: string) => {
   const removeShowEditorId = useCallback((commentId: string) => {
     setShowEditorIds((previousState) => {
     setShowEditorIds((previousState) => {
       const previousShowEditorIds = new Set(...previousState);
       const previousShowEditorIds = new Set(...previousState);
@@ -148,6 +129,26 @@ const PageComment:FC<Props> = memo((props:Props):JSX.Element => {
     return <></>;
     return <></>;
   }
   }
 
 
+  const generateCommentInnerElement = (comment: ICommentHasId) => (
+    <Comment
+      rendererOptions={rendererOptions}
+      deleteBtnClicked={onClickDeleteButton}
+      comment={comment}
+      onComment={mutate}
+      isReadOnly={isReadOnly}
+    />
+  );
+
+  const generateAllRepliesElement = (replyComments: ICommentHasIdList) => (
+    <ReplayComments
+      replyList={replyComments}
+      deleteBtnClicked={onClickDeleteButton}
+      rendererOptions={rendererOptions}
+      isReadOnly={isReadOnly}
+      onComment={mutate}
+    />
+  );
+
   let commentTitleClasses = 'border-bottom py-3 mb-3';
   let commentTitleClasses = 'border-bottom py-3 mb-3';
   commentTitleClasses = titleAlign != null ? `${commentTitleClasses} text-${titleAlign}` : `${commentTitleClasses} text-center`;
   commentTitleClasses = titleAlign != null ? `${commentTitleClasses} text-${titleAlign}` : `${commentTitleClasses} text-center`;
 
 

+ 2 - 7
packages/app/src/components/PageComment/ReplayComments.tsx

@@ -4,7 +4,7 @@ import React, { useState } from 'react';
 import { Collapse } from 'reactstrap';
 import { Collapse } from 'reactstrap';
 
 
 import { ICommentHasId, ICommentHasIdList } from '../../interfaces/comment';
 import { ICommentHasId, ICommentHasIdList } from '../../interfaces/comment';
-import { useRendererConfig } from '../../stores/context';
+import { useRendererConfig, useIsAllReplyShown } from '../../stores/context';
 
 
 import Comment from './Comment';
 import Comment from './Comment';
 
 
@@ -20,6 +20,7 @@ export const ReplayComments = (props: ReplaycommentsProps): JSX.Element => {
     deleteBtnClicked, isReadOnly, replyList, onComment,
     deleteBtnClicked, isReadOnly, replyList, onComment,
   } = props;
   } = props;
   const { data: rendererConfig } = useRendererConfig();
   const { data: rendererConfig } = useRendererConfig();
+  const { data: isAllReplyShown } = useIsAllReplyShown();
 
 
   const [isOlderRepliesShown, setIsOlderRepliesShown] = useState(false);
   const [isOlderRepliesShown, setIsOlderRepliesShown] = useState(false);
 
 
@@ -37,12 +38,6 @@ export const ReplayComments = (props: ReplaycommentsProps): JSX.Element => {
     );
     );
   };
   };
 
 
-  // TODO: Remove isAllReplyShown from rendererconfig
-  if (rendererConfig === undefined) {
-    return <></>;
-  }
-  const isAllReplyShown = rendererConfig.isAllReplyShown || false;
-
   if (isAllReplyShown) {
   if (isAllReplyShown) {
     return (
     return (
       <>
       <>

+ 15 - 18
packages/app/src/components/PageContentFooter.tsx

@@ -1,29 +1,28 @@
-import React, { FC, memo } from 'react';
+import React, { memo } from 'react';
 
 
-import { Ref } from '@growi/core';
+import dynamic from 'next/dynamic';
 
 
-import { IUser } from '../interfaces/user';
+import { useSWRxCurrentPage } from '~/stores/page';
 
 
-import AuthorInfo from './Navbar/AuthorInfo';
+import { Skelton } from './Skelton';
 
 
-type Props = {
-  createdAt: Date,
-  updatedAt: Date,
-  creator: any,
-  revisionAuthor: Ref<IUser>,
-}
+export const PageContentFooter = memo((): JSX.Element => {
 
 
-const PageContentFooter:FC<Props> = memo((props:Props):JSX.Element => {
-  const {
-    createdAt, updatedAt, creator, revisionAuthor,
-  } = props;
+  const AuthorInfo = dynamic(() => import('./Navbar/AuthorInfo'),
+    { ssr: false, loading: () => <Skelton width={300} height={20} additionalClass={'mb-3'} /> });
+
+  const { data: page } = useSWRxCurrentPage();
+
+  if (page == null) {
+    return <></>;
+  }
 
 
   return (
   return (
     <div className="page-content-footer py-4 d-edit-none d-print-none">
     <div className="page-content-footer py-4 d-edit-none d-print-none">
       <div className="grw-container-convertible">
       <div className="grw-container-convertible">
         <div className="page-meta">
         <div className="page-meta">
-          <AuthorInfo user={creator as IUser} date={createdAt} mode="create" locate="footer" />
-          <AuthorInfo user={revisionAuthor as IUser} date={updatedAt} mode="update" locate="footer" />
+          <AuthorInfo user={page.creator} date={page.createdAt} mode="create" locate="footer" />
+          <AuthorInfo user={page.revision.author} date={page.updatedAt} mode="update" locate="footer" />
         </div>
         </div>
       </div>
       </div>
     </div>
     </div>
@@ -31,5 +30,3 @@ const PageContentFooter:FC<Props> = memo((props:Props):JSX.Element => {
 });
 });
 
 
 PageContentFooter.displayName = 'PageContentFooter';
 PageContentFooter.displayName = 'PageContentFooter';
-
-export default PageContentFooter;

+ 5 - 5
packages/app/src/components/SearchPage/SearchResultContent.tsx

@@ -25,7 +25,7 @@ import { GrowiSubNavigation } from '../Navbar/GrowiSubNavigation';
 import { SubNavButtons } from '../Navbar/SubNavButtons';
 import { SubNavButtons } from '../Navbar/SubNavButtons';
 import RevisionLoader from '../Page/RevisionLoader';
 import RevisionLoader from '../Page/RevisionLoader';
 import PageComment from '../PageComment';
 import PageComment from '../PageComment';
-import PageContentFooter from '../PageContentFooter';
+import { PageContentFooter } from '../PageContentFooter';
 
 
 
 
 type AdditionalMenuItemsProps = AdditionalMenuItemsRendererProps & {
 type AdditionalMenuItemsProps = AdditionalMenuItemsRendererProps & {
@@ -216,10 +216,10 @@ export const SearchResultContent: FC<Props> = (props: Props) => {
         />
         />
         <PageComment appContainer={appContainer} pageId={page._id} highlightKeywords={highlightKeywords} isReadOnly hideIfEmpty />
         <PageComment appContainer={appContainer} pageId={page._id} highlightKeywords={highlightKeywords} isReadOnly hideIfEmpty />
         <PageContentFooter
         <PageContentFooter
-          createdAt={new Date(pageWithMeta.data.createdAt)}
-          updatedAt={new Date(pageWithMeta.data.updatedAt)}
-          creator={pageWithMeta.data.creator}
-          revisionAuthor={pageWithMeta.data.lastUpdateUser}
+          // createdAt={new Date(pageWithMeta.data.createdAt)}
+          // updatedAt={new Date(pageWithMeta.data.updatedAt)}
+          // creator={pageWithMeta.data.creator}
+          // revisionAuthor={pageWithMeta.data.lastUpdateUser}
         />
         />
       </div>
       </div>
     </div>
     </div>

+ 0 - 1
packages/app/src/interfaces/services/renderer.ts

@@ -14,7 +14,6 @@ export type RendererConfig = {
   adminPreferredIndentSize: number,
   adminPreferredIndentSize: number,
   isIndentSizeForced: boolean,
   isIndentSizeForced: boolean,
   highlightJsStyleBorder: boolean,
   highlightJsStyleBorder: boolean,
-  isAllReplyShown: boolean,
 
 
   plantumlUri: string | null,
   plantumlUri: string | null,
   blockdiagUri: string | null,
   blockdiagUri: string | null,

+ 6 - 5
packages/app/src/pages/[[...path]].page.tsx

@@ -20,6 +20,7 @@ import superjson from 'superjson';
 import { PageAlerts } from '~/components/PageAlert/PageAlerts';
 import { PageAlerts } from '~/components/PageAlert/PageAlerts';
 // import { PageComments } from '~/components/PageComment/PageComments';
 // import { PageComments } from '~/components/PageComment/PageComments';
 // import { useTranslation } from '~/i18n';
 // import { useTranslation } from '~/i18n';
+import { PageContentFooter } from '~/components/PageContentFooter';
 import { CrowiRequest } from '~/interfaces/crowi-request';
 import { CrowiRequest } from '~/interfaces/crowi-request';
 // import { renderScriptTagByName, renderHighlightJsStyleTag } from '~/service/cdn-resources-loader';
 // import { renderScriptTagByName, renderHighlightJsStyleTag } from '~/service/cdn-resources-loader';
 // import { useIndentSize } from '~/stores/editor';
 // import { useIndentSize } from '~/stores/editor';
@@ -65,7 +66,7 @@ import {
   useIsAclEnabled, useIsUserPage, useIsNotCreatable,
   useIsAclEnabled, useIsUserPage, useIsNotCreatable,
   useCsrfToken, useIsSearchScopeChildrenAsDefault, useCurrentPageId, useCurrentPathname,
   useCsrfToken, useIsSearchScopeChildrenAsDefault, useCurrentPageId, useCurrentPathname,
   useIsSlackConfigured, useIsBlinkedHeaderAtBoot, useRendererConfig, useEditingMarkdown,
   useIsSlackConfigured, useIsBlinkedHeaderAtBoot, useRendererConfig, useEditingMarkdown,
-  useEditorConfig,
+  useEditorConfig, useIsAllReplyShown,
 } from '../stores/context';
 } from '../stores/context';
 import { useXss } from '../stores/xss';
 import { useXss } from '../stores/xss';
 
 
@@ -150,7 +151,7 @@ type Props = CommonProps & {
   // mathJax: string,
   // mathJax: string,
   // noCdn: string,
   // noCdn: string,
   // highlightJsStyle: string,
   // highlightJsStyle: string,
-  // isAllReplyShown: boolean,
+  isAllReplyShown: boolean,
   // isContainerFluid: boolean,
   // isContainerFluid: boolean,
   editorConfig: EditorConfig,
   editorConfig: EditorConfig,
   isEnabledStaleNotification: boolean,
   isEnabledStaleNotification: boolean,
@@ -228,7 +229,7 @@ const GrowiPage: NextPage<Props> = (props: Props) => {
   useRendererConfig(props.rendererConfig);
   useRendererConfig(props.rendererConfig);
   // useRendererSettings(props.rendererSettingsStr != null ? JSON.parse(props.rendererSettingsStr) : undefined);
   // useRendererSettings(props.rendererSettingsStr != null ? JSON.parse(props.rendererSettingsStr) : undefined);
   // useGrowiRendererConfig(props.growiRendererConfigStr != null ? JSON.parse(props.growiRendererConfigStr) : undefined);
   // useGrowiRendererConfig(props.growiRendererConfigStr != null ? JSON.parse(props.growiRendererConfigStr) : undefined);
-
+  useIsAllReplyShown(props.isAllReplyShown);
 
 
   // const { data: editorMode } = useEditorMode();
   // const { data: editorMode } = useEditorMode();
 
 
@@ -327,6 +328,7 @@ const GrowiPage: NextPage<Props> = (props: Props) => {
         <footer>
         <footer>
           {/* <PageComments /> */}
           {/* <PageComments /> */}
           PageComments
           PageComments
+          <PageContentFooter />
         </footer>
         </footer>
 
 
         <UnsavedAlertDialog />
         <UnsavedAlertDialog />
@@ -481,7 +483,7 @@ function injectServerConfigurations(context: GetServerSidePropsContext, props: P
   // props.mathJax = configManager.getConfig('crowi', 'app:mathJax');
   // props.mathJax = configManager.getConfig('crowi', 'app:mathJax');
   // props.noCdn = configManager.getConfig('crowi', 'app:noCdn');
   // props.noCdn = configManager.getConfig('crowi', 'app:noCdn');
   // props.highlightJsStyle = configManager.getConfig('crowi', 'customize:highlightJsStyle');
   // props.highlightJsStyle = configManager.getConfig('crowi', 'customize:highlightJsStyle');
-  // props.isAllReplyShown = configManager.getConfig('crowi', 'customize:isAllReplyShown');
+  props.isAllReplyShown = configManager.getConfig('crowi', 'customize:isAllReplyShown');
   // props.isContainerFluid = configManager.getConfig('crowi', 'customize:isContainerFluid');
   // props.isContainerFluid = configManager.getConfig('crowi', 'customize:isContainerFluid');
   props.isEnabledStaleNotification = configManager.getConfig('crowi', 'customize:isEnabledStaleNotification');
   props.isEnabledStaleNotification = configManager.getConfig('crowi', 'customize:isEnabledStaleNotification');
   // props.isEnabledLinebreaks = configManager.getConfig('markdown', 'markdown:isEnabledLinebreaks');
   // props.isEnabledLinebreaks = configManager.getConfig('markdown', 'markdown:isEnabledLinebreaks');
@@ -501,7 +503,6 @@ function injectServerConfigurations(context: GetServerSidePropsContext, props: P
     isEnabledLinebreaksInComments: configManager.getConfig('markdown', 'markdown:isEnabledLinebreaksInComments'),
     isEnabledLinebreaksInComments: configManager.getConfig('markdown', 'markdown:isEnabledLinebreaksInComments'),
     adminPreferredIndentSize: configManager.getConfig('markdown', 'markdown:adminPreferredIndentSize'),
     adminPreferredIndentSize: configManager.getConfig('markdown', 'markdown:adminPreferredIndentSize'),
     isIndentSizeForced: configManager.getConfig('markdown', 'markdown:isIndentSizeForced'),
     isIndentSizeForced: configManager.getConfig('markdown', 'markdown:isIndentSizeForced'),
-    isAllReplyShown: configManager.getConfig('crowi', 'customize:isAllReplyShown'),
 
 
     plantumlUri: process.env.PLANTUML_URI ?? null,
     plantumlUri: process.env.PLANTUML_URI ?? null,
     blockdiagUri: process.env.BLOCKDIAG_URI ?? null,
     blockdiagUri: process.env.BLOCKDIAG_URI ?? null,

+ 4 - 0
packages/app/src/stores/context.tsx

@@ -233,6 +233,10 @@ export const useRendererConfig = (initialData?: RendererConfig): SWRResponse<Ren
   return useStaticSWR('growiRendererConfig', initialData);
   return useStaticSWR('growiRendererConfig', initialData);
 };
 };
 
 
+export const useIsAllReplyShown = (initialData?: boolean): SWRResponse<boolean, any> => {
+  return useStaticSWR('isAllReplyShown', initialData);
+};
+
 export const useCurrentPageTocNode = (): SWRResponse<HtmlElementNode, any> => {
 export const useCurrentPageTocNode = (): SWRResponse<HtmlElementNode, any> => {
   return useStaticSWR('currentPageTocNode');
   return useStaticSWR('currentPageTocNode');
 };
 };