Browse Source

create isAbleToShowPageReactionButtons

itizawa 5 years ago
parent
commit
77990af43e

+ 1 - 1
src/client/js/components/Navbar/GrowiSubNavigation.jsx

@@ -141,7 +141,7 @@ const GrowiSubNavigation = (props) => {
 
 
         <div className="d-flex flex-column align-items-end">
         <div className="d-flex flex-column align-items-end">
           <div className="d-flex">
           <div className="d-flex">
-            { !isPageInTrash && !isPageNotFound && !isPageForbidden && <PageReactionButtons appContainer={appContainer} pageContainer={pageContainer} /> }
+            { pageContainer.isAbleToShowPageReactionButtons && <PageReactionButtons appContainer={appContainer} pageContainer={pageContainer} /> }
             { !isPageNotFound && !isPageForbidden && <PageManagement isCompactMode={isCompactMode} /> }
             { !isPageNotFound && !isPageForbidden && <PageManagement isCompactMode={isCompactMode} /> }
           </div>
           </div>
           <div className="mt-2">
           <div className="mt-2">

+ 13 - 0
src/client/js/services/PageContainer.js

@@ -114,6 +114,8 @@ export default class PageContainer extends Container {
       this.retrieveBookmarkInfo();
       this.retrieveBookmarkInfo();
     }
     }
 
 
+    this.state.isSharedUser = (this.state.shareLinkId != null && currentUser == null);
+
     this.setTocHtml = this.setTocHtml.bind(this);
     this.setTocHtml = this.setTocHtml.bind(this);
     this.save = this.save.bind(this);
     this.save = this.save.bind(this);
     this.checkAndUpdateImageUrlCached = this.checkAndUpdateImageUrlCached.bind(this);
     this.checkAndUpdateImageUrlCached = this.checkAndUpdateImageUrlCached.bind(this);
@@ -155,6 +157,17 @@ export default class PageContainer extends Container {
     return false;
     return false;
   }
   }
 
 
+  /**
+   * whether to display reaction buttons
+   * ex.) like, bookmark
+   */
+  get isAbleToShowPageReactionButtons() {
+    const { isTrashPage, isPageExist, isSharedUser } = this.state;
+    console.log(isTrashPage, isPageExist, isSharedUser);
+
+    return (!isTrashPage && isPageExist && !isSharedUser);
+  }
+
   /**
   /**
    * initialize state for markdown data
    * initialize state for markdown data
    */
    */