New: Remember add import list exclusion when removing series

Closes #4984
pull/5334/head
Mark McDowall 2 years ago
parent 2fc76a9ac5
commit d8f6eaebdc

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

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

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

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

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

Loading…
Cancel
Save