Revert "Temp8 tinymce"

This commit is contained in:
Warren Buckley
2018-11-22 14:05:51 +00:00
committed by GitHub
parent 2a0748fc1e
commit 54a2aa00a7
6677 changed files with 646351 additions and 410535 deletions

View File

@@ -10,8 +10,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
public abstract class AbstractConfigCheck : HealthCheck
{
private readonly ConfigurationService _configurationService;
protected ILocalizedTextService TextService { get; }
private readonly ILocalizedTextService _textService;
/// <summary>
/// Gets the config file path.
@@ -51,21 +50,27 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
get { return false; }
}
protected AbstractConfigCheck(ILocalizedTextService textService)
protected AbstractConfigCheck(HealthCheckContext healthCheckContext) : base(healthCheckContext)
{
TextService = textService;
_configurationService = new ConfigurationService(AbsoluteFilePath, XPath, textService);
_textService = healthCheckContext.ApplicationContext.Services.TextService;
_configurationService = new ConfigurationService(AbsoluteFilePath, XPath, _textService);
}
/// <summary>
/// Gets the name of the file.
/// </summary>
private string FileName => Path.GetFileName(FilePath);
private string FileName
{
get { return Path.GetFileName(FilePath); }
}
/// <summary>
/// Gets the absolute file path.
/// </summary>
private string AbsoluteFilePath => IOHelper.MapPath(FilePath);
private string AbsoluteFilePath
{
get { return IOHelper.MapPath(FilePath); }
}
/// <summary>
/// Gets the message for when the check has succeeded.
@@ -74,7 +79,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
{
get
{
return TextService.Localize("healthcheck/checkSuccessMessage",
return _textService.Localize("healthcheck/checkSuccessMessage",
new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, XPath, AbsoluteFilePath });
}
}
@@ -87,9 +92,9 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
get
{
return ValueComparisonType == ValueComparisonType.ShouldEqual
? TextService.Localize("healthcheck/checkErrorMessageDifferentExpectedValue",
? _textService.Localize("healthcheck/checkErrorMessageDifferentExpectedValue",
new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, XPath, AbsoluteFilePath })
: TextService.Localize("healthcheck/checkErrorMessageUnexpectedValue",
: _textService.Localize("healthcheck/checkErrorMessageUnexpectedValue",
new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, XPath, AbsoluteFilePath });
}
}
@@ -105,7 +110,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
var rectifiedValue = recommendedValue != null
? recommendedValue.Value
: ProvidedValue;
return TextService.Localize("healthcheck/rectifySuccessMessage",
return _textService.Localize("healthcheck/rectifySuccessMessage",
new[]
{
CurrentValue,
@@ -119,12 +124,18 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
/// <summary>
/// Gets a value indicating whether this check can be rectified automatically.
/// </summary>
public virtual bool CanRectify => ValueComparisonType == ValueComparisonType.ShouldEqual;
public virtual bool CanRectify
{
get { return ValueComparisonType == ValueComparisonType.ShouldEqual; }
}
/// <summary>
/// Gets a value indicating whether this check can be rectified automatically if a value is provided.
/// </summary>
public virtual bool CanRectifyWithValue => ValueComparisonType == ValueComparisonType.ShouldNotEqual;
public virtual bool CanRectifyWithValue
{
get { return ValueComparisonType == ValueComparisonType.ShouldNotEqual; }
}
public override IEnumerable<HealthCheckStatus> GetStatus()
{
@@ -156,7 +167,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
// Declare the action for rectifying the config value
var rectifyAction = new HealthCheckAction("rectify", Id)
{
Name = TextService.Localize("healthcheck/rectifyButton"),
Name = _textService.Localize("healthcheck/rectifyButton"),
ValueRequired = CanRectifyWithValue,
};
@@ -178,7 +189,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
public virtual HealthCheckStatus Rectify()
{
if (ValueComparisonType == ValueComparisonType.ShouldNotEqual)
throw new InvalidOperationException(TextService.Localize("healthcheck/cannotRectifyShouldNotEqual"));
throw new InvalidOperationException(_textService.Localize("healthcheck/cannotRectifyShouldNotEqual"));
var recommendedValue = Values.First(v => v.IsRecommended).Value;
return UpdateConfigurationValue(recommendedValue);
@@ -192,10 +203,10 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
public virtual HealthCheckStatus Rectify(string value)
{
if (ValueComparisonType == ValueComparisonType.ShouldEqual)
throw new InvalidOperationException(TextService.Localize("healthcheck/cannotRectifyShouldEqualWithValue"));
throw new InvalidOperationException(_textService.Localize("healthcheck/cannotRectifyShouldEqualWithValue"));
if (string.IsNullOrWhiteSpace(value))
throw new InvalidOperationException(TextService.Localize("healthcheck/valueToRectifyNotProvided"));
throw new InvalidOperationException(_textService.Localize("healthcheck/valueToRectifyNotProvided"));
// Need to track provided value in order to correctly put together the rectify message
ProvidedValue = value;
@@ -224,4 +235,4 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
: Rectify(action.ProvidedValue);
}
}
}
}

View File

@@ -1,8 +1,8 @@
namespace Umbraco.Web.HealthCheck.Checks.Config
namespace Umbraco.Web.HealthCheck.Checks.Config
{
public class AcceptableConfiguration
{
public string Value { get; set; }
public bool IsRecommended { get; set; }
}
}
}

View File

@@ -8,27 +8,57 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
Group = "Live Environment")]
public class CompilationDebugCheck : AbstractConfigCheck
{
public CompilationDebugCheck(ILocalizedTextService textService)
: base(textService)
{ }
private readonly ILocalizedTextService _textService;
public override string FilePath => "~/Web.config";
public override string XPath => "/configuration/system.web/compilation/@debug";
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldEqual;
public override bool ValidIfConfigMissing => true;
public override IEnumerable<AcceptableConfiguration> Values => new List<AcceptableConfiguration>
public CompilationDebugCheck(HealthCheckContext healthCheckContext) : base(healthCheckContext)
{
new AcceptableConfiguration { IsRecommended = true, Value = bool.FalseString.ToLower() }
};
_textService = healthCheckContext.ApplicationContext.Services.TextService;
}
public override string CheckSuccessMessage => TextService.Localize("healthcheck/compilationDebugCheckSuccessMessage");
public override string FilePath
{
get { return "~/Web.config"; }
}
public override string CheckErrorMessage => TextService.Localize("healthcheck/compilationDebugCheckErrorMessage");
public override string XPath
{
get { return "/configuration/system.web/compilation/@debug"; }
}
public override string RectifySuccessMessage => TextService.Localize("healthcheck/compilationDebugCheckRectifySuccessMessage");
public override ValueComparisonType ValueComparisonType
{
get { return ValueComparisonType.ShouldEqual; }
}
public override bool ValidIfConfigMissing
{
get { return true; }
}
public override IEnumerable<AcceptableConfiguration> Values
{
get
{
return new List<AcceptableConfiguration>
{
new AcceptableConfiguration { IsRecommended = true, Value = bool.FalseString.ToLower() }
};
}
}
public override string CheckSuccessMessage
{
get { return _textService.Localize("healthcheck/compilationDebugCheckSuccessMessage"); }
}
public override string CheckErrorMessage
{
get { return _textService.Localize("healthcheck/compilationDebugCheckErrorMessage"); }
}
public override string RectifySuccessMessage
{
get { return _textService.Localize("healthcheck/compilationDebugCheckRectifySuccessMessage"); }
}
}
}
}

View File

@@ -1,9 +1,8 @@
using System;
using System;
using System.IO;
using System.Xml;
using Umbraco.Core.Logging;
using Umbraco.Core.Services;
using Umbraco.Web.Composing;
namespace Umbraco.Web.HealthCheck.Checks.Config
{
@@ -26,7 +25,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
}
/// <summary>
/// Gets a value from a given configuration file with the given XPath
/// Gets a value from a given configuration file with the given XPath
/// </summary>
public ConfigurationServiceResult GetConfigurationValue()
{
@@ -56,19 +55,19 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
Result = string.Format(xmlNode.Value ?? xmlNode.InnerText)
};
}
catch (Exception ex)
catch (Exception exception)
{
Current.Logger.Error<ConfigurationService>(ex, "Error trying to get configuration value");
LogHelper.Error<ConfigurationService>("Error trying to get configuration value", exception);
return new ConfigurationServiceResult
{
Success = false,
Result = _textService.Localize("healthcheck/configurationServiceError", new[] { ex.Message })
Result = _textService.Localize("healthcheck/configurationServiceError", new[] { exception.Message })
};
}
}
/// <summary>
/// Updates a value in a given configuration file with the given XPath
/// Updates a value in a given configuration file with the given XPath
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
@@ -102,15 +101,15 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
xmlDocument.Save(_configFilePath);
return new ConfigurationServiceResult { Success = true };
}
catch (Exception ex)
catch (Exception exception)
{
Current.Logger.Error<ConfigurationService>(ex, "Error trying to update configuration");
LogHelper.Error<ConfigurationService>("Error trying to update configuration", exception);
return new ConfigurationServiceResult
{
Success = false,
Result = _textService.Localize("healthcheck/configurationServiceError", new[] { ex.Message })
Result = _textService.Localize("healthcheck/configurationServiceError", new[] { exception.Message })
};
}
}
}
}
}

View File

@@ -1,8 +1,8 @@
namespace Umbraco.Web.HealthCheck.Checks.Config
namespace Umbraco.Web.HealthCheck.Checks.Config
{
public class ConfigurationServiceResult
{
public bool Success { get; set; }
public string Result { get; set; }
}
}
}

View File

@@ -10,27 +10,46 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
Group = "Live Environment")]
public class CustomErrorsCheck : AbstractConfigCheck
{
public CustomErrorsCheck(ILocalizedTextService textService)
: base(textService)
{ }
private readonly ILocalizedTextService _textService;
public override string FilePath => "~/Web.config";
public override string XPath => "/configuration/system.web/customErrors/@mode";
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldEqual;
public override IEnumerable<AcceptableConfiguration> Values => new List<AcceptableConfiguration>
public CustomErrorsCheck(HealthCheckContext healthCheckContext) : base(healthCheckContext)
{
new AcceptableConfiguration { IsRecommended = true, Value = CustomErrorsMode.RemoteOnly.ToString() },
new AcceptableConfiguration { IsRecommended = false, Value = "On" }
};
_textService = healthCheckContext.ApplicationContext.Services.TextService;
}
public override string FilePath
{
get { return "~/Web.config"; }
}
public override string XPath
{
get { return "/configuration/system.web/customErrors/@mode"; }
}
public override ValueComparisonType ValueComparisonType
{
get { return ValueComparisonType.ShouldEqual; }
}
public override IEnumerable<AcceptableConfiguration> Values
{
get
{
return new List<AcceptableConfiguration>
{
new AcceptableConfiguration { IsRecommended = true, Value = CustomErrorsMode.RemoteOnly.ToString() },
new AcceptableConfiguration { IsRecommended = false, Value = "On" }
};
}
}
public override string CheckSuccessMessage
{
get
{
return TextService.Localize("healthcheck/customErrorsCheckSuccessMessage", new[] { CurrentValue });
return _textService.Localize("healthcheck/customErrorsCheckSuccessMessage",
new[] { CurrentValue });
}
}
@@ -38,7 +57,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
{
get
{
return TextService.Localize("healthcheck/customErrorsCheckErrorMessage",
return _textService.Localize("healthcheck/customErrorsCheckErrorMessage",
new[] { CurrentValue, Values.First(v => v.IsRecommended).Value });
}
}
@@ -47,9 +66,9 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
{
get
{
return TextService.Localize("healthcheck/customErrorsCheckRectifySuccessMessage",
return _textService.Localize("healthcheck/customErrorsCheckRectifySuccessMessage",
new[] { Values.First(v => v.IsRecommended).Value });
}
}
}
}
}

View File

@@ -9,15 +9,27 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
Group = "Configuration")]
public class MacroErrorsCheck : AbstractConfigCheck
{
public MacroErrorsCheck(ILocalizedTextService textService)
: base(textService)
{ }
private readonly ILocalizedTextService _textService;
public override string FilePath => "~/Config/umbracoSettings.config";
public MacroErrorsCheck(HealthCheckContext healthCheckContext) : base(healthCheckContext)
{
_textService = healthCheckContext.ApplicationContext.Services.TextService;
}
public override string XPath => "/settings/content/MacroErrors";
public override string FilePath
{
get { return "~/Config/umbracoSettings.config"; }
}
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldEqual;
public override string XPath
{
get { return "/settings/content/MacroErrors"; }
}
public override ValueComparisonType ValueComparisonType
{
get { return ValueComparisonType.ShouldEqual; }
}
public override IEnumerable<AcceptableConfiguration> Values
{
@@ -40,12 +52,12 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
return values;
}
}
public override string CheckSuccessMessage
{
get
{
return TextService.Localize("healthcheck/macroErrorModeCheckSuccessMessage",
return _textService.Localize("healthcheck/macroErrorModeCheckSuccessMessage",
new[] { CurrentValue, Values.First(v => v.IsRecommended).Value });
}
}
@@ -54,7 +66,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
{
get
{
return TextService.Localize("healthcheck/macroErrorModeCheckErrorMessage",
return _textService.Localize("healthcheck/macroErrorModeCheckErrorMessage",
new[] { CurrentValue, Values.First(v => v.IsRecommended).Value });
}
}
@@ -63,9 +75,9 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
{
get
{
return TextService.Localize("healthcheck/macroErrorModeCheckRectifySuccessMessage",
return _textService.Localize("healthcheck/macroErrorModeCheckRectifySuccessMessage",
new[] { Values.First(v => v.IsRecommended).Value });
}
}
}
}
}

View File

@@ -8,25 +8,48 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
Group = "Configuration")]
public class NotificationEmailCheck : AbstractConfigCheck
{
private readonly ILocalizedTextService _textService;
private const string DefaultFromEmail = "your@email.here";
public NotificationEmailCheck(ILocalizedTextService textService)
: base(textService)
{ }
public override string FilePath => "~/Config/umbracoSettings.config";
public override string XPath => "/settings/content/notifications/email";
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldNotEqual;
public override IEnumerable<AcceptableConfiguration> Values => new List<AcceptableConfiguration>
public NotificationEmailCheck(HealthCheckContext healthCheckContext) : base(healthCheckContext)
{
new AcceptableConfiguration { IsRecommended = false, Value = DefaultFromEmail }
};
_textService = healthCheckContext.ApplicationContext.Services.TextService;
}
public override string CheckSuccessMessage => TextService.Localize("healthcheck/notificationEmailsCheckSuccessMessage", new [] { CurrentValue } );
public override string FilePath
{
get { return "~/Config/umbracoSettings.config"; }
}
public override string CheckErrorMessage => TextService.Localize("healthcheck/notificationEmailsCheckErrorMessage", new[] { DefaultFromEmail });
public override string XPath
{
get { return "/settings/content/notifications/email"; }
}
public override ValueComparisonType ValueComparisonType
{
get { return ValueComparisonType.ShouldNotEqual; }
}
public override IEnumerable<AcceptableConfiguration> Values
{
get
{
return new List<AcceptableConfiguration>
{
new AcceptableConfiguration { IsRecommended = false, Value = DefaultFromEmail }
};
}
}
public override string CheckSuccessMessage
{
get { return _textService.Localize("healthcheck/notificationEmailsCheckSuccessMessage", new [] { CurrentValue } ); }
}
public override string CheckErrorMessage
{
get { return _textService.Localize("healthcheck/notificationEmailsCheckErrorMessage", new[] { DefaultFromEmail }); }
}
}
}
}

View File

@@ -8,26 +8,52 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
Group = "Live Environment")]
public class TraceCheck : AbstractConfigCheck
{
private readonly ILocalizedTextService _textService;
public TraceCheck(ILocalizedTextService textService)
: base(textService)
{ }
public override string FilePath => "~/Web.config";
public override string XPath => "/configuration/system.web/trace/@enabled";
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldEqual;
public override IEnumerable<AcceptableConfiguration> Values => new List<AcceptableConfiguration>
public TraceCheck(HealthCheckContext healthCheckContext) : base(healthCheckContext)
{
new AcceptableConfiguration { IsRecommended = true, Value = bool.FalseString.ToLower() }
};
_textService = healthCheckContext.ApplicationContext.Services.TextService;
}
public override string CheckSuccessMessage => TextService.Localize("healthcheck/traceModeCheckSuccessMessage");
public override string FilePath
{
get { return "~/Web.config"; }
}
public override string CheckErrorMessage => TextService.Localize("healthcheck/traceModeCheckErrorMessage");
public override string XPath
{
get { return "/configuration/system.web/trace/@enabled"; }
}
public override string RectifySuccessMessage => TextService.Localize("healthcheck/traceModeCheckRectifySuccessMessage");
public override ValueComparisonType ValueComparisonType
{
get { return ValueComparisonType.ShouldEqual; }
}
public override IEnumerable<AcceptableConfiguration> Values
{
get
{
return new List<AcceptableConfiguration>
{
new AcceptableConfiguration { IsRecommended = true, Value = bool.FalseString.ToLower() }
};
}
}
public override string CheckSuccessMessage
{
get { return _textService.Localize("healthcheck/traceModeCheckSuccessMessage"); }
}
public override string CheckErrorMessage
{
get { return _textService.Localize("healthcheck/traceModeCheckErrorMessage"); }
}
public override string RectifySuccessMessage
{
get { return _textService.Localize("healthcheck/traceModeCheckRectifySuccessMessage"); }
}
}
}
}

View File

@@ -12,16 +12,27 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
public class TrySkipIisCustomErrorsCheck : AbstractConfigCheck
{
private readonly Version _serverVersion = HttpRuntime.IISVersion;
private readonly ILocalizedTextService _textService;
public TrySkipIisCustomErrorsCheck(ILocalizedTextService textService)
: base(textService)
{ }
public TrySkipIisCustomErrorsCheck(HealthCheckContext healthCheckContext) : base(healthCheckContext)
{
_textService = healthCheckContext.ApplicationContext.Services.TextService;
}
public override string FilePath => "~/Config/umbracoSettings.config";
public override string FilePath
{
get { return "~/Config/umbracoSettings.config"; }
}
public override string XPath => "/settings/web.routing/@trySkipIisCustomErrors";
public override string XPath
{
get { return "/settings/web.routing/@trySkipIisCustomErrors"; }
}
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldEqual;
public override ValueComparisonType ValueComparisonType
{
get { return ValueComparisonType.ShouldEqual; }
}
public override IEnumerable<AcceptableConfiguration> Values
{
@@ -39,7 +50,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
{
get
{
return TextService.Localize("healthcheck/trySkipIisCustomErrorsCheckSuccessMessage",
return _textService.Localize("healthcheck/trySkipIisCustomErrorsCheckSuccessMessage",
new[] { Values.First(v => v.IsRecommended).Value, _serverVersion.ToString() });
}
}
@@ -48,7 +59,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
{
get
{
return TextService.Localize("healthcheck/trySkipIisCustomErrorsCheckErrorMessage",
return _textService.Localize("healthcheck/trySkipIisCustomErrorsCheckErrorMessage",
new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, _serverVersion.ToString() });
}
}
@@ -57,9 +68,9 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
{
get
{
return TextService.Localize("healthcheck/trySkipIisCustomErrorsCheckRectifySuccessMessage",
return _textService.Localize("healthcheck/trySkipIisCustomErrorsCheckRectifySuccessMessage",
new[] { Values.First(v => v.IsRecommended).Value, _serverVersion.ToString() });
}
}
}
}
}

View File

@@ -5,4 +5,4 @@
ShouldEqual,
ShouldNotEqual,
}
}
}