Removed hard-coded email validation for healthcheck fix value. (#5557)
Made validation for healthchcls more flexible, supporting none, email and regex. Co-authored-by: Nathan Woulfe <nathan@nathanw.com.au>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function HealthCheckController($scope, healthCheckResource) {
|
||||
function HealthCheckController(healthCheckResource) {
|
||||
var SUCCESS = 0;
|
||||
var WARNING = 1;
|
||||
var ERROR = 2;
|
||||
@@ -19,6 +19,7 @@
|
||||
vm.checkAllInGroup = checkAllInGroup;
|
||||
vm.openGroup = openGroup;
|
||||
vm.setViewState = setViewState;
|
||||
vm.parseRegex = parseRegex;
|
||||
|
||||
// Get a (grouped) list of all health checks
|
||||
healthCheckResource.getAllChecks()
|
||||
@@ -131,6 +132,10 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function parseRegex(regexAsString) {
|
||||
return new RegExp(regexAsString);
|
||||
}
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Dashboard.HealthCheckController", HealthCheckController);
|
||||
|
||||
@@ -133,7 +133,12 @@
|
||||
|
||||
<div ng-if="action.valueRequired">
|
||||
<div><label class="bold">Set new value:</label></div>
|
||||
<input name="providedValue" type="text" ng-model="action.providedValue" required val-email />
|
||||
|
||||
<div ng-switch on="action.providedValueValidation">
|
||||
<input ng-switch-when="email" name="providedValue" type="text" ng-model="action.providedValue" required val-email />
|
||||
<input ng-switch-when="regex" name="providedValue" type="text" ng-model="action.providedValue" required ng-pattern="vm.parseRegex(action.providedValueValidationRegex)" />
|
||||
<input ng-switch-default name="providedValue" type="text" ng-model="action.providedValue" required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<umb-button type="button"
|
||||
|
||||
@@ -43,13 +43,20 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
|
||||
/// </summary>
|
||||
public abstract ValueComparisonType ValueComparisonType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates validation method for provided value
|
||||
/// </summary>
|
||||
public virtual ProvidedValueValidation ProvidedValueValidation => ProvidedValueValidation.None;
|
||||
|
||||
/// <summary>
|
||||
/// If provided value validation requires a regex, it's provided here
|
||||
/// </summary>
|
||||
public virtual string ProvidedValueValidationRegex => string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the flag indicating if the check is considered successful if the config value is missing (defaults to false - an error - if missing)
|
||||
/// </summary>
|
||||
public virtual bool ValidIfConfigMissing
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
public virtual bool ValidIfConfigMissing => false;
|
||||
|
||||
protected AbstractConfigCheck(ILocalizedTextService textService)
|
||||
{
|
||||
@@ -160,6 +167,12 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
|
||||
ValueRequired = CanRectifyWithValue,
|
||||
};
|
||||
|
||||
if (rectifyAction.ValueRequired)
|
||||
{
|
||||
rectifyAction.ProvidedValueValidation = ProvidedValueValidation.ToString().ToLower();
|
||||
rectifyAction.ProvidedValueValidationRegex = ProvidedValueValidationRegex;
|
||||
}
|
||||
|
||||
var resultMessage = string.Format(CheckErrorMessage, FileName, XPath, Values, CurrentValue);
|
||||
return new[]
|
||||
{
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
|
||||
|
||||
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldNotEqual;
|
||||
|
||||
public override ProvidedValueValidation ProvidedValueValidation => ProvidedValueValidation.Email;
|
||||
|
||||
public override IEnumerable<AcceptableConfiguration> Values => new List<AcceptableConfiguration>
|
||||
{
|
||||
new AcceptableConfiguration { IsRecommended = false, Value = DefaultFromEmail }
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Umbraco.Web.HealthCheck.Checks.Config
|
||||
{
|
||||
public enum ProvidedValueValidation
|
||||
{
|
||||
None = 1,
|
||||
Email = 2,
|
||||
Regex = 3
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,18 @@ namespace Umbraco.Web.HealthCheck
|
||||
[DataMember(Name = "valueRequired")]
|
||||
public bool ValueRequired { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if a value required, how it is validated
|
||||
/// </summary>
|
||||
[DataMember(Name = "providedValueValidation")]
|
||||
public string ProvidedValueValidation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if a value required, and is validated by a regex, what the regex to use is
|
||||
/// </summary>
|
||||
[DataMember(Name = "providedValueValidationRegex")]
|
||||
public string ProvidedValueValidationRegex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Provides a value to rectify the issue
|
||||
/// </summary>
|
||||
|
||||
@@ -167,6 +167,7 @@
|
||||
<Compile Include="Editors\KeepAliveController.cs" />
|
||||
<Compile Include="Editors\MacrosController.cs" />
|
||||
<Compile Include="Editors\RelationTypeController.cs" />
|
||||
<Compile Include="HealthCheck\Checks\Config\ProvidedValueValidation.cs" />
|
||||
<Compile Include="Editors\TinyMceController.cs" />
|
||||
<Compile Include="HealthCheck\Checks\Data\DatabaseIntegrityCheck.cs" />
|
||||
<Compile Include="ImageCropperTemplateCoreExtensions.cs" />
|
||||
|
||||
Reference in New Issue
Block a user