Sfoglia il codice sorgente

implmented so that the trash page will have no errors when guest users sees it

白石誠 5 anni fa
parent
commit
f4c6bdc9bd

+ 3 - 3
src/client/js/components/Page/TrashPageAlert.jsx

@@ -17,7 +17,7 @@ const TrashPageAlert = (props) => {
   const {
     path, isDeleted, lastUpdateUsername, updatedAt, hasChildren, isAbleToDeleteCompletely,
   } = pageContainer.state;
-  const { currentUser } = appContainer;
+  const { currentUser = null } = appContainer;
   const [isEmptyTrashModalShown, setIsEmptyTrashModalShown] = useState(false);
   const [isPutbackPageModalShown, setIsPutbackPageModalShown] = useState(false);
   const [isPageDeleteModalShown, setIsPageDeleteModalShown] = useState(false);
@@ -113,8 +113,8 @@ const TrashPageAlert = (props) => {
           This page is in the trash <i className="icon-trash" aria-hidden="true"></i>.
           {isDeleted && <span><br /><UserPicture user={{ username: lastUpdateUsername }} /> Deleted by {lastUpdateUsername} at {updatedAt}</span>}
         </div>
-        {(currentUser.admin && path === '/trash' && hasChildren) && renderEmptyButton()}
-        {(isDeleted && currentUser != null) && renderTrashPageManagementButtons()}
+        {(currentUser && currentUser.admin && path === '/trash' && hasChildren) && renderEmptyButton()}
+        {(isDeleted && currentUser) && renderTrashPageManagementButtons()}
       </div>
       {renderModals()}
     </>

+ 1 - 1
src/client/js/components/Sidebar/SidebarNav.jsx

@@ -73,7 +73,7 @@ class SidebarNav extends React.Component {
           {isAdmin && <SecondaryItem label="Admin" iconName="settings" href="/admin" />}
           {isLoggedIn && <SecondaryItem label="Draft" iconName="file_copy" href="/me/drafts" />}
           <SecondaryItem label="Help" iconName="help" href="https://docs.growi.org" isBlank />
-          {isLoggedIn && <SecondaryItem label="Trash" iconName="delete" href="/trash" />}
+          <SecondaryItem label="Trash" iconName="delete" href="/trash" />
         </div>
       </div>
     );