New: Remember add import list exclusion when removing movie

Closes #7949
Closes #7950
pull/8414/head
Qstick 2 years ago
parent 7f71caaf7f
commit c61735cde2

@ -23,8 +23,7 @@ class DeleteMovieModalContent extends Component {
super(props, context);
this.state = {
deleteFiles: false,
addImportExclusion: false
deleteFiles: false
};
}
@ -35,15 +34,11 @@ class DeleteMovieModalContent extends Component {
this.setState({ deleteFiles: value });
};
onAddImportExclusionChange = ({ value }) => {
this.setState({ addImportExclusion: value });
};
onDeleteMovieConfirmed = () => {
const deleteFiles = this.state.deleteFiles;
const addImportExclusion = this.state.addImportExclusion;
const addImportExclusion = this.props.deleteOptions.addImportExclusion;
this.setState({ deleteFiles: false, addImportExclusion: false });
this.setState({ deleteFiles: false });
this.props.onDeletePress(deleteFiles, addImportExclusion);
};
@ -55,12 +50,14 @@ class DeleteMovieModalContent extends Component {
title,
path,
hasFile,
deleteOptions,
sizeOnDisk,
onModalClose
onModalClose,
onDeleteOptionChange
} = this.props;
const deleteFiles = this.state.deleteFiles;
const addImportExclusion = this.state.addImportExclusion;
const addImportExclusion = deleteOptions.addImportExclusion;
let deleteFilesLabel = hasFile ? translate('DeleteFileLabel', [1]) : translate('DeleteFilesLabel', [0]);
let deleteFilesHelpText = translate('DeleteFilesHelpText');
@ -99,7 +96,7 @@ class DeleteMovieModalContent extends Component {
value={addImportExclusion}
helpText={translate('AddImportExclusionHelpText')}
kind={kinds.DANGER}
onChange={this.onAddImportExclusionChange}
onChange={onDeleteOptionChange}
/>
</FormGroup>
@ -156,6 +153,8 @@ DeleteMovieModalContent.propTypes = {
path: PropTypes.string.isRequired,
hasFile: PropTypes.bool.isRequired,
sizeOnDisk: PropTypes.number.isRequired,
deleteOptions: PropTypes.object.isRequired,
onDeleteOptionChange: PropTypes.func.isRequired,
onDeletePress: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired
};

@ -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);

@ -22,14 +22,14 @@ interface DeleteMovieModalContentProps {
}
const selectDeleteOptions = createSelector(
(state) => state.movie.deleteOptions,
(state) => state.movies.deleteOptions,
(deleteOptions) => deleteOptions
);
function DeleteMovieModalContent(props: DeleteMovieModalContentProps) {
const { movieIds, onModalClose } = props;
const { addImportListExclusion } = useSelector(selectDeleteOptions);
const { addImportExclusion } = useSelector(selectDeleteOptions);
const allMovies = useSelector(createAllMoviesSelector());
const dispatch = useDispatch();
@ -68,7 +68,7 @@ function DeleteMovieModalContent(props: DeleteMovieModalContentProps) {
bulkDeleteMovie({
movieIds,
deleteFiles,
addImportListExclusion,
addImportExclusion,
})
);
@ -76,7 +76,7 @@ function DeleteMovieModalContent(props: DeleteMovieModalContentProps) {
}, [
movieIds,
deleteFiles,
addImportListExclusion,
addImportExclusion,
setDeleteFiles,
dispatch,
onModalClose,
@ -93,8 +93,8 @@ function DeleteMovieModalContent(props: DeleteMovieModalContentProps) {
<FormInputGroup
type={inputTypes.CHECK}
name="addImportListExclusion"
value={addImportListExclusion}
name="addImportExclusion"
value={addImportExclusion}
helpText={translate('AddImportExclusionHelpText')}
onChange={onDeleteOptionChange}
/>

@ -70,6 +70,9 @@ function MovieIndexRow(props: MovieIndexRowProps) {
tags = [],
tmdbId,
imdbId,
isAvailable,
grabbed,
movieFile,
youTubeTrailerId,
isSaving = false,
movieRuntimeFormat,
@ -310,7 +313,10 @@ function MovieIndexRow(props: MovieIndexRowProps) {
return (
<VirtualTableRowCell key={name} className={styles[name]}>
<MovieFileStatusConnector
movieId={movieId}
isAvailable={isAvailable}
monitored={monitored}
grabbed={grabbed}
movieFile={movieFile}
queueStatus={queueStatus}
queueState={queueState}
/>

@ -2,21 +2,14 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import createMovieSelector from 'Store/Selectors/createMovieSelector';
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
import MovieFileStatus from './MovieFileStatus';
function createMapStateToProps() {
return createSelector(
createMovieSelector(),
createUISettingsSelector(),
(movie, uiSettings) => {
(uiSettings) => {
return {
inCinemas: movie.inCinemas,
isAvailable: movie.isAvailable,
monitored: movie.monitored,
grabbed: movie.grabbed,
movieFile: movie.movieFile,
colorImpairedMode: uiSettings.enableColorImpairedMode
};
}
@ -41,7 +34,10 @@ class MovieFileStatusConnector extends Component {
}
MovieFileStatusConnector.propTypes = {
movieId: PropTypes.number.isRequired,
isAvailable: PropTypes.bool,
monitored: PropTypes.bool,
grabbed: PropTypes.bool,
movieFile: PropTypes.object,
queueStatus: PropTypes.string,
queueState: PropTypes.string
};

Loading…
Cancel
Save