mirror of
https://github.com/lidarr/Lidarr
synced 2025-03-11 14:33:44 +00:00
Fixed: Validate metadata and quality profiles for root folders
Don't allow `0` as possible value for metadata and quality profiles, and permit to edit root folders with bad values in UI.
This commit is contained in:
parent
838e49ba23
commit
e31f2ad253
4 changed files with 15 additions and 12 deletions
|
@ -7,6 +7,7 @@ import TableRow from 'Components/Table/TableRow';
|
||||||
import TagListConnector from 'Components/TagListConnector';
|
import TagListConnector from 'Components/TagListConnector';
|
||||||
import { createQualityProfileSelectorForHook } from 'Store/Selectors/createQualityProfileSelector';
|
import { createQualityProfileSelectorForHook } from 'Store/Selectors/createQualityProfileSelector';
|
||||||
import { SelectStateInputProps } from 'typings/props';
|
import { SelectStateInputProps } from 'typings/props';
|
||||||
|
import translate from 'Utilities/String/translate';
|
||||||
import styles from './ManageImportListsModalRow.css';
|
import styles from './ManageImportListsModalRow.css';
|
||||||
|
|
||||||
interface ManageImportListsModalRowProps {
|
interface ManageImportListsModalRowProps {
|
||||||
|
@ -63,7 +64,7 @@ function ManageImportListsModalRow(props: ManageImportListsModalRowProps) {
|
||||||
</TableRowCell>
|
</TableRowCell>
|
||||||
|
|
||||||
<TableRowCell className={styles.qualityProfileId}>
|
<TableRowCell className={styles.qualityProfileId}>
|
||||||
{qualityProfile?.name ?? 'None'}
|
{qualityProfile?.name ?? translate('None')}
|
||||||
</TableRowCell>
|
</TableRowCell>
|
||||||
|
|
||||||
<TableRowCell className={styles.rootFolderPath}>
|
<TableRowCell className={styles.rootFolderPath}>
|
||||||
|
@ -71,7 +72,7 @@ function ManageImportListsModalRow(props: ManageImportListsModalRowProps) {
|
||||||
</TableRowCell>
|
</TableRowCell>
|
||||||
|
|
||||||
<TableRowCell className={styles.enableAutomaticAdd}>
|
<TableRowCell className={styles.enableAutomaticAdd}>
|
||||||
{enableAutomaticAdd ? 'Yes' : 'No'}
|
{enableAutomaticAdd ? translate('Yes') : translate('No')}
|
||||||
</TableRowCell>
|
</TableRowCell>
|
||||||
|
|
||||||
<TableRowCell className={styles.tags}>
|
<TableRowCell className={styles.tags}>
|
||||||
|
|
|
@ -75,12 +75,12 @@ class RootFolder extends Component {
|
||||||
{path}
|
{path}
|
||||||
</Label>
|
</Label>
|
||||||
|
|
||||||
<Label kind={kinds.SUCCESS}>
|
<Label kind={qualityProfile?.name ? kinds.SUCCESS : kinds.DANGER}>
|
||||||
{qualityProfile.name}
|
{qualityProfile?.name || translate('None')}
|
||||||
</Label>
|
</Label>
|
||||||
|
|
||||||
<Label kind={kinds.SUCCESS}>
|
<Label kind={metadataProfile?.name ? kinds.SUCCESS : kinds.DANGER}>
|
||||||
{metadataProfile.name}
|
{metadataProfile?.name || translate('None')}
|
||||||
</Label>
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -48,10 +48,12 @@ namespace Lidarr.Api.V1.RootFolders
|
||||||
SharedValidator.RuleFor(c => c.Name)
|
SharedValidator.RuleFor(c => c.Name)
|
||||||
.NotEmpty();
|
.NotEmpty();
|
||||||
|
|
||||||
SharedValidator.RuleFor(c => c.DefaultMetadataProfileId)
|
SharedValidator.RuleFor(c => c.DefaultMetadataProfileId).Cascade(CascadeMode.Stop)
|
||||||
|
.ValidId()
|
||||||
.SetValidator(metadataProfileExistsValidator);
|
.SetValidator(metadataProfileExistsValidator);
|
||||||
|
|
||||||
SharedValidator.RuleFor(c => c.DefaultQualityProfileId)
|
SharedValidator.RuleFor(c => c.DefaultQualityProfileId).Cascade(CascadeMode.Stop)
|
||||||
|
.ValidId()
|
||||||
.SetValidator(qualityProfileExistsValidator);
|
.SetValidator(qualityProfileExistsValidator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,11 @@ namespace NzbDrone.Core.Validation
|
||||||
{
|
{
|
||||||
public class QualityProfileExistsValidator : PropertyValidator
|
public class QualityProfileExistsValidator : PropertyValidator
|
||||||
{
|
{
|
||||||
private readonly IQualityProfileService _profileService;
|
private readonly IQualityProfileService _qualityProfileService;
|
||||||
|
|
||||||
public QualityProfileExistsValidator(IQualityProfileService profileService)
|
public QualityProfileExistsValidator(IQualityProfileService qualityProfileService)
|
||||||
{
|
{
|
||||||
_profileService = profileService;
|
_qualityProfileService = qualityProfileService;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetDefaultMessageTemplate() => "Quality Profile does not exist";
|
protected override string GetDefaultMessageTemplate() => "Quality Profile does not exist";
|
||||||
|
@ -21,7 +21,7 @@ namespace NzbDrone.Core.Validation
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _profileService.Exists((int)context.PropertyValue);
|
return _qualityProfileService.Exists((int)context.PropertyValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue