From cd2368f5f3947af8c80d62f7fe19652233993196 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 15 Sep 2020 22:40:25 -0700 Subject: [PATCH] Fixed: Add list exclusion on delete Fixes #3963 --- .../Series/Delete/DeleteSeriesModalContent.js | 1 - .../Editor/Delete/DeleteSeriesModalContent.js | 36 +++++++++++++++---- .../DeleteSeriesModalContentConnector.js | 5 +-- src/NzbDrone.Api/Series/SeriesModule.cs | 2 +- src/NzbDrone.Core/Tv/SeriesService.cs | 4 +-- .../Series/SeriesEditorModule.cs | 2 +- .../Series/SeriesEditorResource.cs | 1 + src/Sonarr.Api.V3/Series/SeriesModule.cs | 3 +- 8 files changed, 40 insertions(+), 14 deletions(-) diff --git a/frontend/src/Series/Delete/DeleteSeriesModalContent.js b/frontend/src/Series/Delete/DeleteSeriesModalContent.js index acda974cd..3aaaafc81 100644 --- a/frontend/src/Series/Delete/DeleteSeriesModalContent.js +++ b/frontend/src/Series/Delete/DeleteSeriesModalContent.js @@ -98,7 +98,6 @@ class DeleteSeriesModalContent extends Component { name="addImportListExclusion" value={addImportListExclusion} helpText="Prevent series from being added to Sonarr by lists" - kind={kinds.DANGER} onChange={this.onAddImportListExclusionChange} /> diff --git a/frontend/src/Series/Editor/Delete/DeleteSeriesModalContent.js b/frontend/src/Series/Editor/Delete/DeleteSeriesModalContent.js index 79c854cad..d26ad6d80 100644 --- a/frontend/src/Series/Editor/Delete/DeleteSeriesModalContent.js +++ b/frontend/src/Series/Editor/Delete/DeleteSeriesModalContent.js @@ -20,7 +20,8 @@ class DeleteSeriesModalContent extends Component { super(props, context); this.state = { - deleteFiles: false + deleteFiles: false, + addImportListExclusion: false }; } @@ -31,11 +32,18 @@ class DeleteSeriesModalContent extends Component { this.setState({ deleteFiles: value }); } - onDeleteSeriesConfirmed = () => { - const deleteFiles = this.state.deleteFiles; + onAddImportListExclusionChange = ({ value }) => { + this.setState({ addImportListExclusion: value }); + } - this.setState({ deleteFiles: false }); - this.props.onDeleteSelectedPress(deleteFiles); + onDeleteSeriesConfirmed = () => { + const { + addImportListExclusion, + deleteFiles + } = this.state; + + this.setState({ deleteFiles: false, addImportListExclusion: false }); + this.props.onDeleteSelectedPress(deleteFiles, addImportListExclusion); } // @@ -46,7 +54,11 @@ class DeleteSeriesModalContent extends Component { series, onModalClose } = this.props; - const deleteFiles = this.state.deleteFiles; + + const { + addImportListExclusion, + deleteFiles + } = this.state; return ( @@ -56,6 +68,18 @@ class DeleteSeriesModalContent extends Component {
+ + Add List Exclusion + + + + {`Delete Series Folder${series.length > 1 ? 's' : ''}`} diff --git a/frontend/src/Series/Editor/Delete/DeleteSeriesModalContentConnector.js b/frontend/src/Series/Editor/Delete/DeleteSeriesModalContentConnector.js index 0513842b7..ed10122e6 100644 --- a/frontend/src/Series/Editor/Delete/DeleteSeriesModalContentConnector.js +++ b/frontend/src/Series/Editor/Delete/DeleteSeriesModalContentConnector.js @@ -31,10 +31,11 @@ function createMapStateToProps() { function createMapDispatchToProps(dispatch, props) { return { - onDeleteSelectedPress(deleteFiles) { + onDeleteSelectedPress(deleteFiles, addImportListExclusion) { dispatch(bulkDeleteSeries({ seriesIds: props.seriesIds, - deleteFiles + deleteFiles, + addImportListExclusion })); props.onModalClose(); diff --git a/src/NzbDrone.Api/Series/SeriesModule.cs b/src/NzbDrone.Api/Series/SeriesModule.cs index 05d56b5f5..abf99c430 100644 --- a/src/NzbDrone.Api/Series/SeriesModule.cs +++ b/src/NzbDrone.Api/Series/SeriesModule.cs @@ -147,7 +147,7 @@ private void DeleteSeries(int id) deleteFiles = Convert.ToBoolean(deleteFilesQuery.Value); } - _seriesService.DeleteSeries(id, deleteFiles); + _seriesService.DeleteSeries(id, deleteFiles, false); } private SeriesResource MapToResource(Core.Tv.Series series, bool includeSeasonImages) diff --git a/src/NzbDrone.Core/Tv/SeriesService.cs b/src/NzbDrone.Core/Tv/SeriesService.cs index baa437780..533a321fd 100644 --- a/src/NzbDrone.Core/Tv/SeriesService.cs +++ b/src/NzbDrone.Core/Tv/SeriesService.cs @@ -22,7 +22,7 @@ public interface ISeriesService Series FindByTitle(string title, int year); Series FindByTitleInexact(string title); Series FindByPath(string path); - void DeleteSeries(int seriesId, bool deleteFiles, bool addImportListExclusion = false); + void DeleteSeries(int seriesId, bool deleteFiles, bool addImportListExclusion); List GetAllSeries(); List AllForTag(int tagId); Series UpdateSeries(Series series, bool updateEpisodesToMatchSeason = true, bool publishUpdatedEvent = true); @@ -145,7 +145,7 @@ public Series FindByTitle(string title, int year) return _seriesRepository.FindByTitle(title.CleanSeriesTitle(), year); } - public void DeleteSeries(int seriesId, bool deleteFiles, bool addImportListExclusion = false) + public void DeleteSeries(int seriesId, bool deleteFiles, bool addImportListExclusion) { var series = _seriesRepository.Get(seriesId); _seriesRepository.Delete(seriesId); diff --git a/src/Sonarr.Api.V3/Series/SeriesEditorModule.cs b/src/Sonarr.Api.V3/Series/SeriesEditorModule.cs index 8770f0aa0..c50f50774 100644 --- a/src/Sonarr.Api.V3/Series/SeriesEditorModule.cs +++ b/src/Sonarr.Api.V3/Series/SeriesEditorModule.cs @@ -106,7 +106,7 @@ private object DeleteSeries() foreach (var seriesId in resource.SeriesIds) { - _seriesService.DeleteSeries(seriesId, resource.DeleteFiles); + _seriesService.DeleteSeries(seriesId, resource.DeleteFiles, resource.AddImportListExclusion); } return new object(); diff --git a/src/Sonarr.Api.V3/Series/SeriesEditorResource.cs b/src/Sonarr.Api.V3/Series/SeriesEditorResource.cs index e1ca3086b..273057ab6 100644 --- a/src/Sonarr.Api.V3/Series/SeriesEditorResource.cs +++ b/src/Sonarr.Api.V3/Series/SeriesEditorResource.cs @@ -16,6 +16,7 @@ public class SeriesEditorResource public ApplyTags ApplyTags { get; set; } public bool MoveFiles { get; set; } public bool DeleteFiles { get; set; } + public bool AddImportListExclusion { get; set; } } public enum ApplyTags diff --git a/src/Sonarr.Api.V3/Series/SeriesModule.cs b/src/Sonarr.Api.V3/Series/SeriesModule.cs index 69f032870..c4e8dc431 100644 --- a/src/Sonarr.Api.V3/Series/SeriesModule.cs +++ b/src/Sonarr.Api.V3/Series/SeriesModule.cs @@ -169,8 +169,9 @@ private void UpdateSeries(SeriesResource seriesResource) private void DeleteSeries(int id) { var deleteFiles = Request.GetBooleanQueryParameter("deleteFiles"); + var addImportListExclusion = Request.GetBooleanQueryParameter("addImportListExclusion"); - _seriesService.DeleteSeries(id, deleteFiles); + _seriesService.DeleteSeries(id, deleteFiles, addImportListExclusion); } private SeriesResource GetSeriesResource(NzbDrone.Core.Tv.Series series, bool includeSeasonImages)