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