New: Remember add import list exclusion when removing series

Closes #4984
This commit is contained in:
Mark McDowall 2022-12-31 22:17:50 -08:00
parent 2fc76a9ac5
commit d8f6eaebdc
5 changed files with 91 additions and 74 deletions

View File

@ -22,8 +22,7 @@ class DeleteSeriesModalContent extends Component {
super(props, context); super(props, context);
this.state = { this.state = {
deleteFiles: false, deleteFiles: false
addImportListExclusion: false
}; };
} }
@ -34,15 +33,11 @@ class DeleteSeriesModalContent extends Component {
this.setState({ deleteFiles: value }); this.setState({ deleteFiles: value });
}; };
onAddImportListExclusionChange = ({ value }) => {
this.setState({ addImportListExclusion: value });
};
onDeleteSeriesConfirmed = () => { onDeleteSeriesConfirmed = () => {
const deleteFiles = this.state.deleteFiles; const deleteFiles = this.state.deleteFiles;
const addImportListExclusion = this.state.addImportListExclusion; const addImportListExclusion = this.props.deleteOptions.addImportListExclusion;
this.setState({ deleteFiles: false, addImportListExclusion: false }); this.setState({ deleteFiles: false });
this.props.onDeletePress(deleteFiles, addImportListExclusion); this.props.onDeletePress(deleteFiles, addImportListExclusion);
}; };
@ -54,7 +49,9 @@ class DeleteSeriesModalContent extends Component {
title, title,
path, path,
statistics, statistics,
onModalClose deleteOptions,
onModalClose,
onDeleteOptionChange
} = this.props; } = this.props;
const { const {
@ -63,7 +60,7 @@ class DeleteSeriesModalContent extends Component {
} = statistics; } = statistics;
const deleteFiles = this.state.deleteFiles; const deleteFiles = this.state.deleteFiles;
const addImportListExclusion = this.state.addImportListExclusion; const addImportListExclusion = deleteOptions.addImportListExclusion;
let deleteFilesLabel = `Delete ${episodeFileCount} Episode Files`; let deleteFilesLabel = `Delete ${episodeFileCount} Episode Files`;
let deleteFilesHelpText = 'Delete the episode files and series folder'; let deleteFilesHelpText = 'Delete the episode files and series folder';
@ -98,7 +95,7 @@ class DeleteSeriesModalContent extends Component {
name="addImportListExclusion" name="addImportListExclusion"
value={addImportListExclusion} value={addImportListExclusion}
helpText="Prevent series from being added to Sonarr by lists" helpText="Prevent series from being added to Sonarr by lists"
onChange={this.onAddImportListExclusionChange} onChange={onDeleteOptionChange}
/> />
</FormGroup> </FormGroup>
@ -150,6 +147,9 @@ DeleteSeriesModalContent.propTypes = {
title: PropTypes.string.isRequired, title: PropTypes.string.isRequired,
path: PropTypes.string.isRequired, path: PropTypes.string.isRequired,
statistics: PropTypes.object.isRequired, statistics: PropTypes.object.isRequired,
deleteOptions: PropTypes.object.isRequired,
onDeleteOptionChange: PropTypes.func.isRequired,
onAddImportListExclusionChange: PropTypes.func.isRequired,
onDeletePress: PropTypes.func.isRequired, onDeletePress: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired onModalClose: PropTypes.func.isRequired
}; };

View File

@ -1,56 +1,44 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { deleteSeries } from 'Store/Actions/seriesActions'; import { deleteSeries, setDeleteOption } from 'Store/Actions/seriesActions';
import createSeriesSelector from 'Store/Selectors/createSeriesSelector'; import createSeriesSelector from 'Store/Selectors/createSeriesSelector';
import DeleteSeriesModalContent from './DeleteSeriesModalContent'; import DeleteSeriesModalContent from './DeleteSeriesModalContent';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.series.deleteOptions,
createSeriesSelector(), createSeriesSelector(),
(series) => { (deleteOptions, series) => {
return series; return {
...series,
deleteOptions
};
} }
); );
} }
const mapDispatchToProps = { function createMapDispatchToProps(dispatch, props) {
deleteSeries return {
}; setDeleteOption(option) {
dispatch(
setDeleteOption({
[option.name]: option.value
})
);
},
class DeleteSeriesModalContentConnector extends Component { onDeleteSelectedPress(deleteFiles, addImportListExclusion) {
dispatch(
deleteSeries({
id: props.seriesId,
deleteFiles,
addImportListExclusion
})
);
// props.onModalClose(true);
// Listeners }
onDeletePress = (deleteFiles, addImportListExclusion) => {
this.props.deleteSeries({
id: this.props.seriesId,
deleteFiles,
addImportListExclusion
});
this.props.onModalClose(true);
}; };
//
// Render
render() {
return (
<DeleteSeriesModalContent
{...this.props}
onDeletePress={this.onDeletePress}
/>
);
}
} }
DeleteSeriesModalContentConnector.propTypes = { export default connect(createMapStateToProps, createMapDispatchToProps)(DeleteSeriesModalContent);
seriesId: PropTypes.number.isRequired,
onModalClose: PropTypes.func.isRequired,
deleteSeries: PropTypes.func.isRequired
};
export default connect(createMapStateToProps, mapDispatchToProps)(DeleteSeriesModalContentConnector);

View File

@ -20,8 +20,7 @@ class DeleteSeriesModalContent extends Component {
super(props, context); super(props, context);
this.state = { this.state = {
deleteFiles: false, deleteFiles: false
addImportListExclusion: false
}; };
} }
@ -32,17 +31,11 @@ class DeleteSeriesModalContent extends Component {
this.setState({ deleteFiles: value }); this.setState({ deleteFiles: value });
}; };
onAddImportListExclusionChange = ({ value }) => {
this.setState({ addImportListExclusion: value });
};
onDeleteSeriesConfirmed = () => { onDeleteSeriesConfirmed = () => {
const { const deleteFiles = this.state.deleteFiles;
addImportListExclusion, const addImportListExclusion = this.props.deleteOptions.addImportListExclusion;
deleteFiles
} = this.state;
this.setState({ deleteFiles: false, addImportListExclusion: false }); this.setState({ deleteFiles: false });
this.props.onDeleteSelectedPress(deleteFiles, addImportListExclusion); this.props.onDeleteSelectedPress(deleteFiles, addImportListExclusion);
}; };
@ -52,11 +45,12 @@ class DeleteSeriesModalContent extends Component {
render() { render() {
const { const {
series, series,
onModalClose deleteOptions,
onModalClose,
setDeleteOption
} = this.props; } = this.props;
const { const {
addImportListExclusion,
deleteFiles deleteFiles
} = this.state; } = this.state;
@ -74,9 +68,9 @@ class DeleteSeriesModalContent extends Component {
<FormInputGroup <FormInputGroup
type={inputTypes.CHECK} type={inputTypes.CHECK}
name="addImportListExclusion" name="addImportListExclusion"
value={addImportListExclusion} value={deleteOptions.addImportListExclusion}
helpText="Prevent series from being added to Sonarr by lists" helpText="Prevent series from being added to Sonarr by lists"
onChange={this.onAddImportListExclusionChange} onChange={setDeleteOption}
/> />
</FormGroup> </FormGroup>
@ -140,7 +134,9 @@ class DeleteSeriesModalContent extends Component {
DeleteSeriesModalContent.propTypes = { DeleteSeriesModalContent.propTypes = {
series: PropTypes.arrayOf(PropTypes.object).isRequired, series: PropTypes.arrayOf(PropTypes.object).isRequired,
deleteOptions: PropTypes.arrayOf(PropTypes.object).isRequired,
onModalClose: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired,
setDeleteOption: PropTypes.func.isRequired,
onDeleteSelectedPress: PropTypes.func.isRequired onDeleteSelectedPress: PropTypes.func.isRequired
}; };

View File

@ -1,6 +1,7 @@
import _ from 'lodash'; import _ from 'lodash';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { setDeleteOption } from 'Store/Actions/seriesActions';
import { bulkDeleteSeries } from 'Store/Actions/seriesEditorActions'; import { bulkDeleteSeries } from 'Store/Actions/seriesEditorActions';
import createAllSeriesSelector from 'Store/Selectors/createAllSeriesSelector'; import createAllSeriesSelector from 'Store/Selectors/createAllSeriesSelector';
import DeleteSeriesModalContent from './DeleteSeriesModalContent'; import DeleteSeriesModalContent from './DeleteSeriesModalContent';
@ -8,8 +9,9 @@ import DeleteSeriesModalContent from './DeleteSeriesModalContent';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state, { seriesIds }) => seriesIds, (state, { seriesIds }) => seriesIds,
(state) => state.series.deleteOptions,
createAllSeriesSelector(), createAllSeriesSelector(),
(seriesIds, allSeries) => { (seriesIds, deleteOptions, allSeries) => {
const selectedSeries = _.intersectionWith(allSeries, seriesIds, (s, id) => { const selectedSeries = _.intersectionWith(allSeries, seriesIds, (s, id) => {
return s.id === id; return s.id === id;
}); });
@ -23,7 +25,8 @@ function createMapStateToProps() {
}); });
return { return {
series series,
deleteOptions
}; };
} }
); );
@ -31,12 +34,22 @@ function createMapStateToProps() {
function createMapDispatchToProps(dispatch, props) { function createMapDispatchToProps(dispatch, props) {
return { return {
setDeleteOption(option) {
dispatch(
setDeleteOption({
[option.name]: option.value
})
);
},
onDeleteSelectedPress(deleteFiles, addImportListExclusion) { onDeleteSelectedPress(deleteFiles, addImportListExclusion) {
dispatch(bulkDeleteSeries({ dispatch(
seriesIds: props.seriesIds, bulkDeleteSeries({
deleteFiles, seriesIds: props.seriesIds,
addImportListExclusion deleteFiles,
})); addImportListExclusion
})
);
props.onModalClose(); props.onModalClose();
} }

View File

@ -384,9 +384,16 @@ export const defaultState = {
items: [], items: [],
sortKey: 'sortTitle', sortKey: 'sortTitle',
sortDirection: sortDirections.ASCENDING, sortDirection: sortDirections.ASCENDING,
pendingChanges: {} pendingChanges: {},
deleteOptions: {
addImportListExclusion: false
}
}; };
export const persistState = [
'series.deleteOptions'
];
// //
// Actions Types // Actions Types
@ -399,6 +406,8 @@ export const TOGGLE_SERIES_MONITORED = 'series/toggleSeriesMonitored';
export const TOGGLE_SEASON_MONITORED = 'series/toggleSeasonMonitored'; export const TOGGLE_SEASON_MONITORED = 'series/toggleSeasonMonitored';
export const UPDATE_SERIES_MONITOR = 'series/updateSeriesMonitor'; export const UPDATE_SERIES_MONITOR = 'series/updateSeriesMonitor';
export const SET_DELETE_OPTION = 'series/setDeleteOption';
// //
// Action Creators // Action Creators
@ -440,6 +449,8 @@ export const setSeriesValue = createAction(SET_SERIES_VALUE, (payload) => {
}; };
}); });
export const setDeleteOption = createAction(SET_DELETE_OPTION);
// //
// Helpers // Helpers
@ -655,6 +666,15 @@ export const actionHandlers = handleThunks({
export const reducers = createHandleActions({ export const reducers = createHandleActions({
[SET_SERIES_VALUE]: createSetSettingValueReducer(section) [SET_SERIES_VALUE]: createSetSettingValueReducer(section),
[SET_DELETE_OPTION]: (state, { payload }) => {
return {
...state,
deleteOptions: {
...payload
}
};
}
}, defaultState, section); }, defaultState, section);