Browse Source

modify naming and delete path file

yuto-o 4 năm trước cách đây
mục cha
commit
1810a8a167

+ 0 - 4
packages/app/src/client/util/search/path.ts

@@ -1,4 +0,0 @@
-export const specificPathNames: { [pathName : string]: string} = {
-  user: 'user',
-  trash: 'trash',
-};

+ 21 - 18
packages/app/src/components/SearchPage.jsx

@@ -12,7 +12,11 @@ import SearchPageLayout from './SearchPage/SearchPageLayout';
 import SearchResultContent from './SearchPage/SearchResultContent';
 import SearchResultContent from './SearchPage/SearchResultContent';
 import SearchResultList from './SearchPage/SearchResultList';
 import SearchResultList from './SearchPage/SearchResultList';
 import SearchControl from './SearchPage/SearchControl';
 import SearchControl from './SearchPage/SearchControl';
-import { specificPathNames } from '../client/util/search/path';
+
+export const specificPathNames = {
+  user: '/user',
+  trash: '/trash',
+};
 
 
 class SearchPage extends React.Component {
 class SearchPage extends React.Component {
 
 
@@ -28,15 +32,16 @@ class SearchPage extends React.Component {
       searchResultMeta: {},
       searchResultMeta: {},
       selectedPage: {},
       selectedPage: {},
       selectedPages: new Set(),
       selectedPages: new Set(),
-      isNotIncludeUserPath: true,
-      isNotIncludeTrashPath: true,
+      excludeUsersHome: true,
+      excludeTrash: true,
     };
     };
 
 
     this.changeURL = this.changeURL.bind(this);
     this.changeURL = this.changeURL.bind(this);
     this.search = this.search.bind(this);
     this.search = this.search.bind(this);
     this.selectPage = this.selectPage.bind(this);
     this.selectPage = this.selectPage.bind(this);
     this.toggleCheckBox = this.toggleCheckBox.bind(this);
     this.toggleCheckBox = this.toggleCheckBox.bind(this);
-    this.toggleIncludedSpecificPath = this.toggleIncludedSpecificPath.bind(this);
+    this.onExcludeUsersHome = this.onExcludeUsersHome.bind(this);
+    this.onExcludeTrash = this.onExcludeTrash.bind(this);
   }
   }
 
 
   componentDidMount() {
   componentDidMount() {
@@ -58,15 +63,12 @@ class SearchPage extends React.Component {
     return query;
     return query;
   }
   }
 
 
-  toggleIncludedSpecificPath(pathType) {
-    switch (pathType) {
-      case specificPathNames.user:
-        this.setState({ isNotIncludeUserPath: !this.state.isNotIncludeUserPath });
-        break;
-      case specificPathNames.trash:
-        this.setState({ isNotIncludeTrashPath: !this.state.isNotIncludeTrashPath });
-        break;
-    }
+  onExcludeUsersHome() {
+    this.setState({ excludeUsersHome: !this.state.excludeUsersHome });
+  }
+
+  onExcludeTrash() {
+    this.setState({ excludeTrash: !this.state.excludeTrash });
   }
   }
 
 
   changeURL(keyword, refreshHash) {
   changeURL(keyword, refreshHash) {
@@ -84,11 +86,11 @@ class SearchPage extends React.Component {
     let query = keyword;
     let query = keyword;
 
 
     // pages included in specific path are not retrived when prefix is added
     // pages included in specific path are not retrived when prefix is added
-    if (this.state.isNotIncludeTrashPath) {
-      query = `${query} -prefix:/${specificPathNames.trash}`;
+    if (this.state.excludeTrash) {
+      query = `${query} -prefix:${specificPathNames.trash}`;
     }
     }
-    if (this.state.isNotIncludeUserPath) {
-      query = `${query} -prefix:/${specificPathNames.user}`;
+    if (this.state.excludeUsersHome) {
+      query = `${query} -prefix:${specificPathNames.user}`;
     }
     }
 
 
     return query;
     return query;
@@ -188,7 +190,8 @@ class SearchPage extends React.Component {
         searchingKeyword={this.state.searchingKeyword}
         searchingKeyword={this.state.searchingKeyword}
         appContainer={this.props.appContainer}
         appContainer={this.props.appContainer}
         onSearchInvoked={this.search}
         onSearchInvoked={this.search}
-        toggleIncludedSpecificPath={this.toggleIncludedSpecificPath}
+        onExcludeUsersHome={this.onExcludeUsersHome}
+        onExcludeTrash={this.onExcludeTrash}
       >
       >
       </SearchControl>
       </SearchControl>
     );
     );

+ 4 - 4
packages/app/src/components/SearchPage/SearchControl.tsx

@@ -1,6 +1,5 @@
 import React, { FC } from 'react';
 import React, { FC } from 'react';
 import SearchPageForm from './SearchPageForm';
 import SearchPageForm from './SearchPageForm';
-import { specificPathNames } from '../../client/util/search/path';
 import AppContainer from '../../client/services/AppContainer';
 import AppContainer from '../../client/services/AppContainer';
 
 
 
 
@@ -8,7 +7,8 @@ type Props = {
   searchingKeyword: string,
   searchingKeyword: string,
   appContainer: AppContainer,
   appContainer: AppContainer,
   onSearchInvoked: (data : any[]) => boolean,
   onSearchInvoked: (data : any[]) => boolean,
-  toggleIncludedSpecificPath: (pathType: string) => void,
+  onExcludeUsersHome: () => void,
+  onExcludeTrash: () => void,
 }
 }
 
 
 const SearchControl: FC <Props> = (props: Props) => {
 const SearchControl: FC <Props> = (props: Props) => {
@@ -32,7 +32,7 @@ const SearchControl: FC <Props> = (props: Props) => {
             type="checkbox"
             type="checkbox"
             value=""
             value=""
             id="flexCheckDefault"
             id="flexCheckDefault"
-            onClick={() => props.toggleIncludedSpecificPath(specificPathNames.user)}
+            onClick={() => props.onExcludeUsersHome()}
           />
           />
           <label className="form-check-label" htmlFor="flexCheckDefault">
           <label className="form-check-label" htmlFor="flexCheckDefault">
             /user下を含む
             /user下を含む
@@ -44,7 +44,7 @@ const SearchControl: FC <Props> = (props: Props) => {
             type="checkbox"
             type="checkbox"
             value=""
             value=""
             id="flexCheckChecked"
             id="flexCheckChecked"
-            onClick={() => props.toggleIncludedSpecificPath(specificPathNames.trash)}
+            onClick={() => props.onExcludeTrash()}
           />
           />
           <label className="form-check-label" htmlFor="flexCheckChecked">
           <label className="form-check-label" htmlFor="flexCheckChecked">
             /trash下を含む
             /trash下を含む