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

change sidebar content after moving tag page

yuto-oweseek 4 лет назад
Родитель
Сommit
9f82e24d42

+ 2 - 3
packages/app/src/components/Sidebar/SidebarContents.jsx

@@ -18,12 +18,11 @@ const SidebarContents = (props) => {
     return null;
   }
 
-  let Contents;
-  if (navigationContainer.state.sidebarContentsId === 'resent') {
+  if (navigationContainer.state.sidebarContentsId === 'recent') {
     return <RecentChanges />;
   }
   if (navigationContainer.state.sidebarContentsId === 'tag') {
-    return <Tag appContainer={appContainer} />;
+    return <Tag appContainer={appContainer} navigationContainer={navigationContainer} />;
   }
 
   return <CustomSidebar />;

+ 14 - 4
packages/app/src/components/Sidebar/Tag.tsx

@@ -2,25 +2,35 @@ import React, { FC } from 'react';
 import { useTranslation } from 'react-i18next';
 import TagsList from '../TagsList';
 import AppContainer from '../../client/services/AppContainer';
+import NavigationContainer from '../../client/services/NavigationContainer';
 
 type Props = {
   appContainer: AppContainer,
+  navigationContainer: NavigationContainer,
 };
 
-
 const Tag: FC<Props> = (props:Props) => {
   const { t } = useTranslation('');
-  const { appContainer } = props;
+  const { appContainer, navigationContainer } = props;
   return (
     <>
       <div className="grw-sidebar-content-header p-3 d-flex">
         <h3 className="mb-0">{t('Tags')}</h3>
-        <button type="button" className="btn btn-sm ml-auto grw-btn-reload-rc" onClick={() => { window.location.href = '/tags' }}>
+        <button type="button" className="btn btn-sm ml-auto grw-btn-reload-rc" onClick={() => {}}>
           <i className="icon icon-reload"></i>
         </button>
       </div>
       <div className="d-flex justify-content-center">
-        <button className="btn btn-primary my-4" type="button" onClick={() => { window.location.href = '/tags' }}>check all tags</button>
+        <button
+          className="btn btn-primary my-4"
+          type="button"
+          onClick={() => {
+            navigationContainer.selectSidebarContents('recent');
+            window.location.href = '/tags';
+          }}
+        >
+          check all tag
+        </button>
       </div>
       <TagsList crowi={appContainer} />
     </>