import React from 'react'; import PropTypes from 'prop-types'; import { withUnstatedContainers } from './UnstatedUtils'; import AppContainer from '../services/AppContainer'; import SearchTypeahead from './SearchTypeahead'; // SearchTypeahead wrapper class SearchForm extends React.Component { constructor(props) { super(props); this.state = { searchError: null, isShownHelp: false, }; this.onSearchError = this.onSearchError.bind(this); this.onChange = this.onChange.bind(this); this.onBlur = this.onBlur.bind(this); this.onFocus = this.onFocus.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; } } onBlur() { this.setState({ isShownHelp: false, }); this.getHelpElement(); } onFocus() { this.setState({ isShownHelp: true, }); } getHelpElement() { const { t, appContainer } = this.props; const { isShownHelp } = this.state; const config = appContainer.getConfig(); const isReachable = config.isSearchServiceReachable; if (!isReachable) { return ( <>
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/' }) } |
tag:wiki |
{ t('search_help.tag.desc', { tag: 'wiki' }) } |
-tag:wiki |
{ t('search_help.exclude_tag.desc', { tag: 'wiki' }) } |