Ryu Sato 8 лет назад
Родитель
Сommit
0732ff7148

+ 0 - 22
resource/js/components/HeaderSearchBox/SearchForm.js

@@ -19,16 +19,10 @@ export default class SearchForm extends React.Component {
     this.crowi = window.crowi; // FIXME
     this.crowi = window.crowi; // FIXME
 
 
     this.state = {
     this.state = {
-      input: '',
-      keyword: '',
-      pages: [],
-      isLoading: false,
       searchError: null,
       searchError: null,
     };
     };
 
 
-    this.onSearchSuccess = this.onSearchSuccess.bind(this);
     this.onSearchError = this.onSearchError.bind(this);
     this.onSearchError = this.onSearchError.bind(this);
-    this.onInputChange = this.onInputChange.bind(this);
     this.onChange = this.onChange.bind(this);
     this.onChange = this.onChange.bind(this);
   }
   }
 
 
@@ -38,25 +32,12 @@ export default class SearchForm extends React.Component {
   componentWillUnmount() {
   componentWillUnmount() {
   }
   }
 
 
-  onSearchSuccess(res) {
-    this.setState({
-      isLoading: false,
-      keyword: '',
-      pages: res.data,
-    });
-  }
-
   onSearchError(err) {
   onSearchError(err) {
     this.setState({
     this.setState({
-      isLoading: false,
       searchError: err,
       searchError: err,
     });
     });
   }
   }
 
 
-  onInputChange(text) {
-    this.setState({input: text});
-  }
-
   onChange(selected) {
   onChange(selected) {
     const page = selected[0];  // should be single page selected
     const page = selected[0];  // should be single page selected
 
 
@@ -80,9 +61,6 @@ export default class SearchForm extends React.Component {
           <InputGroup>
           <InputGroup>
             <SearchTypeahead
             <SearchTypeahead
               crowi={this.crowi}
               crowi={this.crowi}
-              onSearchSuccess={this.onSearchSuccess}
-              onSearchError={this.onSearchError}
-              onInputChange={this.onInputChange}
               onChange={this.onChange}
               onChange={this.onChange}
               emptyLabel={emptyLabel}
               emptyLabel={emptyLabel}
               placeholder="Search ..."
               placeholder="Search ..."

+ 0 - 14
resource/js/components/NewPageNameInputter.js

@@ -14,14 +14,10 @@ export default class NewPageNameInputter extends React.Component {
     super(props);
     super(props);
 
 
     this.state = {
     this.state = {
-      input: '',
-      keyword: '',
-      isLoading: false,
       searchError: null,
       searchError: null,
     };
     };
     this.crowi = this.props.crowi;
     this.crowi = this.props.crowi;
 
 
-    this.onSearchSuccess = this.onSearchSuccess.bind(this);
     this.onSearchError = this.onSearchError.bind(this);
     this.onSearchError = this.onSearchError.bind(this);
     this.getParentPageName = this.getParentPageName.bind(this);
     this.getParentPageName = this.getParentPageName.bind(this);
   }
   }
@@ -32,17 +28,8 @@ export default class NewPageNameInputter extends React.Component {
   componentWillUnmount() {
   componentWillUnmount() {
   }
   }
 
 
-  onSearchSuccess(res) {
-    this.setState({
-      isLoading: false,
-      keyword: '',
-      pages: res.data,
-    });
-  }
-
   onSearchError(err) {
   onSearchError(err) {
     this.setState({
     this.setState({
-      isLoading: false,
       searchError: err,
       searchError: err,
     });
     });
   }
   }
@@ -71,7 +58,6 @@ export default class NewPageNameInputter extends React.Component {
       >
       >
         <SearchTypeahead
         <SearchTypeahead
           crowi={this.crowi}
           crowi={this.crowi}
-          onSearchSuccess={this.onSearchSuccess}
           onSearchError={this.onSearchError}
           onSearchError={this.onSearchError}
           emptyLabel={emptyLabel}
           emptyLabel={emptyLabel}
           placeholder="Input page name"
           placeholder="Input page name"

+ 2 - 4
resource/js/components/SearchTypeahead.js

@@ -103,7 +103,7 @@ export default class SearchTypeahead extends React.Component {
       keyword: '',
       keyword: '',
       pages: res.data,
       pages: res.data,
     });
     });
-    this.props.onSearchSuccess(res);
+    this.props.onSearchSuccess && this.props.onSearchSuccess(res);
   }
   }
 
 
   /**
   /**
@@ -115,7 +115,7 @@ export default class SearchTypeahead extends React.Component {
       isLoading: false,
       isLoading: false,
       searchError: err,
       searchError: err,
     });
     });
-    this.props.onSearchError(err);
+    this.props.onSearchError && this.props.onSearchError(err);
   }
   }
 
 
   onInputChange(text) {
   onInputChange(text) {
@@ -207,7 +207,6 @@ SearchTypeahead.propTypes = {
   onSearchSuccess: PropTypes.func,
   onSearchSuccess: PropTypes.func,
   onSearchError:   PropTypes.func,
   onSearchError:   PropTypes.func,
   onChange:        PropTypes.func,
   onChange:        PropTypes.func,
-  onInputChange:   PropTypes.func,
   emptyLabel:      PropTypes.string,
   emptyLabel:      PropTypes.string,
   placeholder:     PropTypes.string,
   placeholder:     PropTypes.string,
   keywordOnInit:   PropTypes.string,
   keywordOnInit:   PropTypes.string,
@@ -220,7 +219,6 @@ SearchTypeahead.defaultProps = {
   onSearchSuccess: noop,
   onSearchSuccess: noop,
   onSearchError:   noop,
   onSearchError:   noop,
   onChange:        noop,
   onChange:        noop,
-  onInputChange:   noop,
   emptyLabel:      null,
   emptyLabel:      null,
   placeholder:     "",
   placeholder:     "",
   keywordOnInit:   "",
   keywordOnInit:   "",