2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
|
|
|
import * as React from 'react';
|
2018-06-21 01:08:51 +02:00
|
|
|
import * as settings from 'constants/settings';
|
2018-04-18 06:03:01 +02:00
|
|
|
import { isURIValid, normalizeURI } from 'lbry-redux';
|
2018-06-21 01:08:51 +02:00
|
|
|
import { FormField, FormRow } from 'component/common/form';
|
2017-12-21 22:08:54 +01:00
|
|
|
import FileTile from 'component/fileTile';
|
|
|
|
import FileListSearch from 'component/fileListSearch';
|
2018-03-26 23:32:43 +02:00
|
|
|
import ToolTip from 'component/common/tooltip';
|
|
|
|
import Page from 'component/page';
|
2018-05-23 02:11:20 +02:00
|
|
|
import Icon from 'component/common/icon';
|
|
|
|
import * as icons from 'constants/icons';
|
2017-05-05 10:01:16 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
type Props = {
|
|
|
|
query: ?string,
|
2018-06-21 01:08:51 +02:00
|
|
|
resultCount: number,
|
|
|
|
setClientSetting: (string, number | boolean) => void,
|
2018-03-26 23:32:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class SearchPage extends React.PureComponent<Props> {
|
2018-06-21 01:08:51 +02:00
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
(this: any).onShowUnavailableChange = this.onShowUnavailableChange.bind(this);
|
|
|
|
(this: any).onSearchResultCountChange = this.onSearchResultCountChange.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
onSearchResultCountChange(event: SyntheticInputEvent<*>) {
|
2018-06-22 21:18:08 +02:00
|
|
|
const count = Number(event.target.value);
|
2018-06-21 01:08:51 +02:00
|
|
|
this.props.setClientSetting(settings.RESULT_COUNT, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
onShowUnavailableChange(event: SyntheticInputEvent<*>) {
|
|
|
|
this.props.setClientSetting(settings.SHOW_UNAVAILABLE, event.target.checked);
|
|
|
|
}
|
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
render() {
|
2018-06-25 21:16:23 +02:00
|
|
|
const { query, resultCount } = this.props;
|
2017-05-11 02:59:47 +02:00
|
|
|
return (
|
2018-05-24 19:48:51 +02:00
|
|
|
<Page>
|
2018-06-21 01:08:51 +02:00
|
|
|
<React.Fragment>
|
|
|
|
<FormRow alignRight>
|
|
|
|
<FormField
|
|
|
|
type="number"
|
|
|
|
name="result_count"
|
2018-06-22 21:18:08 +02:00
|
|
|
min={10}
|
2018-06-21 01:08:51 +02:00
|
|
|
max={1000}
|
|
|
|
value={resultCount}
|
|
|
|
onChange={this.onSearchResultCountChange}
|
|
|
|
postfix={__('returned results')}
|
|
|
|
/>
|
2018-06-25 21:16:23 +02:00
|
|
|
{
|
|
|
|
// Removing this for now, it currently doesn't do anything but ideally it would
|
|
|
|
// display content that we don't think is currently available to download
|
|
|
|
// It is like a "display all" setting
|
|
|
|
// <FormField
|
|
|
|
// type="checkbox"
|
|
|
|
// name="show_unavailable"
|
|
|
|
// onChange={this.onShowUnavailableChange}
|
|
|
|
// checked={showUnavailable}
|
|
|
|
// postfix={__('Include unavailable content')}
|
|
|
|
// />
|
|
|
|
}
|
2018-06-21 01:08:51 +02:00
|
|
|
</FormRow>
|
|
|
|
</React.Fragment>
|
2018-06-06 08:13:26 +02:00
|
|
|
{isURIValid(query) && (
|
|
|
|
<React.Fragment>
|
|
|
|
<div className="file-list__header">
|
|
|
|
{__('Exact URL')}
|
|
|
|
<ToolTip
|
|
|
|
icon
|
|
|
|
body={__('This is the resolution of a LBRY URL and not controlled by LBRY Inc.')}
|
|
|
|
>
|
|
|
|
<Icon icon={icons.HELP} />
|
|
|
|
</ToolTip>
|
|
|
|
</div>
|
2018-07-25 02:50:04 +02:00
|
|
|
<FileTile showUri displayHiddenMessage uri={normalizeURI(query)} />
|
2018-06-06 08:13:26 +02:00
|
|
|
</React.Fragment>
|
|
|
|
)}
|
|
|
|
<FileListSearch query={query} />
|
|
|
|
<div className="help">{__('These search results are provided by LBRY, Inc.')}</div>
|
2018-03-26 23:32:43 +02:00
|
|
|
</Page>
|
2017-06-06 23:19:12 +02:00
|
|
|
);
|
2017-05-11 02:59:47 +02:00
|
|
|
}
|
2017-05-05 10:01:16 +02:00
|
|
|
}
|
2018-03-26 23:32:43 +02:00
|
|
|
|
2017-05-05 10:01:16 +02:00
|
|
|
export default SearchPage;
|