From 11905b99d3063d68fe17b15f3455258f2d8290b2 Mon Sep 17 00:00:00 2001 From: Stevie Robinson Date: Mon, 27 Mar 2023 08:40:11 +0200 Subject: [PATCH] New: Specials monitoring options --- .../SeriesMonitoringOptionsPopoverContent.js | 10 ++++ .../ChangeMonitoringModalContent.css | 4 ++ .../ChangeMonitoringModalContent.css.d.ts | 1 + .../ChangeMonitoringModalContent.tsx | 16 +++++- .../MonitoringOptionsModalContent.css | 3 ++ .../MonitoringOptionsModalContent.css.d.ts | 7 +++ .../MonitoringOptionsModalContent.js | 22 +++++++- .../src/Utilities/Series/monitorOptions.js | 2 + .../SetEpisodeMontitoredFixture.cs | 52 +++++++++++++++++++ .../Tv/EpisodeMonitoredService.cs | 12 +++++ src/NzbDrone.Core/Tv/MonitoringOptions.cs | 2 + src/Sonarr.Api.V3/openapi.json | 2 + 12 files changed, 129 insertions(+), 4 deletions(-) create mode 100644 frontend/src/Series/MonitoringOptions/MonitoringOptionsModalContent.css create mode 100644 frontend/src/Series/MonitoringOptions/MonitoringOptionsModalContent.css.d.ts diff --git a/frontend/src/AddSeries/SeriesMonitoringOptionsPopoverContent.js b/frontend/src/AddSeries/SeriesMonitoringOptionsPopoverContent.js index e889fbb09..6a08f05af 100644 --- a/frontend/src/AddSeries/SeriesMonitoringOptionsPopoverContent.js +++ b/frontend/src/AddSeries/SeriesMonitoringOptionsPopoverContent.js @@ -35,6 +35,16 @@ function SeriesMonitoringOptionsPopoverContent() { data="Monitor all episodes of the latest season and future seasons" /> + + + +
- {translate('Monitoring')} + + {translate('Monitoring')} + + } + title={translate('Monitoring Options')} + body={} + position={tooltipPositions.RIGHT} + /> + - Monitoring + + Monitoring + + + } + title="Monitoring Options" + body={} + position={tooltipPositions.RIGHT} + /> + e.SeasonNumber == 0); } + [Test] + public void should_monitor_specials() + { + GivenSpecials(); + + var monitoringOptions = new MonitoringOptions + { + Monitor = MonitorTypes.MonitorSpecials + }; + + Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions); + + VerifyMonitored(e => e.SeasonNumber == 0); + } + + [Test] + public void should_unmonitor_specials() + { + GivenSpecials(); + + var monitoringOptions = new MonitoringOptions + { + Monitor = MonitorTypes.UnmonitorSpecials + }; + + Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions); + + VerifyNotMonitored(e => e.SeasonNumber == 0); + } + + [Test] + public void should_unmonitor_specials_after_monitoring() + { + GivenSpecials(); + + var monitoringOptions = new MonitoringOptions + { + Monitor = MonitorTypes.MonitorSpecials + }; + + Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions); + + monitoringOptions = new MonitoringOptions + { + Monitor = MonitorTypes.UnmonitorSpecials + }; + + Subject.SetEpisodeMonitoredStatus(_series, monitoringOptions); + + VerifyNotMonitored(e => e.SeasonNumber == 0); + } + [Test] public void should_not_monitor_season_when_all_episodes_are_monitored_except_latest_season() { diff --git a/src/NzbDrone.Core/Tv/EpisodeMonitoredService.cs b/src/NzbDrone.Core/Tv/EpisodeMonitoredService.cs index eaf1a6235..c0351457a 100644 --- a/src/NzbDrone.Core/Tv/EpisodeMonitoredService.cs +++ b/src/NzbDrone.Core/Tv/EpisodeMonitoredService.cs @@ -100,6 +100,18 @@ namespace NzbDrone.Core.Tv break; + case MonitorTypes.MonitorSpecials: + _logger.Debug("[{0}] Monitoring special episodes", series.Title); + ToggleEpisodesMonitoredState(episodes.Where(e => e.SeasonNumber == 0), true); + + break; + + case MonitorTypes.UnmonitorSpecials: + _logger.Debug("[{0}] Unmonitoring special episodes", series.Title); + ToggleEpisodesMonitoredState(episodes.Where(e => e.SeasonNumber == 0), false); + + break; + case MonitorTypes.None: _logger.Debug("[{0}] Unmonitoring all episodes", series.Title); ToggleEpisodesMonitoredState(episodes, e => false); diff --git a/src/NzbDrone.Core/Tv/MonitoringOptions.cs b/src/NzbDrone.Core/Tv/MonitoringOptions.cs index 9ac1d7710..878a9f8e1 100644 --- a/src/NzbDrone.Core/Tv/MonitoringOptions.cs +++ b/src/NzbDrone.Core/Tv/MonitoringOptions.cs @@ -19,6 +19,8 @@ namespace NzbDrone.Core.Tv FirstSeason, LatestSeason, Pilot, + MonitorSpecials, + UnmonitorSpecials, None } } diff --git a/src/Sonarr.Api.V3/openapi.json b/src/Sonarr.Api.V3/openapi.json index 0a6d4ebcc..6b4c5c624 100644 --- a/src/Sonarr.Api.V3/openapi.json +++ b/src/Sonarr.Api.V3/openapi.json @@ -9150,6 +9150,8 @@ "firstSeason", "latestSeason", "pilot", + "monitorSpecials", + "UnmonitorSpecials", "none" ], "type": "string"