jam411 3 лет назад
Родитель
Сommit
60e7de35ad

+ 21 - 11
packages/app/src/components/Comments.tsx

@@ -1,29 +1,39 @@
 import React from 'react';
 
 import { PageComment } from '~/components/PageComment';
+import { useCommentPreviewOptions } from '~/stores/renderer';
 
 import { CommentEditorLazyRenderer } from './PageComment/CommentEditorLazyRenderer';
 
-export const Comments = (): JSX.Element => {
+type CommentsProps = {
+  pageId?: string,
+  isDeleted: boolean,
+}
 
+export const Comments = (props: CommentsProps): JSX.Element => {
+
+  const { pageId, isDeleted } = props;
+
+  const { data: rendererOptions } = useCommentPreviewOptions();
+
+  if (rendererOptions == null) {
+    return <></>;
+  }
 
   return (
+    // TODO: Check CSS import
     <div className="page-comments-row mt-5 py-4 d-edit-none d-print-none">
       <div className="container-lg">
-
         <div className="page-comments">
           <div id="page-comments-list" className="page-comments-list">
-            <PageComment />
+            <PageComment pageId={pageId} isReadOnly={false} titleAlign="left" />
           </div>
-
-          {/* {% if page and not page.isDeleted() %} */}
-          <div id="page-comment-write">
-            <CommentEditorLazyRenderer />
-          </div>
-          {/* {% endif %} */}
-
+          { isDeleted && (
+            <div id="page-comment-write">
+              <CommentEditorLazyRenderer pageId={pageId} rendererOptions={rendererOptions} />
+            </div>
+          )}
         </div>
-
       </div>
     </div>
   );

+ 0 - 8
packages/app/src/components/PageComment.tsx

@@ -170,7 +170,6 @@ export const PageComment: FC<PageCommentProps> = memo((props:PageCommentProps):
 
   return (
     <>
-      {/* TODO: Check the comment.html CSS */}
       <div className={`${styles['page-comment-styles']} page-comments-row comment-list`}>
         <div className="container-lg">
           <div className="page-comments">
@@ -221,13 +220,6 @@ export const PageComment: FC<PageCommentProps> = memo((props:PageCommentProps):
 
               })}
             </div>
-            {/* TODO: Check if identical-page */}
-            {(!isReadOnly) && (
-              <CommentEditorLazyRenderer
-                pageId={pageId}
-                rendererOptions={rendererOptions}
-              />
-            )}
           </div>
         </div>
       </div>

+ 1 - 1
packages/app/src/components/PageContentFooter.tsx

@@ -15,7 +15,7 @@ export const PageContentFooter = memo((): JSX.Element => {
 
   const { data: page } = useSWRxCurrentPage();
 
-  if (page == null) {
+  if (page == null || page.revision === undefined) {
     return <></>;
   }
 

+ 37 - 3
packages/app/src/pages/[[...path]].page.tsx

@@ -17,8 +17,8 @@ import Head from 'next/head';
 import { useRouter } from 'next/router';
 import superjson from 'superjson';
 
+import { Comments } from '~/components/Comments';
 import { PageAlerts } from '~/components/PageAlert/PageAlerts';
-import { PageComment } from '~/components/PageComment';
 // import { useTranslation } from '~/i18n';
 import { PageContentFooter } from '~/components/PageContentFooter';
 import { CrowiRequest } from '~/interfaces/crowi-request';
@@ -74,7 +74,7 @@ import {
 const logger = loggerFactory('growi:pages:all');
 
 const {
-  isPermalink: _isPermalink, isUsersHomePage, isTrashPage: _isTrashPage, isUserPage, isCreatablePage,
+  isPermalink: _isPermalink, isUsersHomePage, isTrashPage: _isTrashPage, isUserPage, isCreatablePage, isTrashPage,
 } = pagePathUtils;
 const { removeHeadingSlash } = pathUtils;
 
@@ -329,9 +329,43 @@ const GrowiPage: NextPage<Props> = (props: Props) => {
             </div> */}
           </div>
         </div>
+        {/* TODO: Check CSS import */}
         <footer className="footer d-edit-none">
+          {/* TODO: Enable page_list.html */}
+          {/* TODO: Enable isIdenticalPathPage or useIdenticalPath */}
           { !props.isIdenticalPathPage && (
-            <PageComment pageId={pageId} isReadOnly={false} titleAlign="left" />
+            <Comments pageId={pageId} isDeleted={isTrashPage(pageWithMeta?.data.path)}/>
+          )}
+          {/* TODO: Create UsersHomePageFooter conponent */}
+          { isUsersHomePage(pageWithMeta?.data.path) && (
+            <div className="container-lg user-page-footer py-5">
+              <div className="grw-user-page-list-m d-edit-none">
+                <h2 id="bookmarks-list" className="grw-user-page-header border-bottom pb-2 mb-3">
+                  <i style={{ fontSize: '1.3em' }} className="fa fa-fw fa-bookmark-o"></i>
+                  Bookmarks
+                </h2>
+                <div id="user-bookmark-list" className="page-list">
+                  {/* TODO: No need page-list-container class ? */}
+                  <div className="page-list-container">
+                    {/* <BookmarkList userId={pageContainer.state.creator._id} /> */}
+                  </div>
+                </div>
+              </div>
+              <div className="grw-user-page-list-m mt-5 d-edit-none">
+                <h2 id="recently-created-list" className="grw-user-page-header border-bottom pb-2 mb-3">
+                  <i id="recent-created-icon" className="mr-1">
+                    {/* <RecentlyCreatedIcon /> */}
+                  </i>
+                  Recently Created
+                </h2>
+                <div id="user-created-list" className="page-list">
+                  {/* TODO: No need page-list-container class ? */}
+                  <div className="page-list-container">
+                    {/* <RecentCreated userId={pageContainer.state.creator._id} /> */}
+                  </div>
+                </div>
+              </div>
+            </div>
           )}
           <PageContentFooter />
         </footer>