Add link to search for torrents for a movie

This commit is contained in:
Grégoire Delattre 2017-08-15 14:19:09 +02:00
parent 33f0036e11
commit 380c9c453a
2 changed files with 17 additions and 6 deletions

View File

@ -45,12 +45,11 @@ function MovieButtons(props) {
lastFetchUrl={props.lastFetchUrl}
/>
{props.movie.get("torrents") !== null &&
<TorrentsButton
torrents={props.movie.get("torrents")}
addTorrent={props.addTorrent}
/>
}
<TorrentsButton
movieTitle={props.movie.get("title")}
torrents={props.movie.get("torrents")}
addTorrent={props.addTorrent}
/>
<DownloadButton
url={props.movie.get("polochon_url")}

View File

@ -13,8 +13,16 @@ export default class TorrentsButton extends React.PureComponent {
}
render() {
const entries = buildMenuItems(this.props.torrents);
const searchUrl = `#/torrents/search/movies/${encodeURI(this.props.movieTitle)}`;
return (
<DropdownButton className="btn btn-default btn-sm" title="Torrents" id="download-torrents-button" dropup>
<MenuItem className="text-warning" header>Advanced</MenuItem>
<MenuItem href={searchUrl} >
<i className="fa fa-search" aria-hidden="true"></i> Search
</MenuItem>
{entries.length > 0 &&
<MenuItem divider></MenuItem>
}
{entries.map(function(e, index) {
switch (e.type) {
case "header":
@ -41,6 +49,10 @@ export default class TorrentsButton extends React.PureComponent {
}
function buildMenuItems(torrents) {
if (!torrents) {
return [];
}
const t = torrents.groupBy((el) => el.get("source"));
// Build the array of entries