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

resolve dependency and change get method

yuto-o 4 лет назад
Родитель
Сommit
61fe9a4108

+ 1 - 0
packages/app/src/components/Sidebar.jsx

@@ -162,6 +162,7 @@ class Sidebar extends React.Component {
           <div id="grw-sidebar-content-container">
             <SidebarContents
               isSharedUser={this.props.appContainer.isSharedUser}
+              navigationContainer={this.props.navigationContainer}
             />
           </div>
         </div>

+ 4 - 4
packages/app/src/components/Sidebar/SidebarContents.jsx

@@ -18,6 +18,7 @@ const SidebarContents = (props) => {
   }
 
   let Contents;
+
   switch (navigationContainer.state.sidebarContentsId) {
     case 'recent':
       Contents = RecentChanges;
@@ -27,11 +28,10 @@ const SidebarContents = (props) => {
       break;
     default:
       Contents = CustomSidebar;
-
-      return (
-        <Contents />
-      );
   }
+  return (
+    <Contents />
+  );
 };
 
 SidebarContents.propTypes = {

+ 3 - 11
packages/app/src/components/Sidebar/Tag.tsx

@@ -1,16 +1,10 @@
 import React, { FC, useState, useEffect } from 'react';
 import { useTranslation } from 'react-i18next';
 import TagsList from '../TagsList';
-import AppContainer from '../../client/services/AppContainer';
 
-type Props = {
-  appContainer: AppContainer,
-};
-
-const Tag: FC<Props> = (props:Props) => {
+const Tag: FC = () => {
   const { t } = useTranslation('');
   const [isOnReload, setIsOnReload] = useState<boolean>(false);
-  const { appContainer } = props;
 
   useEffect(() => {
     setIsOnReload(false);
@@ -34,15 +28,13 @@ const Tag: FC<Props> = (props:Props) => {
         <button
           className="btn btn-primary my-4"
           type="button"
-          onClick={() => {
-            window.location.href = '/tags';
-          }}
+          onClick={() => { window.location.href = '/tags' }}
         >
           {t('Check All tags')}
         </button>
       </div>
       <div className="grw-container-convertible mb-5 pb-5">
-        <TagsList crowi={appContainer} isOnReload={isOnReload} />
+        <TagsList isOnReload={isOnReload} />
       </div>
     </>
   );

+ 2 - 2
packages/app/src/components/TagsList.jsx

@@ -5,6 +5,7 @@ import { withTranslation } from 'react-i18next';
 
 import PaginationWrapper from './PaginationWrapper';
 import TagCloudBox from './TagCloudBox';
+import { apiGet } from '../client/util/apiv1-client';
 
 class TagsList extends React.Component {
 
@@ -39,7 +40,7 @@ class TagsList extends React.Component {
   async getTagList(selectPageNumber) {
     const limit = this.state.pagingLimit;
     const offset = (selectPageNumber - 1) * limit;
-    const res = await this.props.crowi.apiGet('/tags.list', { limit, offset });
+    const res = await apiGet('/tags.list', { limit, offset });
 
     const totalTags = res.totalCount;
     const tagData = res.data;
@@ -106,7 +107,6 @@ class TagsList extends React.Component {
 }
 
 TagsList.propTypes = {
-  crowi: PropTypes.object.isRequired,
   isOnReload: PropTypes.bool,
   t: PropTypes.func.isRequired, // i18next
 };