Group movie action buttons

This commit is contained in:
Grégoire Delattre 2017-01-20 19:59:43 +01:00
parent 68285f165a
commit 8142b2ce31
2 changed files with 71 additions and 44 deletions

View File

@ -0,0 +1,45 @@
import React from 'react'
import { DropdownButton, MenuItem } from 'react-bootstrap'
export default function ActionsButton(props) {
return (
<DropdownButton className="btn btn-default btn-sm" title="Actions" id="actions-button" dropup>
<RefreshButton
fetching={props.fetching}
movieId={props.movieId}
getDetails={props.getDetails}
/>
</DropdownButton>
);
}
class RefreshButton extends React.Component {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick(e) {
e.preventDefault();
if (this.props.fetching) {
return
}
this.props.getDetails(this.props.movieId);
}
render() {
return (
<MenuItem onClick={this.handleClick}>
{this.props.fetching ||
<span>
<i className="fa fa-refresh"></i> Refresh
</span>
}
{this.props.fetching &&
<span>
<i className="fa fa-spin fa-refresh"></i> Refreshing
</span>
}
</MenuItem>
);
}
}

View File

@ -1,57 +1,39 @@
import React from 'react' import React from 'react'
import TorrentsButton from './torrents' import TorrentsButton from './torrents'
import ActionsButton from './actions'
import ListPosters from '../list/posters' import ListPosters from '../list/posters'
import ListDetails from '../list/details' import ListDetails from '../list/details'
import Loader from '../loader/loader' import Loader from '../loader/loader'
class MovieButtons extends React.Component { function MovieButtons(props) {
constructor(props) { const imdb_link = `http://www.imdb.com/title/${props.movie.imdb_id}`;
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick(e) {
e.preventDefault();
if (this.props.fetching) {
return
}
this.props.getMovieDetails(this.props.movie.imdb_id);
}
render() {
const imdb_link = `http://www.imdb.com/title/${this.props.movie.imdb_id}`;
return ( return (
<div className="list-details-buttons btn-toolbar"> <div className="list-details-buttons btn-toolbar">
<a type="button" className="btn btn-default btn-sm" onClick={this.handleClick}> {props.movie.polochon_url !== "" &&
{this.props.fetching || <a type="button" className="btn btn-primary btn-sm" href={props.movie.polochon_url}>
<span>
<i className="fa fa-refresh"></i> Refresh
</span>
}
{this.props.fetching &&
<span>
<i className="fa fa-spin fa-refresh"></i> Refreshing
</span>
}
</a>
{this.props.movie.polochon_url !== "" &&
<a type="button" className="btn btn-primary btn-sm" href={this.props.movie.polochon_url}>
<i className="fa fa-download"></i> Download <i className="fa fa-download"></i> Download
</a> </a>
} }
{this.props.movie.torrents && {props.movie.torrents &&
<TorrentsButton <TorrentsButton
torrents={this.props.movie.torrents} torrents={props.movie.torrents}
addTorrent={this.props.addTorrent} addTorrent={props.addTorrent}
/> />
} }
<ActionsButton
fetching={props.fetching}
movieId={props.movie.imdb_id}
getDetails={props.getMovieDetails}
/>
<a type="button" className="btn btn-warning btn-sm" href={imdb_link}> <a type="button" className="btn btn-warning btn-sm" href={imdb_link}>
<i className="fa fa-external-link"></i> IMDB <i className="fa fa-external-link"></i> IMDB
</a> </a>
</div> </div>
); );
}
} }
export default class MovieList extends React.Component { export default class MovieList extends React.Component {