Browse Source

Fix conditional render

https://youtrack.weseek.co.jp/issue/GW-7832
-  Replace ternary operator of conditional rendering with renderBar method
- Adjust Todo comment
- Remove unnecessary styling
Mudana-Grune 3 years ago
parent
commit
1c1b1a9aa6

+ 22 - 24
packages/app/src/components/Sidebar/Bookmarks.tsx

@@ -13,7 +13,7 @@ import loggerFactory from '~/utils/logger';
 
 
 const logger = loggerFactory('growi:BookmarkList');
 const logger = loggerFactory('growi:BookmarkList');
 
 
-// TODO: Adjust pagination
+// TODO: Remove pagination and apply  scrolling (not infinity)
 const ACTIVE_PAGE = 1;
 const ACTIVE_PAGE = 1;
 
 
 type Props = {
 type Props = {
@@ -65,7 +65,7 @@ const Bookmarks = () : JSX.Element => {
   const [pages, setPages] = useState<IPageHasId[]>([]);
   const [pages, setPages] = useState<IPageHasId[]>([]);
 
 
   const getMyBookmarkList = useCallback(async() => {
   const getMyBookmarkList = useCallback(async() => {
-    // TODO: Adjust pagination
+    // TODO: Remove pagination and apply  scrolling (not infinity)
     const page = ACTIVE_PAGE;
     const page = ACTIVE_PAGE;
 
 
     try {
     try {
@@ -87,33 +87,31 @@ const Bookmarks = () : JSX.Element => {
     getMyBookmarkList();
     getMyBookmarkList();
   }, [getMyBookmarkList]);
   }, [getMyBookmarkList]);
 
 
+  const renderBar = () => {
+    if (isGuestUser) {
+      return (
+        <h3 className="pl-3">
+          { t('Not available for guest') }
+        </h3>
+      );
+    }
+    if (pages.length === 0) {
+      return (
+        <h3 className="pl-3">
+          { t('No bookmarks yet') }
+        </h3>
+      );
+    }
+    return null;
+  };
+
   return (
   return (
     <>
     <>
       <div className="grw-sidebar-content-header p-3">
       <div className="grw-sidebar-content-header p-3">
         <h3 className="mb-0">{t('Bookmarks')}</h3>
         <h3 className="mb-0">{t('Bookmarks')}</h3>
       </div>
       </div>
-
-      { isGuestUser
-        ? (
-          <h3 className="pl-3">
-            { t('Not available for guest') }
-          </h3>
-        )
-        : (
-          <>
-            { pages.length === 0
-              ? (
-                <h3 className="pl-3">
-                  { t('No bookmarks yet') }
-                </h3>
-              )
-              : (
-                <BookmarksItem pages={pages} />
-              )
-            }
-          </>
-        )
-      }
+      { renderBar() }
+      <BookmarksItem pages={pages} />
     </>
     </>
   );
   );
 
 

+ 0 - 12
packages/app/src/styles/theme/_apply-colors.scss

@@ -318,18 +318,6 @@ ul.pagination {
     }
     }
   }
   }
 
 
-  .grw-bookmarks-list {
-    .list-group {
-      .list-group-item {
-        background-color: transparent;
-      }
-    }
-    .list-group-flush {
-      .list-group-item {
-        border: none;
-      }
-    }
-  }
 }
 }
 
 
 /*
 /*