From 7b01c85c76b93be360ee89b64a7b6572e7d78e4f Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 22 Jul 2023 02:16:05 +0300 Subject: [PATCH] Fixed: Ensure the default monitoring type in Album Studio is not all --- frontend/src/AlbumStudio/AlbumStudioFooter.js | 25 +++++++++++-------- .../Form/MonitorAlbumsSelectInput.js | 4 ++- .../Form/MonitorNewItemsSelectInput.js | 4 ++- .../AlbumStudio/AlbumStudioController.cs | 18 +++++++------ src/NzbDrone.Core/Localization/Core/en.json | 4 +++ .../Music/Model/MonitoringOptions.cs | 1 + .../Music/Services/AlbumMonitoredService.cs | 9 ++++--- 7 files changed, 40 insertions(+), 25 deletions(-) diff --git a/frontend/src/AlbumStudio/AlbumStudioFooter.js b/frontend/src/AlbumStudio/AlbumStudioFooter.js index 1e56b9cf4..fbdaefa13 100644 --- a/frontend/src/AlbumStudio/AlbumStudioFooter.js +++ b/frontend/src/AlbumStudio/AlbumStudioFooter.js @@ -1,11 +1,11 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import FormInputGroup from 'Components/Form/FormInputGroup'; import MonitorAlbumsSelectInput from 'Components/Form/MonitorAlbumsSelectInput'; import MonitorNewItemsSelectInput from 'Components/Form/MonitorNewItemsSelectInput'; -import SelectInput from 'Components/Form/SelectInput'; import SpinnerButton from 'Components/Link/SpinnerButton'; import PageContentFooter from 'Components/Page/PageContentFooter'; -import { kinds } from 'Helpers/Props'; +import { inputTypes, kinds } from 'Helpers/Props'; import translate from 'Utilities/String/translate'; import styles from './AlbumStudioFooter.css'; @@ -30,7 +30,7 @@ class AlbumStudioFooter extends Component { const { isSaving, saveError - } = prevProps; + } = this.props; if (prevProps.isSaving && !isSaving && !saveError) { this.setState({ @@ -89,8 +89,8 @@ class AlbumStudioFooter extends Component { const monitoredOptions = [ { key: NO_CHANGE, value: translate('NoChange'), disabled: true }, - { key: 'monitored', value: 'Monitored' }, - { key: 'unmonitored', value: 'Unmonitored' } + { key: 'monitored', value: translate('Monitored') }, + { key: 'unmonitored', value: translate('Unmonitored') } ]; const noChanges = monitored === NO_CHANGE && @@ -101,10 +101,11 @@ class AlbumStudioFooter extends Component {
- Monitor Artist + {translate('MonitorArtist')}
-
- Monitor Existing Albums + {translate('MonitorExistingAlbums')}
@@ -129,13 +131,14 @@ class AlbumStudioFooter extends Component {
- Monitor New Albums + {translate('MonitorNewAlbums')}
@@ -143,7 +146,7 @@ class AlbumStudioFooter extends Component {
- {selectedCount} Artist(s) Selected + {translate('CountArtistsSelected', [selectedCount])}
- Update Selected + {translate('UpdateSelected')}
diff --git a/frontend/src/Components/Form/MonitorAlbumsSelectInput.js b/frontend/src/Components/Form/MonitorAlbumsSelectInput.js index ae94a7160..a10bbb776 100644 --- a/frontend/src/Components/Form/MonitorAlbumsSelectInput.js +++ b/frontend/src/Components/Form/MonitorAlbumsSelectInput.js @@ -7,6 +7,7 @@ import SelectInput from './SelectInput'; function MonitorAlbumsSelectInput(props) { const { includeNoChange, + includeNoChangeDisabled = true, includeMixed, ...otherProps } = props; @@ -17,7 +18,7 @@ function MonitorAlbumsSelectInput(props) { values.unshift({ key: 'noChange', value: translate('NoChange'), - disabled: true + disabled: includeNoChangeDisabled }); } @@ -39,6 +40,7 @@ function MonitorAlbumsSelectInput(props) { MonitorAlbumsSelectInput.propTypes = { includeNoChange: PropTypes.bool.isRequired, + includeNoChangeDisabled: PropTypes.bool, includeMixed: PropTypes.bool.isRequired, onChange: PropTypes.func.isRequired }; diff --git a/frontend/src/Components/Form/MonitorNewItemsSelectInput.js b/frontend/src/Components/Form/MonitorNewItemsSelectInput.js index 66f3c1080..65d8f1b52 100644 --- a/frontend/src/Components/Form/MonitorNewItemsSelectInput.js +++ b/frontend/src/Components/Form/MonitorNewItemsSelectInput.js @@ -7,6 +7,7 @@ import SelectInput from './SelectInput'; function MonitorNewItemsSelectInput(props) { const { includeNoChange, + includeNoChangeDisabled = true, includeMixed, ...otherProps } = props; @@ -17,7 +18,7 @@ function MonitorNewItemsSelectInput(props) { values.unshift({ key: 'noChange', value: translate('NoChange'), - disabled: true + disabled: includeNoChangeDisabled }); } @@ -39,6 +40,7 @@ function MonitorNewItemsSelectInput(props) { MonitorNewItemsSelectInput.propTypes = { includeNoChange: PropTypes.bool.isRequired, + includeNoChangeDisabled: PropTypes.bool, includeMixed: PropTypes.bool.isRequired, onChange: PropTypes.func.isRequired }; diff --git a/src/Lidarr.Api.V1/AlbumStudio/AlbumStudioController.cs b/src/Lidarr.Api.V1/AlbumStudio/AlbumStudioController.cs index edde38573..50f7c3ed3 100644 --- a/src/Lidarr.Api.V1/AlbumStudio/AlbumStudioController.cs +++ b/src/Lidarr.Api.V1/AlbumStudio/AlbumStudioController.cs @@ -18,11 +18,13 @@ namespace Lidarr.Api.V1.AlbumStudio } [HttpPost] - public IActionResult UpdateAll([FromBody] AlbumStudioResource request) + [Consumes("application/json")] + [Produces("application/json")] + public IActionResult UpdateAll([FromBody] AlbumStudioResource resource) { - var artistToUpdate = _artistService.GetArtists(request.Artist.Select(s => s.Id)); + var artistToUpdate = _artistService.GetArtists(resource.Artist.Select(s => s.Id)); - foreach (var s in request.Artist) + foreach (var s in resource.Artist) { var artist = artistToUpdate.Single(c => c.Id == s.Id); @@ -31,20 +33,20 @@ namespace Lidarr.Api.V1.AlbumStudio artist.Monitored = s.Monitored.Value; } - if (request.MonitoringOptions != null && request.MonitoringOptions.Monitor == MonitorTypes.None) + if (resource.MonitoringOptions is { Monitor: MonitorTypes.None }) { artist.Monitored = false; } - if (request.MonitorNewItems.HasValue) + if (resource.MonitorNewItems.HasValue) { - artist.MonitorNewItems = request.MonitorNewItems.Value; + artist.MonitorNewItems = resource.MonitorNewItems.Value; } - _albumMonitoredService.SetAlbumMonitoredStatus(artist, request.MonitoringOptions); + _albumMonitoredService.SetAlbumMonitoredStatus(artist, resource.MonitoringOptions); } - return Accepted(request); + return Accepted(resource); } } } diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index 03232e0b7..1734a2afd 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -165,6 +165,7 @@ "CopyUsingHardlinksHelpTextWarning": "Occasionally, file locks may prevent renaming files that are being seeded. You may temporarily disable seeding and use Lidarr's rename function as a work around.", "CouldntFindAnyResultsForTerm": "Couldn't find any results for '{0}'", "CountAlbums": "{0} albums", + "CountArtistsSelected": "{0} artist(s) selected", "CountDownloadClientsSelected": "{0} download client(s) selected", "CountImportListsSelected": "{0} import list(s) selected", "CountIndexersSelected": "{0} indexer(s) selected", @@ -549,6 +550,8 @@ "MonitorAlbum": "Monitor Album", "MonitorAlbumExistingOnlyWarning": "This is a one off adjustment of the monitored setting for each album. Use the option under Artist/Edit to control what happens for newly added albums", "MonitorArtist": "Monitor Artist", + "MonitorExistingAlbums": "Monitor Existing Albums", + "MonitorNewAlbums": "Monitor New Albums", "MonitorNewItems": "Monitor New Albums", "MonitorNewItemsHelpText": "Which new albums should be monitored", "Monitored": "Monitored", @@ -1017,6 +1020,7 @@ "UpdateCheckUINotWritableMessage": "Cannot install update because UI folder '{0}' is not writable by the user '{1}'.", "UpdateMechanismHelpText": "Use Lidarr's built-in updater or a script", "UpdateScriptPathHelpText": "Path to a custom script that takes an extracted update package and handle the remainder of the update process", + "UpdateSelected": "Update Selected", "Updates": "Updates", "UpdatingIsDisabledInsideADockerContainerUpdateTheContainerImageInstead": "Updating is disabled inside a docker container. Update the container image instead.", "UpgradeAllowedHelpText": "If disabled qualities will not be upgraded", diff --git a/src/NzbDrone.Core/Music/Model/MonitoringOptions.cs b/src/NzbDrone.Core/Music/Model/MonitoringOptions.cs index d50e278c8..f4015f9ab 100644 --- a/src/NzbDrone.Core/Music/Model/MonitoringOptions.cs +++ b/src/NzbDrone.Core/Music/Model/MonitoringOptions.cs @@ -7,6 +7,7 @@ namespace NzbDrone.Core.Music { public MonitoringOptions() { + Monitor = MonitorTypes.Unknown; AlbumsToMonitor = new List(); } diff --git a/src/NzbDrone.Core/Music/Services/AlbumMonitoredService.cs b/src/NzbDrone.Core/Music/Services/AlbumMonitoredService.cs index 4b747074b..b715cb80d 100644 --- a/src/NzbDrone.Core/Music/Services/AlbumMonitoredService.cs +++ b/src/NzbDrone.Core/Music/Services/AlbumMonitoredService.cs @@ -40,10 +40,8 @@ namespace NzbDrone.Core.Music // If specific albums are passed use those instead of the monitoring options. if (monitoredAlbums.Any()) { - ToggleAlbumsMonitoredState( - albums.Where(s => monitoredAlbums.Contains(s.ForeignAlbumId)), true); - ToggleAlbumsMonitoredState( - albums.Where(s => !monitoredAlbums.Contains(s.ForeignAlbumId)), false); + ToggleAlbumsMonitoredState(albums.Where(s => monitoredAlbums.Contains(s.ForeignAlbumId)), true); + ToggleAlbumsMonitoredState(albums.Where(s => !monitoredAlbums.Contains(s.ForeignAlbumId)), false); } else { @@ -81,6 +79,9 @@ namespace NzbDrone.Core.Music ToggleAlbumsMonitoredState(albums, false); ToggleAlbumsMonitoredState(albums.OrderBy(e => e.ReleaseDate).Take(1), true); break; + case MonitorTypes.Unknown: + // Ignoring, it's the default value + break; default: throw new ArgumentOutOfRangeException(); }