Fixed: Ensure the default monitoring type in Album Studio is not all

This commit is contained in:
Bogdan 2023-07-22 02:16:05 +03:00
parent 950dcd30f0
commit 7b01c85c76
7 changed files with 40 additions and 25 deletions

View file

@ -1,11 +1,11 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import FormInputGroup from 'Components/Form/FormInputGroup';
import MonitorAlbumsSelectInput from 'Components/Form/MonitorAlbumsSelectInput'; import MonitorAlbumsSelectInput from 'Components/Form/MonitorAlbumsSelectInput';
import MonitorNewItemsSelectInput from 'Components/Form/MonitorNewItemsSelectInput'; import MonitorNewItemsSelectInput from 'Components/Form/MonitorNewItemsSelectInput';
import SelectInput from 'Components/Form/SelectInput';
import SpinnerButton from 'Components/Link/SpinnerButton'; import SpinnerButton from 'Components/Link/SpinnerButton';
import PageContentFooter from 'Components/Page/PageContentFooter'; import PageContentFooter from 'Components/Page/PageContentFooter';
import { kinds } from 'Helpers/Props'; import { inputTypes, kinds } from 'Helpers/Props';
import translate from 'Utilities/String/translate'; import translate from 'Utilities/String/translate';
import styles from './AlbumStudioFooter.css'; import styles from './AlbumStudioFooter.css';
@ -30,7 +30,7 @@ class AlbumStudioFooter extends Component {
const { const {
isSaving, isSaving,
saveError saveError
} = prevProps; } = this.props;
if (prevProps.isSaving && !isSaving && !saveError) { if (prevProps.isSaving && !isSaving && !saveError) {
this.setState({ this.setState({
@ -89,8 +89,8 @@ class AlbumStudioFooter extends Component {
const monitoredOptions = [ const monitoredOptions = [
{ key: NO_CHANGE, value: translate('NoChange'), disabled: true }, { key: NO_CHANGE, value: translate('NoChange'), disabled: true },
{ key: 'monitored', value: 'Monitored' }, { key: 'monitored', value: translate('Monitored') },
{ key: 'unmonitored', value: 'Unmonitored' } { key: 'unmonitored', value: translate('Unmonitored') }
]; ];
const noChanges = monitored === NO_CHANGE && const noChanges = monitored === NO_CHANGE &&
@ -101,10 +101,11 @@ class AlbumStudioFooter extends Component {
<PageContentFooter> <PageContentFooter>
<div className={styles.inputContainer}> <div className={styles.inputContainer}>
<div className={styles.label}> <div className={styles.label}>
Monitor Artist {translate('MonitorArtist')}
</div> </div>
<SelectInput <FormInputGroup
type={inputTypes.SELECT}
name="monitored" name="monitored"
value={monitored} value={monitored}
values={monitoredOptions} values={monitoredOptions}
@ -115,13 +116,14 @@ class AlbumStudioFooter extends Component {
<div className={styles.inputContainer}> <div className={styles.inputContainer}>
<div className={styles.label}> <div className={styles.label}>
Monitor Existing Albums {translate('MonitorExistingAlbums')}
</div> </div>
<MonitorAlbumsSelectInput <MonitorAlbumsSelectInput
name="monitor" name="monitor"
value={monitor} value={monitor}
includeNoChange={true} includeNoChange={true}
includeNoChangeDisabled={false}
isDisabled={!selectedCount} isDisabled={!selectedCount}
onChange={this.onInputChange} onChange={this.onInputChange}
/> />
@ -129,13 +131,14 @@ class AlbumStudioFooter extends Component {
<div className={styles.inputContainer}> <div className={styles.inputContainer}>
<div className={styles.label}> <div className={styles.label}>
Monitor New Albums {translate('MonitorNewAlbums')}
</div> </div>
<MonitorNewItemsSelectInput <MonitorNewItemsSelectInput
name="monitorNewItems" name="monitorNewItems"
value={monitorNewItems} value={monitorNewItems}
includeNoChange={true} includeNoChange={true}
includeNoChangeDisabled={false}
isDisabled={!selectedCount} isDisabled={!selectedCount}
onChange={this.onInputChange} onChange={this.onInputChange}
/> />
@ -143,7 +146,7 @@ class AlbumStudioFooter extends Component {
<div> <div>
<div className={styles.label}> <div className={styles.label}>
{selectedCount} Artist(s) Selected {translate('CountArtistsSelected', [selectedCount])}
</div> </div>
<SpinnerButton <SpinnerButton
@ -153,7 +156,7 @@ class AlbumStudioFooter extends Component {
isDisabled={!selectedCount || noChanges} isDisabled={!selectedCount || noChanges}
onPress={this.onUpdateSelectedPress} onPress={this.onUpdateSelectedPress}
> >
Update Selected {translate('UpdateSelected')}
</SpinnerButton> </SpinnerButton>
</div> </div>
</PageContentFooter> </PageContentFooter>

View file

@ -7,6 +7,7 @@ import SelectInput from './SelectInput';
function MonitorAlbumsSelectInput(props) { function MonitorAlbumsSelectInput(props) {
const { const {
includeNoChange, includeNoChange,
includeNoChangeDisabled = true,
includeMixed, includeMixed,
...otherProps ...otherProps
} = props; } = props;
@ -17,7 +18,7 @@ function MonitorAlbumsSelectInput(props) {
values.unshift({ values.unshift({
key: 'noChange', key: 'noChange',
value: translate('NoChange'), value: translate('NoChange'),
disabled: true disabled: includeNoChangeDisabled
}); });
} }
@ -39,6 +40,7 @@ function MonitorAlbumsSelectInput(props) {
MonitorAlbumsSelectInput.propTypes = { MonitorAlbumsSelectInput.propTypes = {
includeNoChange: PropTypes.bool.isRequired, includeNoChange: PropTypes.bool.isRequired,
includeNoChangeDisabled: PropTypes.bool,
includeMixed: PropTypes.bool.isRequired, includeMixed: PropTypes.bool.isRequired,
onChange: PropTypes.func.isRequired onChange: PropTypes.func.isRequired
}; };

View file

@ -7,6 +7,7 @@ import SelectInput from './SelectInput';
function MonitorNewItemsSelectInput(props) { function MonitorNewItemsSelectInput(props) {
const { const {
includeNoChange, includeNoChange,
includeNoChangeDisabled = true,
includeMixed, includeMixed,
...otherProps ...otherProps
} = props; } = props;
@ -17,7 +18,7 @@ function MonitorNewItemsSelectInput(props) {
values.unshift({ values.unshift({
key: 'noChange', key: 'noChange',
value: translate('NoChange'), value: translate('NoChange'),
disabled: true disabled: includeNoChangeDisabled
}); });
} }
@ -39,6 +40,7 @@ function MonitorNewItemsSelectInput(props) {
MonitorNewItemsSelectInput.propTypes = { MonitorNewItemsSelectInput.propTypes = {
includeNoChange: PropTypes.bool.isRequired, includeNoChange: PropTypes.bool.isRequired,
includeNoChangeDisabled: PropTypes.bool,
includeMixed: PropTypes.bool.isRequired, includeMixed: PropTypes.bool.isRequired,
onChange: PropTypes.func.isRequired onChange: PropTypes.func.isRequired
}; };

View file

@ -18,11 +18,13 @@ namespace Lidarr.Api.V1.AlbumStudio
} }
[HttpPost] [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); var artist = artistToUpdate.Single(c => c.Id == s.Id);
@ -31,20 +33,20 @@ namespace Lidarr.Api.V1.AlbumStudio
artist.Monitored = s.Monitored.Value; artist.Monitored = s.Monitored.Value;
} }
if (request.MonitoringOptions != null && request.MonitoringOptions.Monitor == MonitorTypes.None) if (resource.MonitoringOptions is { Monitor: MonitorTypes.None })
{ {
artist.Monitored = false; 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);
} }
} }
} }

View file

@ -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.", "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}'", "CouldntFindAnyResultsForTerm": "Couldn't find any results for '{0}'",
"CountAlbums": "{0} albums", "CountAlbums": "{0} albums",
"CountArtistsSelected": "{0} artist(s) selected",
"CountDownloadClientsSelected": "{0} download client(s) selected", "CountDownloadClientsSelected": "{0} download client(s) selected",
"CountImportListsSelected": "{0} import list(s) selected", "CountImportListsSelected": "{0} import list(s) selected",
"CountIndexersSelected": "{0} indexer(s) selected", "CountIndexersSelected": "{0} indexer(s) selected",
@ -549,6 +550,8 @@
"MonitorAlbum": "Monitor Album", "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", "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", "MonitorArtist": "Monitor Artist",
"MonitorExistingAlbums": "Monitor Existing Albums",
"MonitorNewAlbums": "Monitor New Albums",
"MonitorNewItems": "Monitor New Albums", "MonitorNewItems": "Monitor New Albums",
"MonitorNewItemsHelpText": "Which new albums should be monitored", "MonitorNewItemsHelpText": "Which new albums should be monitored",
"Monitored": "Monitored", "Monitored": "Monitored",
@ -1017,6 +1020,7 @@
"UpdateCheckUINotWritableMessage": "Cannot install update because UI folder '{0}' is not writable by the user '{1}'.", "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", "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", "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", "Updates": "Updates",
"UpdatingIsDisabledInsideADockerContainerUpdateTheContainerImageInstead": "Updating is disabled inside a docker container. Update the container image instead.", "UpdatingIsDisabledInsideADockerContainerUpdateTheContainerImageInstead": "Updating is disabled inside a docker container. Update the container image instead.",
"UpgradeAllowedHelpText": "If disabled qualities will not be upgraded", "UpgradeAllowedHelpText": "If disabled qualities will not be upgraded",

View file

@ -7,6 +7,7 @@ namespace NzbDrone.Core.Music
{ {
public MonitoringOptions() public MonitoringOptions()
{ {
Monitor = MonitorTypes.Unknown;
AlbumsToMonitor = new List<string>(); AlbumsToMonitor = new List<string>();
} }

View file

@ -40,10 +40,8 @@ namespace NzbDrone.Core.Music
// If specific albums are passed use those instead of the monitoring options. // If specific albums are passed use those instead of the monitoring options.
if (monitoredAlbums.Any()) if (monitoredAlbums.Any())
{ {
ToggleAlbumsMonitoredState( ToggleAlbumsMonitoredState(albums.Where(s => monitoredAlbums.Contains(s.ForeignAlbumId)), true);
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)), false);
} }
else else
{ {
@ -81,6 +79,9 @@ namespace NzbDrone.Core.Music
ToggleAlbumsMonitoredState(albums, false); ToggleAlbumsMonitoredState(albums, false);
ToggleAlbumsMonitoredState(albums.OrderBy(e => e.ReleaseDate).Take(1), true); ToggleAlbumsMonitoredState(albums.OrderBy(e => e.ReleaseDate).Take(1), true);
break; break;
case MonitorTypes.Unknown:
// Ignoring, it's the default value
break;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }