Просмотр исходного кода

Merge pull request #3096 from weseek/fix/4302-4393-dont-push-like-page-at-share-link-page

Fix/4302 4393 dont push like page at share link page
Yuki Takei 5 лет назад
Родитель
Сommit
5399e7d8e4

+ 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">
-            { !isPageInTrash && !isPageNotFound && !isPageForbidden && <PageReactionButtons appContainer={appContainer} pageContainer={pageContainer} /> }
+            { pageContainer.isAbleToShowPageReactionButtons && <PageReactionButtons appContainer={appContainer} pageContainer={pageContainer} /> }
             { !isPageNotFound && !isPageForbidden && <PageManagement isCompactMode={isCompactMode} /> }
           </div>
           <div className="mt-2">

+ 20 - 4
src/client/js/services/PageContainer.js

@@ -108,8 +108,13 @@ export default class PageContainer extends Container {
     this.checkAndUpdateImageUrlCached(this.state.likerUsers);
 
     const { currentUser } = this.appContainer;
+
+    // check what kind of user
+    this.state.isGuestUser = currentUser == null;
+    this.state.isSharedUser = this.state.shareLinkId != null && currentUser == null;
+
     // see https://dev.growi.org/5fabddf8bbeb1a0048bcb9e9
-    const isAbleToGetAttachedInformationAboutPages = this.state.pageId != null || !(currentUser == null && this.state.isSharedPage);
+    const isAbleToGetAttachedInformationAboutPages = this.state.isPageExist && !this.state.isSharedUser;
 
     if (isAbleToGetAttachedInformationAboutPages) {
       this.retrieveSeenUsers();
@@ -147,10 +152,21 @@ export default class PageContainer extends Container {
 
 
   get isAbleToOpenPageEditor() {
-    const { currentUser } = this.appContainer;
-    const { isPageForbidden, isNotCreatable, isTrashPage } = this.state;
+    const {
+      isGuestUser, isPageForbidden, isNotCreatable, isTrashPage,
+    } = this.state;
+
+    return (!isGuestUser && !isPageForbidden && !isNotCreatable && !isTrashPage);
+  }
+
+  /**
+   * whether to display reaction buttons
+   * ex.) like, bookmark
+   */
+  get isAbleToShowPageReactionButtons() {
+    const { isTrashPage, isPageExist, isSharedUser } = this.state;
 
-    return ((currentUser != null) && !isPageForbidden && !isNotCreatable && !isTrashPage);
+    return (!isTrashPage && isPageExist && !isSharedUser);
   }
 
   /**