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

81664 rename state and setState method

SULLEY\ryo-h 4 лет назад
Родитель
Сommit
62b21f4e05

+ 12 - 12
packages/app/src/components/SearchPage.jsx

@@ -35,8 +35,8 @@ class SearchPage extends React.Component {
       searchResultCount: 0,
       activePage: 1,
       pagingLimit: 10, // change to an appropriate limit number
-      excludeUsersHome: true,
-      excludeTrash: true,
+      excludeUnderUserPage: true,
+      excludeUnderTrashPage: true,
     };
 
     this.changeURL = this.changeURL.bind(this);
@@ -44,8 +44,8 @@ class SearchPage extends React.Component {
     this.searchHandler = this.searchHandler.bind(this);
     this.selectPage = this.selectPage.bind(this);
     this.toggleCheckBox = this.toggleCheckBox.bind(this);
-    this.onExcludeUsersHome = this.onExcludeUsersHome.bind(this);
-    this.onExcludeTrash = this.onExcludeTrash.bind(this);
+    this.switchExcludingUnderUserPage = this.switchExcludingUnderUserPage.bind(this);
+    this.switchExcludingUnderTrashPage = this.switchExcludingUnderTrashPage.bind(this);
     this.onPagingNumberChanged = this.onPagingNumberChanged.bind(this);
   }
 
@@ -68,12 +68,12 @@ class SearchPage extends React.Component {
     return query;
   }
 
-  onExcludeUsersHome() {
-    this.setState({ excludeUsersHome: !this.state.excludeUsersHome });
+  switchExcludingUnderUserPage() {
+    this.setState({ excludeUnderUserPage: !this.state.excludeUnderUserPage });
   }
 
-  onExcludeTrash() {
-    this.setState({ excludeTrash: !this.state.excludeTrash });
+  switchExcludingUnderTrashPage() {
+    this.setState({ excludeUnderTrashPage: !this.state.excludeUnderTrashPage });
   }
 
   changeURL(keyword, refreshHash) {
@@ -91,10 +91,10 @@ class SearchPage extends React.Component {
     let query = keyword;
 
     // pages included in specific path are not retrived when prefix is added
-    if (this.state.excludeTrash) {
+    if (this.state.excludeUnderTrashPage) {
       query = `${query} -prefix:${specificPathNames.trash}`;
     }
-    if (this.state.excludeUsersHome) {
+    if (this.state.excludeUnderUserPage) {
       query = `${query} -prefix:${specificPathNames.user}`;
     }
 
@@ -224,8 +224,8 @@ class SearchPage extends React.Component {
         searchingKeyword={this.state.searchingKeyword}
         appContainer={this.props.appContainer}
         onSearchInvoked={this.searchHandler}
-        onExcludeUsersHome={this.onExcludeUsersHome}
-        onExcludeTrash={this.onExcludeTrash}
+        switchExcludingUnderUserPage={this.switchExcludingUnderUserPage}
+        switchExcludingUnderTrashPage={this.switchExcludingUnderTrashPage}
       >
       </SearchControl>
     );

+ 5 - 5
packages/app/src/components/SearchPage/FilterOptionModal.tsx

@@ -8,9 +8,9 @@ import {
 
 type Props = {
   isOpen: boolean,
-  onClose: () => void,
-  onExcludeUsersHome?: () => void,
-  onExcludeTrash?: () => void,
+  onClose?: () => void,
+  switchExcludingUnderUserPage?: () => void,
+  switchExcludingUnderTrashPage?: () => void,
 }
 
 // todo: implement filtering search result
@@ -37,7 +37,7 @@ const FilterOptionModal: FC<Props> = (props: Props) => {
               <input
                 className="mr-2"
                 type="checkbox"
-                onClick={props.onExcludeUsersHome}
+                onClick={props.switchExcludingUnderUserPage}
               />
               {t('Include Subordinated Target Page', { target: '/user' })}
             </label>
@@ -47,7 +47,7 @@ const FilterOptionModal: FC<Props> = (props: Props) => {
               <input
                 className="mr-2"
                 type="checkbox"
-                onClick={props.onExcludeTrash}
+                onClick={props.switchExcludingUnderTrashPage}
               />
               {t('Include Subordinated Target Page', { target: '/trash' })}
             </label>

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

@@ -10,8 +10,8 @@ type Props = {
   searchingKeyword: string,
   appContainer: AppContainer,
   onSearchInvoked: (data : any[]) => boolean,
-  onExcludeUsersHome?: () => void,
-  onExcludeTrash?: () => void,
+  switchExcludingUnderUserPage?: () => void,
+  switchExcludingUnderTrashPage?: () => void,
 }
 
 const SearchControl: FC <Props> = (props: Props) => {
@@ -22,15 +22,15 @@ const SearchControl: FC <Props> = (props: Props) => {
   const SearchPageFormTypeAny : any = SearchPageForm;
   const { t } = useTranslation('');
 
-  const onExcludeUsersHome = () => {
-    if (props.onExcludeUsersHome != null) {
-      props.onExcludeUsersHome();
+  const switchExcludingUnderUserPage = () => {
+    if (props.switchExcludingUnderUserPage != null) {
+      props.switchExcludingUnderUserPage();
     }
   };
 
-  const onExcludeTrash = () => {
-    if (props.onExcludeTrash != null) {
-      props.onExcludeTrash();
+  const switchExcludingUnderTrashPage = () => {
+    if (props.switchExcludingUnderTrashPage != null) {
+      props.switchExcludingUnderTrashPage();
     }
   };
 
@@ -62,8 +62,8 @@ const SearchControl: FC <Props> = (props: Props) => {
       <FilterOptionModal
         isOpen={isFileterOptionModalShown || false}
         onClose={closePageRenameModalHandler}
-        onExcludeUsersHome={onExcludeUsersHome}
-        onExcludeTrash={onExcludeTrash}
+        switchExcludingUnderUserPage={switchExcludingUnderUserPage}
+        switchExcludingUnderTrashPage={switchExcludingUnderTrashPage}
       />
     );
   };
@@ -110,7 +110,7 @@ const SearchControl: FC <Props> = (props: Props) => {
                 className="mr-2"
                 type="checkbox"
                 id="flexCheckDefault"
-                onClick={() => onExcludeUsersHome()}
+                onClick={() => switchExcludingUnderUserPage()}
               />
               {t('Include Subordinated Target Page', { target: '/user' })}
             </label>
@@ -121,7 +121,7 @@ const SearchControl: FC <Props> = (props: Props) => {
                 className="mr-2"
                 type="checkbox"
                 id="flexCheckChecked"
-                onClick={() => onExcludeTrash()}
+                onClick={() => switchExcludingUnderTrashPage()}
               />
               {t('Include Subordinated Target Page', { target: '/trash' })}
             </label>