Added logging
This commit is contained in:
@@ -412,7 +412,6 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Web.BackOffice.Controllers
|
||||
[Test]
|
||||
public async Task PostSave_Validates_Domains_Exist()
|
||||
{
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
|
||||
ILocalizationService localizationService = GetRequiredService<ILocalizationService>();
|
||||
localizationService.Save(new LanguageBuilder()
|
||||
.WithCultureInfo("da-DK")
|
||||
@@ -445,17 +444,21 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Web.BackOffice.Controllers
|
||||
body = body.TrimStart(AngularJsonMediaTypeFormatter.XsrfPrefix);
|
||||
ContentItemDisplay display = JsonConvert.DeserializeObject<ContentItemDisplay>(body);
|
||||
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
|
||||
ILocalizedTextService localizedTextService = GetRequiredService<ILocalizedTextService>();
|
||||
var expectedMessage = localizedTextService.Localize("speechBubbles", "publishWithNoDomains", new []{"en-US"});
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.IsNotNull(display);
|
||||
Assert.AreEqual(1, display.Notifications.Count(x => x.NotificationType == NotificationStyle.Warning));
|
||||
Assert.AreEqual(expectedMessage, display.Notifications.FirstOrDefault(x => x.NotificationType == NotificationStyle.Warning)?.Message);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task PostSave_Validates_All_Cultures_Has_Domains()
|
||||
{
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
|
||||
var enString = "en-US";
|
||||
var dkString = "da-DK";
|
||||
|
||||
@@ -504,11 +507,14 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Web.BackOffice.Controllers
|
||||
body = body.TrimStart(AngularJsonMediaTypeFormatter.XsrfPrefix);
|
||||
ContentItemDisplay display = JsonConvert.DeserializeObject<ContentItemDisplay>(body);
|
||||
|
||||
ILocalizedTextService localizedTextService = GetRequiredService<ILocalizedTextService>();
|
||||
var expectedMessage = localizedTextService.Localize("speechBubbles", "publishWithMissingDomain", new []{"en-US"});
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.NotNull(display);
|
||||
Assert.AreEqual(1, display.Notifications.Count(x => x.NotificationType == NotificationStyle.Warning));
|
||||
Assert.AreEqual(expectedMessage, display.Notifications.FirstOrDefault(x => x.NotificationType == NotificationStyle.Warning)?.Message);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,8 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Web.BackOffice.Controllers
|
||||
Mock.Of<ISqlContext>(),
|
||||
Mock.Of<IJsonSerializer>(),
|
||||
Mock.Of<IScopeProvider>(),
|
||||
Mock.Of<IAuthorizationService>()
|
||||
Mock.Of<IAuthorizationService>(),
|
||||
Mock.Of<IUserDataService>()
|
||||
);
|
||||
|
||||
return controller;
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
private readonly Lazy<IDictionary<string, ILanguage>> _allLangs;
|
||||
private readonly ILogger<ContentController> _logger;
|
||||
private readonly IScopeProvider _scopeProvider;
|
||||
private readonly IUserDataService _userDataService;
|
||||
|
||||
public object Domains { get; private set; }
|
||||
|
||||
@@ -90,7 +91,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
ISqlContext sqlContext,
|
||||
IJsonSerializer serializer,
|
||||
IScopeProvider scopeProvider,
|
||||
IAuthorizationService authorizationService)
|
||||
IAuthorizationService authorizationService,
|
||||
IUserDataService userDataService)
|
||||
: base(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService, serializer)
|
||||
{
|
||||
_propertyEditors = propertyEditors;
|
||||
@@ -112,6 +114,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
_logger = loggerFactory.CreateLogger<ContentController>();
|
||||
_scopeProvider = scopeProvider;
|
||||
_allLangs = new Lazy<IDictionary<string, ILanguage>>(() => _localizationService.GetAllLanguages().ToDictionary(x => x.IsoCode, x => x, StringComparer.InvariantCultureIgnoreCase));
|
||||
_userDataService = userDataService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1470,14 +1473,17 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
{
|
||||
assignedDomains.UnionWith(_domainService.GetAssignedDomains(ancestorID, true));
|
||||
}
|
||||
|
||||
foreach (var data in _userDataService.GetUserData())
|
||||
{
|
||||
_logger.LogWarning($"{data.Name} : {data.Data}");
|
||||
}
|
||||
// No domains at all, add a warning, to add domains.
|
||||
if (assignedDomains.Count == 0)
|
||||
{
|
||||
globalNotifications.AddWarningNotification(
|
||||
_localizedTextService.Localize("auditTrails", "publish"),
|
||||
_localizedTextService.Localize("speechBubbles", "publishWithNoDomains"));
|
||||
|
||||
_logger.LogWarning("NOT REGISTRED DOMAIN FOR: {Cultures}");
|
||||
_logger.LogWarning("The root node {RootNodeName} was published with multiple cultures, but no domains are configured, this will cause routing and caching issues, please register domains for: {Cultures}",
|
||||
persistedContent.Name, string.Join(", ", publishedCultures));
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user