import React from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import { withUnstatedContainers } from '../UnstatedUtils'; import AppContainer from '../../services/AppContainer'; import NavigationContainer from '../../services/NavigationContainer'; import SearchForm from '../SearchForm'; class SearchTop extends React.Component { constructor(props) { super(props); this.state = { text: '', isScopeChildren: false, }; this.onInputChange = this.onInputChange.bind(this); this.onClickAllPages = this.onClickAllPages.bind(this); this.onClickChildren = this.onClickChildren.bind(this); this.search = this.search.bind(this); } onInputChange(text) { this.setState({ text }); } onClickAllPages() { this.setState({ isScopeChildren: false }); } onClickChildren() { this.setState({ isScopeChildren: true }); } search() { const url = new URL(window.location.href); url.pathname = '/_search'; // construct search query let q = this.state.text; if (this.state.isScopeChildren) { q += ` prefix:${window.location.pathname}`; } url.searchParams.append('q', q); window.location.href = url.href; } Root = ({ children }) => { const { isDeviceSmallerThanMd: isCollapsed } = this.props.navigationContainer.state; return isCollapsed ? (