import React from 'react'; import PropTypes from 'prop-types'; import SearchTypeahead from './SearchTypeahead'; // SearchTypeahead wrapper export default class SearchForm extends React.Component { constructor(props) { super(props); this.state = { searchError: null, }; this.onSearchError = this.onSearchError.bind(this); this.onChange = this.onChange.bind(this); } componentDidMount() { } componentWillUnmount() { } onSearchError(err) { this.setState({ searchError: err, }); } onChange(selected) { const page = selected[0]; // should be single page selected // navigate to page if (page != null) { window.location = page.path; } } getHelpElement() { const t = this.props.t; return (
{ t('search_help.title') }
word1 word2

({ t('search_help.and.syntax help') })
{ t('search_help.and.desc', { word1: 'word1', word2: 'word2' }) }
"This is GROWI"

({ t('search_help.phrase.syntax help') })
{ t('search_help.phrase.desc', { phrase: 'This is GROWI' }) }
-keyword
{ t('search_help.exclude.desc', { word: 'keyword' }) }
prefix:/user/
{ t('search_help.prefix.desc', { path: '/user/' }) }
-prefix:/user/
{ t('search_help.exclude_prefix.desc', { path: '/user/' }) }
); } render() { const t = this.props.t; const emptyLabel = (this.state.searchError !== null) ? 'Error on searching.' : t('search.search page bodies'); return ( ); } } SearchForm.propTypes = { t: PropTypes.func.isRequired, // i18next crowi: PropTypes.object.isRequired, keyword: PropTypes.string, onSubmit: PropTypes.func.isRequired, onInputChange: PropTypes.func, }; SearchForm.defaultProps = { onInputChange: () => {}, };