mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-19 17:32:38 +01:00
Display naming example errors when all fields are empty
This commit is contained in:
parent
be2e1e4fdb
commit
1d286df85d
@ -112,17 +112,13 @@ class Naming extends Component {
|
||||
if (examples.movieExample) {
|
||||
standardMovieFormatHelpTexts.push(`${translate('Movie')}: ${examples.movieExample}`);
|
||||
} else {
|
||||
standardMovieFormatErrors.push({ get message() {
|
||||
return translate('MovieInvalidFormat');
|
||||
} });
|
||||
standardMovieFormatErrors.push({ message: translate('MovieInvalidFormat') });
|
||||
}
|
||||
|
||||
if (examples.movieFolderExample) {
|
||||
movieFolderFormatHelpTexts.push(`${translate('Example')}: ${examples.movieFolderExample}`);
|
||||
} else {
|
||||
movieFolderFormatErrors.push({ get message() {
|
||||
return translate('InvalidFormat');
|
||||
} });
|
||||
movieFolderFormatErrors.push({ message: translate('InvalidFormat') });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import _ from 'lodash';
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
@ -15,11 +14,11 @@ function createMapStateToProps() {
|
||||
(state) => state.settings.advancedSettings,
|
||||
(state) => state.settings.namingExamples,
|
||||
createSettingsSectionSelector(SECTION),
|
||||
(advancedSettings, examples, sectionSettings) => {
|
||||
(advancedSettings, namingExamples, sectionSettings) => {
|
||||
return {
|
||||
advancedSettings,
|
||||
examples: examples.item,
|
||||
examplesPopulated: !_.isEmpty(examples.item),
|
||||
examples: namingExamples.item,
|
||||
examplesPopulated: namingExamples.isPopulated,
|
||||
...sectionSettings
|
||||
};
|
||||
}
|
||||
|
@ -107,7 +107,13 @@ public string BuildFileName(Movie movie, MovieFile movieFile, NamingConfig namin
|
||||
return GetOriginalTitle(movieFile, false);
|
||||
}
|
||||
|
||||
if (namingConfig.StandardMovieFormat.IsNullOrWhiteSpace())
|
||||
{
|
||||
throw new NamingFormatException("Standard movie format cannot be empty");
|
||||
}
|
||||
|
||||
var pattern = namingConfig.StandardMovieFormat;
|
||||
|
||||
var tokenHandlers = new Dictionary<string, Func<TokenMatch, string>>(FileNameBuilderTokenEqualityComparer.Instance);
|
||||
var multipleTokens = TitleRegex.Matches(pattern).Count > 1;
|
||||
|
||||
|
@ -90,6 +90,8 @@ public SampleResult GetMovieSample(NamingConfig nameSpec)
|
||||
var result = new SampleResult
|
||||
{
|
||||
FileName = BuildSample(_movie, _movieFile, nameSpec),
|
||||
Movie = _movie,
|
||||
MovieFile = _movieFile
|
||||
};
|
||||
|
||||
return result;
|
||||
|
@ -17,17 +17,14 @@ public class NamingConfigController : RestController<NamingConfigResource>
|
||||
private readonly INamingConfigService _namingConfigService;
|
||||
private readonly IFilenameSampleService _filenameSampleService;
|
||||
private readonly IFilenameValidationService _filenameValidationService;
|
||||
private readonly IBuildFileNames _filenameBuilder;
|
||||
|
||||
public NamingConfigController(INamingConfigService namingConfigService,
|
||||
IFilenameSampleService filenameSampleService,
|
||||
IFilenameValidationService filenameValidationService,
|
||||
IBuildFileNames filenameBuilder)
|
||||
IFilenameValidationService filenameValidationService)
|
||||
{
|
||||
_namingConfigService = namingConfigService;
|
||||
_filenameSampleService = filenameSampleService;
|
||||
_filenameValidationService = filenameValidationService;
|
||||
_filenameBuilder = filenameBuilder;
|
||||
|
||||
SharedValidator.RuleFor(c => c.StandardMovieFormat).ValidMovieFormat();
|
||||
SharedValidator.RuleFor(c => c.MovieFolderFormat).ValidMovieFolderFormat();
|
||||
@ -72,11 +69,11 @@ public object GetExamples([FromQuery]NamingConfigResource config)
|
||||
var movieSampleResult = _filenameSampleService.GetMovieSample(nameSpec);
|
||||
|
||||
sampleResource.MovieExample = nameSpec.StandardMovieFormat.IsNullOrWhiteSpace()
|
||||
? "Invalid Format"
|
||||
? null
|
||||
: movieSampleResult.FileName;
|
||||
|
||||
sampleResource.MovieFolderExample = nameSpec.MovieFolderFormat.IsNullOrWhiteSpace()
|
||||
? "Invalid format"
|
||||
? null
|
||||
: _filenameSampleService.GetMovieFolderSample(nameSpec);
|
||||
|
||||
return sampleResource;
|
||||
@ -90,6 +87,8 @@ private void ValidateFormatResult(NamingConfig nameSpec)
|
||||
|
||||
var validationFailures = new List<ValidationFailure>();
|
||||
|
||||
validationFailures.AddIfNotNull(standardMovieValidationResult);
|
||||
|
||||
if (validationFailures.Any())
|
||||
{
|
||||
throw new ValidationException(validationFailures.DistinctBy(v => v.PropertyName).ToArray());
|
||||
|
Loading…
Reference in New Issue
Block a user