Closes #7949 Closes #7950pull/8414/head
parent
7f71caaf7f
commit
c61735cde2
@ -1,64 +1,44 @@
|
||||
import { push } from 'connected-react-router';
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import { deleteMovie } from 'Store/Actions/movieActions';
|
||||
import { deleteMovie, setDeleteOption } from 'Store/Actions/movieActions';
|
||||
import createMovieSelector from 'Store/Selectors/createMovieSelector';
|
||||
import DeleteMovieModalContent from './DeleteMovieModalContent';
|
||||
|
||||
function createMapStateToProps() {
|
||||
return createSelector(
|
||||
(state) => state.movies.deleteOptions,
|
||||
createMovieSelector(),
|
||||
(movie) => {
|
||||
return movie;
|
||||
(deleteOptions, movie) => {
|
||||
return {
|
||||
...movie,
|
||||
deleteOptions
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const mapDispatchToProps = {
|
||||
deleteMovie,
|
||||
push
|
||||
};
|
||||
|
||||
class DeleteMovieModalContentConnector extends Component {
|
||||
|
||||
//
|
||||
// Listeners
|
||||
|
||||
onDeletePress = (deleteFiles, addImportExclusion) => {
|
||||
this.props.deleteMovie({
|
||||
id: this.props.movieId,
|
||||
deleteFiles,
|
||||
addImportExclusion
|
||||
});
|
||||
|
||||
this.props.onModalClose(true);
|
||||
|
||||
if (this.props.nextMovieRelativePath) {
|
||||
this.props.push(window.Radarr.urlBase + this.props.nextMovieRelativePath);
|
||||
function createMapDispatchToProps(dispatch, props) {
|
||||
return {
|
||||
onDeleteOptionChange(option) {
|
||||
dispatch(
|
||||
setDeleteOption({
|
||||
[option.name]: option.value
|
||||
})
|
||||
);
|
||||
},
|
||||
|
||||
onDeletePress(deleteFiles, addImportExclusion) {
|
||||
dispatch(
|
||||
deleteMovie({
|
||||
id: props.movieId,
|
||||
deleteFiles,
|
||||
addImportExclusion
|
||||
})
|
||||
);
|
||||
|
||||
props.onModalClose(true);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Render
|
||||
|
||||
render() {
|
||||
return (
|
||||
<DeleteMovieModalContent
|
||||
{...this.props}
|
||||
onDeletePress={this.onDeletePress}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
DeleteMovieModalContentConnector.propTypes = {
|
||||
movieId: PropTypes.number.isRequired,
|
||||
onModalClose: PropTypes.func.isRequired,
|
||||
deleteMovie: PropTypes.func.isRequired,
|
||||
push: PropTypes.func.isRequired,
|
||||
nextMovieRelativePath: PropTypes.string
|
||||
};
|
||||
|
||||
export default connect(createMapStateToProps, mapDispatchToProps)(DeleteMovieModalContentConnector);
|
||||
export default connect(createMapStateToProps, createMapDispatchToProps)(DeleteMovieModalContent);
|
||||
|
Loading…
Reference in new issue