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

81076 PageManagement condition

Mao 4 лет назад
Родитель
Сommit
f7f9c81a92

+ 15 - 2
packages/app/src/components/Navbar/GrowiSubNavigation.jsx

@@ -25,14 +25,26 @@ const GrowiSubNavigation = (props) => {
   } = props;
   const { isDrawerMode, editorMode, isDeviceSmallerThanMd } = navigationContainer.state;
   const {
-    pageId, revisionId, path, isDeletable, isAbleToDeleteCompletely, createdAt, creator, updatedAt, revisionAuthor, isPageExist, tags,
+    pageId,
+    revisionId,
+    path,
+    isDeletable,
+    isAbleToDeleteCompletely,
+    createdAt,
+    creator,
+    updatedAt,
+    revisionAuthor,
+    isPageExist,
+    isTrashPage,
+    tags,
   } = pageContainer.state;
 
-  const { isGuestUser } = appContainer;
+  const { isGuestUser, isSharedUser } = appContainer;
   const isEditorMode = editorMode !== 'view';
   // Tags cannot be edited while the new page and editorMode is view
   const isTagLabelHidden = (editorMode !== 'edit' && !isPageExist);
 
+  const isAbleToShowPageManagement = isPageExist && !isTrashPage && !isSharedUser;
   function onPageEditorModeButtonClicked(viewType) {
     navigationContainer.setEditorMode(viewType);
   }
@@ -92,6 +104,7 @@ const GrowiSubNavigation = (props) => {
               path={path}
               isDeletable={isDeletable}
               isAbleToDeleteCompletely={isAbleToDeleteCompletely}
+              willShowPageManagement={isAbleToShowPageManagement}
             />
           </div>
           <div className="mt-2">

+ 12 - 9
packages/app/src/components/Navbar/SubNavButtons.tsx

@@ -20,12 +20,13 @@ type SubNavButtonsProps= {
   pageId: string,
   revisionId: string,
   path: string,
+  willShowPageManagement: boolean,
   isDeletable: boolean,
   isAbleToDeleteCompletely: boolean,
 }
 const SubNavButtons: FC<SubNavButtonsProps> = (props: SubNavButtonsProps) => {
   const {
-    appContainer, navigationContainer, isCompactMode, pageId, revisionId, path, isDeletable, isAbleToDeleteCompletely,
+    appContainer, navigationContainer, isCompactMode, pageId, revisionId, path, willShowPageManagement, isDeletable, isAbleToDeleteCompletely,
   } = props;
   const { editorMode } = navigationContainer.state;
   const isViewMode = editorMode === 'view';
@@ -91,14 +92,16 @@ const SubNavButtons: FC<SubNavButtonsProps> = (props: SubNavButtonsProps) => {
         </PageReactionButtons>
       )}
       {/* TODO add condition here */}
-      <PageManagement
-        pageId={pageId}
-        revisionId={revisionId}
-        path={path}
-        isDeletable={isDeletable}
-        isAbleToDeleteCompletely={isAbleToDeleteCompletely}
-      >
-      </PageManagement>
+      {willShowPageManagement && (
+        <PageManagement
+          pageId={pageId}
+          revisionId={revisionId}
+          path={path}
+          isDeletable={isDeletable}
+          isAbleToDeleteCompletely={isAbleToDeleteCompletely}
+        >
+        </PageManagement>
+      )}
     </>
   );
 };

+ 4 - 0
packages/app/src/components/SearchPage/SearchResultContentSubNavigation.tsx

@@ -40,6 +40,9 @@ const SearchResultContentSubNavigation: FC<Props> = (props : Props) => {
     return <></>;
   }
   const { isSharedUser } = appContainer;
+  // path : /trash/hoge. subStr(0,7) => /trash/
+  const isTrashPage = path.substr(0, 7) === '/trash/';
+  const isAbleToShowPageManagement = !isTrashPage && !isSharedUser;
   return (
     <div className={`grw-subnav container-fluid d-flex align-items-center justify-content-between ${isCompactMode ? 'grw-subnav-compact d-print-none' : ''}`}>
       {/* Left side */}
@@ -60,6 +63,7 @@ const SearchResultContentSubNavigation: FC<Props> = (props : Props) => {
           path={path}
           isDeletable
           isAbleToDeleteCompletely
+          willShowPageManagement={isAbleToShowPageManagement}
         >
         </SubNavButtons>
       </div>