NewPageNameInputter.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // This is the root component for #search-top
  2. import React from 'react';
  3. import { FormGroup, Button, InputGroup } from 'react-bootstrap';
  4. import { AsyncTypeahead } from 'react-bootstrap-typeahead';
  5. import SearchForm from './HeaderSearchBox/SearchForm';
  6. // import SearchSuggest from './HeaderSearchBox/SearchSuggest'; // omit since using react-bootstrap-typeahead in SearchForm
  7. import PagePath from './PageList/PagePath';
  8. import PropTypes from 'prop-types';
  9. export default class NewPageNameInputter extends SearchForm {
  10. constructor(props) {
  11. super(props);
  12. this.state.keyword = props.keyword
  13. }
  14. render() {
  15. const emptyLabel = (this.state.searchError !== null)
  16. ? 'Error on searching.'
  17. : 'No matches found on title...';
  18. const formClear = this.getFormClearComponent();
  19. const keyword = "hoge";
  20. return (
  21. <form
  22. action="/_search"
  23. className=""
  24. >
  25. <AsyncTypeahead
  26. ref={ref => this._typeahead = ref}
  27. inputProps={{name: "q", autoComplete: "off"}}
  28. isLoading={this.state.isLoading}
  29. labelKey="path"
  30. minLength={2}
  31. options={this.state.pages}
  32. placeholder="Input page name"
  33. emptyLabel={emptyLabel}
  34. align='left'
  35. submitFormOnEnter={true}
  36. onSearch={this.search}
  37. onInputChange={this.onInputChange}
  38. renderMenuItemChildren={this.renderMenuItemChildren}
  39. caseSensitive={false}
  40. keyword={keyword} // 検索キーワードを表示中のページの親ページにしたいがやり方不明。[TODO]
  41. />
  42. {formClear}
  43. <span>page: {this.state.keyword}</span> {/* 検索キーワードを表示デバッグ用 */ }
  44. </form>
  45. );
  46. }
  47. }
  48. NewPageNameInputter.propTypes = {
  49. keyword: PropTypes.string.isRequired,
  50. };
  51. NewPageNameInputter.defaultProps = {
  52. keyword: "",
  53. };