2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2018-12-19 06:44:53 +01:00
|
|
|
import * as ICONS from 'constants/icons';
|
2018-03-26 23:32:43 +02:00
|
|
|
import * as React from 'react';
|
2018-08-24 23:25:18 +02:00
|
|
|
import { isURIValid, normalizeURI, parseURI } from 'lbry-redux';
|
2017-12-21 22:08:54 +01:00
|
|
|
import FileTile from 'component/fileTile';
|
2018-08-24 23:25:18 +02:00
|
|
|
import ChannelTile from 'component/channelTile';
|
2017-12-21 22:08:54 +01:00
|
|
|
import FileListSearch from 'component/fileListSearch';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Page from 'component/page';
|
2018-08-27 20:47:55 +02:00
|
|
|
import ToolTip from 'component/common/tooltip';
|
|
|
|
import Icon from 'component/common/icon';
|
2019-02-18 18:24:56 +01:00
|
|
|
import SearchOptions from 'component/searchOptions';
|
2017-05-05 10:01:16 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
type Props = {
|
|
|
|
query: ?string,
|
|
|
|
};
|
|
|
|
|
|
|
|
class SearchPage extends React.PureComponent<Props> {
|
|
|
|
render() {
|
2019-02-18 18:24:56 +01:00
|
|
|
const { query } = this.props;
|
2018-08-24 23:25:18 +02:00
|
|
|
const isValid = isURIValid(query);
|
|
|
|
|
|
|
|
let uri;
|
|
|
|
let isChannel;
|
|
|
|
if (isValid) {
|
|
|
|
uri = normalizeURI(query);
|
|
|
|
({ isChannel } = parseURI(uri));
|
|
|
|
}
|
|
|
|
|
2017-05-11 02:59:47 +02:00
|
|
|
return (
|
2018-08-14 05:52:09 +02:00
|
|
|
<Page noPadding>
|
2018-12-19 06:44:53 +01:00
|
|
|
<section className="search">
|
2019-03-05 05:46:57 +01:00
|
|
|
{query && isValid && (
|
|
|
|
<header className="search__header">
|
|
|
|
<h1 className="search__title">
|
|
|
|
{`lbry://${query}`}
|
|
|
|
<ToolTip
|
|
|
|
icon
|
|
|
|
body={__('This is the resolution of a LBRY URL and not controlled by LBRY Inc.')}
|
|
|
|
>
|
|
|
|
<Icon icon={ICONS.HELP} />
|
|
|
|
</ToolTip>
|
|
|
|
</h1>
|
|
|
|
{isChannel ? (
|
|
|
|
<ChannelTile size="large" isSearchResult uri={uri} />
|
|
|
|
) : (
|
|
|
|
<FileTile size="large" isSearchResult displayHiddenMessage uri={uri} />
|
|
|
|
)}
|
|
|
|
</header>
|
|
|
|
)}
|
2018-12-19 06:44:53 +01:00
|
|
|
|
|
|
|
<div className="search__results-wrapper">
|
2019-02-18 18:24:56 +01:00
|
|
|
<SearchOptions />
|
|
|
|
|
2018-12-19 06:44:53 +01:00
|
|
|
<FileListSearch query={query} />
|
|
|
|
<div className="help">{__('These search results are provided by LBRY, Inc.')}</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
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;
|