Explorar o código

create isAbleToShowLikeButton

itizawa %!s(int64=5) %!d(string=hai) anos
pai
achega
967ebbee42

+ 4 - 12
src/client/js/components/Navbar/GrowiSubNavigation.jsx

@@ -70,20 +70,12 @@ const PagePathNav = ({ pageId, pagePath, isPageForbidden }) => {
 /* eslint-disable react/prop-types */
 const PageReactionButtons = ({ appContainer, pageContainer }) => {
 
-  const {
-    pageUser, shareLinkId,
-  } = pageContainer.state;
-
-  const isSharedPage = useMemo(() => {
-    return shareLinkId != null;
-  }, [shareLinkId]);
-
   return (
     <>
-      {pageUser == null && !isSharedPage && (
-      <span className="mr-2">
-        <LikeButton />
-      </span>
+      {pageContainer.isAbleToShowLikeButton && (
+        <span className="mr-2">
+          <LikeButton />
+        </span>
       )}
       <span>
         <BookmarkButton crowi={appContainer} />

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

@@ -208,6 +208,17 @@ export default class PageContainer extends Container {
     return (!isUserPage && isPageExist && !isPageForbidden);
   }
 
+  /**
+   * whether to like button
+   * not displayed on user page
+   */
+  get isAbleToShowLikeButton() {
+    const { isUserPage } = this.state;
+    const { isSharedUser } = this.appContainer;
+
+    return (!isUserPage && !isSharedUser);
+  }
+
   /**
    * initialize state for markdown data
    */