Merge remote-tracking branch 'origin/v8/dev' into v9/feature/merge-v8-05072021

# Conflicts:
#	build/NuSpecs/UmbracoCms.Web.nuspec
#	src/SolutionInfo.cs
#	src/Umbraco.Core/Compose/RelateOnTrashComponent.cs
#	src/Umbraco.Core/Composing/Current.cs
#	src/Umbraco.Core/Constants-AppSettings.cs
#	src/Umbraco.Core/Constants-SqlTemplates.cs
#	src/Umbraco.Core/Dashboards/ContentDashboardSettings.cs
#	src/Umbraco.Core/Dashboards/IContentDashboardSettings.cs
#	src/Umbraco.Core/Extensions/PublishedPropertyExtension.cs
#	src/Umbraco.Core/HealthChecks/Checks/Services/SmtpCheck.cs
#	src/Umbraco.Core/Models/IReadOnlyContentBase.cs
#	src/Umbraco.Core/Models/Mapping/MemberTabsAndPropertiesMapper.cs
#	src/Umbraco.Core/Models/Mapping/UserMapDefinition.cs
#	src/Umbraco.Core/Models/ReadOnlyContentBaseAdapter.cs
#	src/Umbraco.Core/Persistence/NPocoDatabaseExtensions-Bulk.cs
#	src/Umbraco.Core/PropertyEditors/IPropertyCacheCompression.cs
#	src/Umbraco.Core/PropertyEditors/IPropertyCacheCompressionOptions.cs
#	src/Umbraco.Core/PropertyEditors/MediaPicker3Configuration.cs
#	src/Umbraco.Core/PropertyEditors/NoopPropertyCacheCompressionOptions.cs
#	src/Umbraco.Core/PropertyEditors/PropertyCacheCompression.cs
#	src/Umbraco.Core/Routing/UrlProviderExtensions.cs
#	src/Umbraco.Core/Runtime/CoreRuntime.cs
#	src/Umbraco.Core/Services/ILocalizedTextService.cs
#	src/Umbraco.Core/Services/LocalizedTextServiceExtensions.cs
#	src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs
#	src/Umbraco.Examine/UmbracoContentIndex.cs
#	src/Umbraco.Infrastructure/Examine/GenericIndexDiagnostics.cs
#	src/Umbraco.Infrastructure/IPublishedContentQuery.cs
#	src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs
#	src/Umbraco.Infrastructure/Models/MediaWithCrops.cs
#	src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions.cs
#	src/Umbraco.Infrastructure/Persistence/UmbracoDatabase.cs
#	src/Umbraco.Infrastructure/PropertyEditors/ImageCropperConfiguration.cs
#	src/Umbraco.Infrastructure/PropertyEditors/MediaPicker3PropertyEditor.cs
#	src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs
#	src/Umbraco.Infrastructure/PropertyEditors/UploadFileTypeValidator.cs
#	src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/ImageCropperValue.cs
#	src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/MediaPickerWithCropsValueConverter.cs
#	src/Umbraco.Infrastructure/PublishedContentQuery.cs
#	src/Umbraco.Infrastructure/Search/UmbracoTreeSearcherFields.cs
#	src/Umbraco.Infrastructure/Services/Implement/LocalizedTextService.cs
#	src/Umbraco.Persistence.SqlCe/SqlCeSyntaxProvider.cs
#	src/Umbraco.PublishedCache.NuCache/DataSource/BTree.DictionaryOfPropertyDataSerializer.cs
#	src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs
#	src/Umbraco.PublishedCache.NuCache/DataSource/ContentData.cs
#	src/Umbraco.PublishedCache.NuCache/DataSource/ContentSourceDto.cs
#	src/Umbraco.PublishedCache.NuCache/DataSource/PropertyData.cs
#	src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceVariantsTests.cs
#	src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/ImageCropperTest.cs
#	src/Umbraco.Tests/App.config
#	src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs
#	src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs
#	src/Umbraco.Tests/PublishedContent/NuCacheTests.cs
#	src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs
#	src/Umbraco.Web.BackOffice/Controllers/CodeFileController.cs
#	src/Umbraco.Web.BackOffice/Controllers/ContentController.cs
#	src/Umbraco.Web.BackOffice/Controllers/ContentTypeControllerBase.cs
#	src/Umbraco.Web.BackOffice/Controllers/DashboardController.cs
#	src/Umbraco.Web.BackOffice/Controllers/DataTypeController.cs
#	src/Umbraco.Web.BackOffice/Controllers/MediaController.cs
#	src/Umbraco.Web.BackOffice/Controllers/PackageInstallController.cs
#	src/Umbraco.Web.BackOffice/Controllers/TemplateQueryController.cs
#	src/Umbraco.Web.BackOffice/Mapping/ContentMapDefinition.cs
#	src/Umbraco.Web.BackOffice/Trees/ContentTreeControllerBase.cs
#	src/Umbraco.Web.BackOffice/Trees/DataTypeTreeController.cs
#	src/Umbraco.Web.BackOffice/Trees/MediaTypeTreeController.cs
#	src/Umbraco.Web.Common/Extensions/FriendlyImageCropperTemplateExtensions.cs
#	src/Umbraco.Web.Common/Extensions/ImageCropperTemplateCoreExtensions.cs
#	src/Umbraco.Web.Common/Macros/MacroRenderer.cs
#	src/Umbraco.Web.UI.NetCore/umbraco/config/lang/da.xml
#	src/Umbraco.Web.UI/Umbraco/config/lang/it.xml
#	src/Umbraco.Web.UI/web.Template.Debug.config
#	src/Umbraco.Web.UI/web.Template.config
#	src/Umbraco.Web/Compose/NotificationsComponent.cs
#	src/Umbraco.Web/Composing/ModuleInjector.cs
#	src/Umbraco.Web/Editors/AuthenticationController.cs
#	src/Umbraco.Web/Editors/BackOfficeController.cs
#	src/Umbraco.Web/Editors/ContentTypeController.cs
#	src/Umbraco.Web/Editors/CurrentUserController.cs
#	src/Umbraco.Web/Editors/DictionaryController.cs
#	src/Umbraco.Web/Editors/MediaTypeController.cs
#	src/Umbraco.Web/Editors/MemberController.cs
#	src/Umbraco.Web/Editors/MemberGroupController.cs
#	src/Umbraco.Web/Editors/MemberTypeController.cs
#	src/Umbraco.Web/Editors/NuCacheStatusController.cs
#	src/Umbraco.Web/Editors/UserGroupsController.cs
#	src/Umbraco.Web/Editors/UsersController.cs
#	src/Umbraco.Web/HealthCheck/Checks/Config/AbstractConfigCheck.cs
#	src/Umbraco.Web/HealthCheck/Checks/Config/CompilationDebugCheck.cs
#	src/Umbraco.Web/HealthCheck/Checks/Config/ConfigurationService.cs
#	src/Umbraco.Web/HealthCheck/Checks/Config/CustomErrorsCheck.cs
#	src/Umbraco.Web/HealthCheck/Checks/Config/MacroErrorsCheck.cs
#	src/Umbraco.Web/HealthCheck/Checks/Config/NotificationEmailCheck.cs
#	src/Umbraco.Web/HealthCheck/Checks/Config/TraceCheck.cs
#	src/Umbraco.Web/HealthCheck/Checks/Config/TrySkipIisCustomErrorsCheck.cs
#	src/Umbraco.Web/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs
#	src/Umbraco.Web/HealthCheck/Checks/Security/BaseHttpHeaderCheck.cs
#	src/Umbraco.Web/HealthCheck/Checks/Security/ExcessiveHeadersCheck.cs
#	src/Umbraco.Web/HealthCheck/Checks/Security/HttpsCheck.cs
#	src/Umbraco.Web/HealthCheck/NotificationMethods/EmailNotificationMethod.cs
#	src/Umbraco.Web/Models/Trees/MenuItemList.cs
#	src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentCacheDataModel.cs
#	src/Umbraco.Web/PublishedCache/NuCache/DataSource/DatabaseDataSource.cs
#	src/Umbraco.Web/PublishedCache/NuCache/DataSource/SerializerBase.cs
#	src/Umbraco.Web/PublishedCache/NuCache/NuCacheComposer.cs
#	src/Umbraco.Web/Runtime/WebRuntime.cs
#	src/Umbraco.Web/Search/ExamineComponent.cs
#	src/Umbraco.Web/Trees/ApplicationTreeController.cs
#	src/Umbraco.Web/Trees/MemberTreeController.cs
#	src/Umbraco.Web/UrlHelperRenderExtensions.cs
This commit is contained in:
Bjarke Berg
2021-07-05 20:58:04 +02:00
122 changed files with 4101 additions and 1694 deletions

View File

@@ -275,7 +275,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
new ContentVariantDisplay
{
CreateDate = DateTime.Now,
Name = _localizedTextService.Localize("general/recycleBin")
Name = _localizedTextService.Localize("general","recycleBin")
}
},
ContentApps = apps
@@ -417,16 +417,65 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
{
var emptyContent = _contentService.Create("", parentId, contentType.Alias, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
var mapped = MapToDisplay(emptyContent);
return CleanContentItemDisplay(mapped);
}
private ContentItemDisplay CleanContentItemDisplay(ContentItemDisplay display)
{
// translate the content type name if applicable
mapped.ContentTypeName = _localizedTextService.UmbracoDictionaryTranslate(CultureDictionary, mapped.ContentTypeName);
display.ContentTypeName = _localizedTextService.UmbracoDictionaryTranslate(CultureDictionary, display.ContentTypeName);
// if your user type doesn't have access to the Settings section it would not get this property mapped
if (mapped.DocumentType != null)
mapped.DocumentType.Name = _localizedTextService.UmbracoDictionaryTranslate(CultureDictionary, mapped.DocumentType.Name);
if (display.DocumentType != null)
display.DocumentType.Name = _localizedTextService.UmbracoDictionaryTranslate(CultureDictionary, display.DocumentType.Name);
//remove the listview app if it exists
mapped.ContentApps = mapped.ContentApps.Where(x => x.Alias != "umbListView").ToList();
display.ContentApps = display.ContentApps.Where(x => x.Alias != "umbListView").ToList();
return mapped;
return display;
}
/// <summary>
/// Gets an empty <see cref="ContentItemDisplay"/> for each content type in the IEnumerable, all with the same parent ID
/// </summary>
/// <remarks>Will attempt to re-use the same permissions for every content as long as the path and user are the same</remarks>
/// <param name="contentTypes"></param>
/// <param name="parentId"></param>
/// <returns></returns>
private IEnumerable<ContentItemDisplay> GetEmpties(IEnumerable<IContentType> contentTypes, int parentId)
{
var result = new List<ContentItemDisplay>();
var backOfficeSecurity = _backofficeSecurityAccessor.BackOfficeSecurity;
var userId = backOfficeSecurity.GetUserId().ResultOr(0);
var currentUser = backOfficeSecurity.CurrentUser;
// We know that if the ID is less than 0 the parent is null.
// Since this is called with parent ID it's safe to assume that the parent is the same for all the content types.
var parent = parentId > 0 ? _contentService.GetById(parentId) : null;
// Since the parent is the same and the path used to get permissions is based on the parent we only have to do it once
var path = parent == null ? "-1" : parent.Path;
var permissions = new Dictionary<string, EntityPermissionSet>
{
[path] = _userService.GetPermissionsForPath(currentUser, path)
};
foreach (var contentType in contentTypes)
{
var emptyContent = _contentService.Create("", parentId, contentType, userId);
var mapped = MapToDisplay(emptyContent, context =>
{
// Since the permissions depend on current user and path, we add both of these to context as well,
// that way we can compare the path and current user when mapping, if they're the same just take permissions
// and skip getting them again, in theory they should always be the same, but better safe than sorry.,
context.Items["Parent"] = parent;
context.Items["CurrentUser"] = currentUser;
context.Items["Permissions"] = permissions;
});
result.Add(CleanContentItemDisplay(mapped));
}
return result;
}
/// <summary>
@@ -437,22 +486,9 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
[OutgoingEditorModelEvent]
public ActionResult<IDictionary<Guid, ContentItemDisplay>> GetEmptyByKeys([FromQuery] Guid[] contentTypeKeys, [FromQuery] int parentId)
{
var result = new Dictionary<Guid, ContentItemDisplay>();
using var scope = _scopeProvider.CreateScope(autoComplete: true);
var contentTypes = _contentTypeService.GetAll(contentTypeKeys).ToList();
foreach (var contentType in contentTypes)
{
if (contentType is null)
{
return NotFound();
}
result.Add(contentType.Key, GetEmptyInner(contentType, parentId));
}
return result;
return GetEmpties(contentTypes, parentId).ToDictionary(x => x.ContentTypeKey);
}
[OutgoingEditorModelEvent]
@@ -616,8 +652,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
var notificationModel = new SimpleNotificationModel();
notificationModel.AddSuccessNotification(
_localizedTextService.Localize("blueprints/createdBlueprintHeading"),
_localizedTextService.Localize("blueprints/createdBlueprintMessage", new[] { content.Name })
_localizedTextService.Localize("blueprints", "createdBlueprintHeading"),
_localizedTextService.Localize("blueprints", "createdBlueprintMessage", new[] { content.Name })
);
return notificationModel;
@@ -628,7 +664,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
var existing = _contentService.GetBlueprintsForContentTypes(content.ContentTypeId);
if (existing.Any(x => x.Name == name && x.Id != content.Id))
{
ModelState.AddModelError(modelName, _localizedTextService.Localize("blueprints/duplicateBlueprintMessage"));
ModelState.AddModelError(modelName, _localizedTextService.Localize("blueprints", "duplicateBlueprintMessage"));
return false;
}
@@ -794,15 +830,15 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
var variantName = GetVariantName(culture, segment);
AddSuccessNotification(notifications, culture, segment,
_localizedTextService.Localize("speechBubbles/editContentSendToPublish"),
_localizedTextService.Localize("speechBubbles/editVariantSendToPublishText", new[] { variantName }));
_localizedTextService.Localize("speechBubbles", "editContentSendToPublish"),
_localizedTextService.Localize("speechBubbles", "editVariantSendToPublishText", new[] { variantName }));
}
}
else if (ModelState.IsValid)
{
globalNotifications.AddSuccessNotification(
_localizedTextService.Localize("speechBubbles/editContentSendToPublish"),
_localizedTextService.Localize("speechBubbles/editContentSendToPublishText"));
_localizedTextService.Localize("speechBubbles", "editContentSendToPublish"),
_localizedTextService.Localize("speechBubbles", "editContentSendToPublishText"));
}
}
break;
@@ -819,8 +855,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
if (!await ValidatePublishBranchPermissionsAsync(contentItem))
{
globalNotifications.AddErrorNotification(
_localizedTextService.Localize("publish"),
_localizedTextService.Localize("publish/invalidPublishBranchPermissions"));
_localizedTextService.Localize(null,"publish"),
_localizedTextService.Localize("publish", "invalidPublishBranchPermissions"));
wasCancelled = false;
break;
}
@@ -835,8 +871,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
if (!await ValidatePublishBranchPermissionsAsync(contentItem))
{
globalNotifications.AddErrorNotification(
_localizedTextService.Localize("publish"),
_localizedTextService.Localize("publish/invalidPublishBranchPermissions"));
_localizedTextService.Localize(null,"publish"),
_localizedTextService.Localize("publish", "invalidPublishBranchPermissions"));
wasCancelled = false;
break;
}
@@ -931,7 +967,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
//if there's more than 1 variant, then we need to add the culture specific error
//messages based on the variants in error so that the messages show in the publish/save dialog
if (variants.Count > 1)
AddVariantValidationError(variant.Culture, variant.Segment, "publish/contentPublishedFailedByMissingName");
AddVariantValidationError(variant.Culture, variant.Segment, "publish","contentPublishedFailedByMissingName");
else
return false; //It's invariant and is missing critical data, it cannot be saved
}
@@ -968,15 +1004,15 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
/// <param name="variantCount"></param>
/// <param name="notifications"></param>
/// <param name="globalNotifications"></param>
/// <param name="invariantSavedLocalizationKey"></param>
/// <param name="variantSavedLocalizationKey"></param>
/// <param name="invariantSavedLocalizationAlias"></param>
/// <param name="variantSavedLocalizationAlias"></param>
/// <param name="wasCancelled"></param>
/// <remarks>
/// Method is used for normal Saving and Scheduled Publishing
/// </remarks>
private void SaveAndNotify(ContentItemSave contentItem, Func<IContent, OperationResult> saveMethod, int variantCount,
Dictionary<string, SimpleNotificationModel> notifications, SimpleNotificationModel globalNotifications,
string invariantSavedLocalizationKey, string variantSavedLocalizationKey, string cultureForInvariantErrors,
string invariantSavedLocalizationAlias, string variantSavedLocalizationAlias, string cultureForInvariantErrors,
out bool wasCancelled)
{
var saveResult = saveMethod(contentItem.PersistedContent);
@@ -996,15 +1032,15 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
var variantName = GetVariantName(culture, segment);
AddSuccessNotification(notifications, culture, segment,
_localizedTextService.Localize("speechBubbles/editContentSavedHeader"),
_localizedTextService.Localize(variantSavedLocalizationKey, new[] { variantName }));
_localizedTextService.Localize("speechBubbles", "editContentSavedHeader"),
_localizedTextService.Localize(null,variantSavedLocalizationAlias, new[] { variantName }));
}
}
else if (ModelState.IsValid)
{
globalNotifications.AddSuccessNotification(
_localizedTextService.Localize("speechBubbles/editContentSavedHeader"),
_localizedTextService.Localize(invariantSavedLocalizationKey));
_localizedTextService.Localize("speechBubbles", "editContentSavedHeader"),
_localizedTextService.Localize("speechBubbles",invariantSavedLocalizationAlias));
}
}
}
@@ -1131,7 +1167,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
{
//can't continue, a mandatory variant is not published and not scheduled for publishing
// TODO: Add segment
AddVariantValidationError(culture, null, "speechBubbles/scheduleErrReleaseDate2");
AddVariantValidationError(culture, null, "speechBubbles", "scheduleErrReleaseDate2");
isValid = false;
continue;
}
@@ -1139,7 +1175,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
{
//can't continue, a mandatory variant is not published and it's scheduled for publishing after a non-mandatory
// TODO: Add segment
AddVariantValidationError(culture, null, "speechBubbles/scheduleErrReleaseDate3");
AddVariantValidationError(culture, null, "speechBubbles", "scheduleErrReleaseDate3");
isValid = false;
continue;
}
@@ -1153,7 +1189,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
//1) release date cannot be less than now
if (variant.ReleaseDate.HasValue && variant.ReleaseDate < DateTime.Now)
{
AddVariantValidationError(variant.Culture, variant.Segment, "speechBubbles/scheduleErrReleaseDate1");
AddVariantValidationError(variant.Culture, variant.Segment, "speechBubbles", "scheduleErrReleaseDate1");
isValid = false;
continue;
}
@@ -1161,7 +1197,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
//2) expire date cannot be less than now
if (variant.ExpireDate.HasValue && variant.ExpireDate < DateTime.Now)
{
AddVariantValidationError(variant.Culture, variant.Segment, "speechBubbles/scheduleErrExpireDate1");
AddVariantValidationError(variant.Culture, variant.Segment, "speechBubbles", "scheduleErrExpireDate1");
isValid = false;
continue;
}
@@ -1169,7 +1205,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
//3) expire date cannot be less than release date
if (variant.ExpireDate.HasValue && variant.ReleaseDate.HasValue && variant.ExpireDate <= variant.ReleaseDate)
{
AddVariantValidationError(variant.Culture, variant.Segment, "speechBubbles/scheduleErrExpireDate2");
AddVariantValidationError(variant.Culture, variant.Segment, "speechBubbles", "scheduleErrExpireDate2");
isValid = false;
continue;
}
@@ -1397,19 +1433,19 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
if (r.publishing && !r.isValid)
{
//flagged for publishing but the mandatory culture is invalid
AddVariantValidationError(r.model.Culture, r.model.Segment, "publish/contentPublishedFailedReqCultureValidationError");
AddVariantValidationError(r.model.Culture, r.model.Segment, "publish", "contentPublishedFailedReqCultureValidationError");
canPublish = false;
}
else if (r.publishing && r.isValid && firstInvalidMandatoryCulture != null)
{
//in this case this culture also cannot be published because another mandatory culture is invalid
AddVariantValidationError(r.model.Culture, r.model.Segment, "publish/contentPublishedFailedReqCultureValidationError", firstInvalidMandatoryCulture);
AddVariantValidationError(r.model.Culture, r.model.Segment, "publish", "contentPublishedFailedReqCultureValidationError", firstInvalidMandatoryCulture);
canPublish = false;
}
else if (!r.publishing)
{
//cannot continue publishing since a required culture that is not currently being published isn't published
AddVariantValidationError(r.model.Culture, r.model.Segment, "speechBubbles/contentReqCulturePublishError");
AddVariantValidationError(r.model.Culture, r.model.Segment, "speechBubbles", "contentReqCulturePublishError");
canPublish = false;
}
}
@@ -1434,7 +1470,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
var valid = persistentContent.PublishCulture(CultureImpact.Explicit(variant.Culture, defaultCulture.InvariantEquals(variant.Culture)));
if (!valid)
{
AddVariantValidationError(variant.Culture, variant.Segment, "speechBubbles/contentCultureValidationError");
AddVariantValidationError(variant.Culture, variant.Segment, "speechBubbles", "contentCultureValidationError");
return false;
}
}
@@ -1451,12 +1487,12 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
/// <param name="cultureToken">
/// The culture used in the localization message, null by default which means <see cref="culture"/> will be used.
/// </param>
private void AddVariantValidationError(string culture, string segment, string localizationKey, string cultureToken = null)
private void AddVariantValidationError(string culture, string segment, string localizationArea,string localizationAlias, string cultureToken = null)
{
var cultureToUse = cultureToken ?? culture;
var variantName = GetVariantName(cultureToUse, segment);
var errMsg = _localizedTextService.Localize(localizationKey, new[] { variantName });
var errMsg = _localizedTextService.Localize(localizationArea, localizationAlias, new[] { variantName });
ModelState.AddVariantValidationError(culture, segment, errMsg);
}
@@ -1585,7 +1621,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
{
_contentService.EmptyRecycleBin(_backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(Constants.Security.SuperUserId));
return Ok(_localizedTextService.Localize("defaultdialogs/recycleBinIsEmpty"));
return Ok(_localizedTextService.Localize("defaultdialogs", "recycleBinIsEmpty"));
}
/// <summary>
@@ -1726,8 +1762,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
else
{
content.AddSuccessNotification(
_localizedTextService.Localize("content/unpublish"),
_localizedTextService.Localize("speechBubbles/contentUnpublished"));
_localizedTextService.Localize("content", "unpublish"),
_localizedTextService.Localize("speechBubbles", "contentUnpublished"));
return content;
}
}
@@ -1752,8 +1788,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
if (results.Any(x => x.Value.Result == PublishResultType.SuccessUnpublishMandatoryCulture))
{
content.AddSuccessNotification(
_localizedTextService.Localize("content/unpublish"),
_localizedTextService.Localize("speechBubbles/contentMandatoryCultureUnpublished"));
_localizedTextService.Localize("content", "unpublish"),
_localizedTextService.Localize("speechBubbles", "contentMandatoryCultureUnpublished"));
return content;
}
@@ -1761,8 +1797,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
foreach (var r in results)
{
content.AddSuccessNotification(
_localizedTextService.Localize("content/unpublish"),
_localizedTextService.Localize("speechBubbles/contentCultureUnpublished", new[] { _allLangs.Value[r.Key].CultureName }));
_localizedTextService.Localize("conten", "unpublish"),
_localizedTextService.Localize("speechBubbles", "contentCultureUnpublished", new[] { _allLangs.Value[r.Key].CultureName }));
}
return content;
@@ -1793,7 +1829,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
}
catch (UriFormatException)
{
return ValidationProblem(_localizedTextService.Localize("assignDomain/invalidDomain"));
return ValidationProblem(_localizedTextService.Localize("assignDomain", "invalidDomain"));
}
}
@@ -1943,7 +1979,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
foreach (var (culture, segment) in variantErrors)
{
AddVariantValidationError(culture, segment, "speechBubbles/contentCultureValidationError");
AddVariantValidationError(culture, segment, "speechBubbles", "contentCultureValidationError");
}
}
}
@@ -2064,7 +2100,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
if (toMove.ContentType.AllowedAsRoot == false)
{
return ValidationProblem(
_localizedTextService.Localize("moveOrCopy/notAllowedAtRoot"));
_localizedTextService.Localize("moveOrCopy", "notAllowedAtRoot"));
}
}
else
@@ -2081,14 +2117,14 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
.Any(x => x.Value == toMove.ContentType.Id) == false)
{
return ValidationProblem(
_localizedTextService.Localize("moveOrCopy/notAllowedByContentType"));
_localizedTextService.Localize("moveOrCopy", "notAllowedByContentType"));
}
// Check on paths
if ($",{parent.Path},".IndexOf($",{toMove.Id},", StringComparison.Ordinal) > -1)
{
return ValidationProblem(
_localizedTextService.Localize("moveOrCopy/notAllowedByPath"));
_localizedTextService.Localize("moveOrCopy", "notAllowedByPath"));
}
}
@@ -2157,16 +2193,16 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
{
//either invariant single publish, or bulk publish where all statuses are already published
display.AddSuccessNotification(
_localizedTextService.Localize("speechBubbles/editContentPublishedHeader"),
_localizedTextService.Localize("speechBubbles/editContentPublishedText"));
_localizedTextService.Localize("speechBubbles", "editContentPublishedHeader"),
_localizedTextService.Localize("speechBubbles", "editContentPublishedText"));
}
else
{
foreach (var c in successfulCultures)
{
display.AddSuccessNotification(
_localizedTextService.Localize("speechBubbles/editContentPublishedHeader"),
_localizedTextService.Localize("speechBubbles/editVariantPublishedText", new[] { _allLangs.Value[c].CultureName }));
_localizedTextService.Localize("speechBubbles", "editContentPublishedHeader"),
_localizedTextService.Localize("speechBubbles", "editVariantPublishedText", new[] { _allLangs.Value[c].CultureName }));
}
}
}
@@ -2182,20 +2218,20 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
if (successfulCultures == null)
{
display.AddSuccessNotification(
_localizedTextService.Localize("speechBubbles/editContentPublishedHeader"),
_localizedTextService.Localize("speechBubbles", "editContentPublishedHeader"),
totalStatusCount > 1
? _localizedTextService.Localize("speechBubbles/editMultiContentPublishedText", new[] { itemCount.ToInvariantString() })
: _localizedTextService.Localize("speechBubbles/editContentPublishedText"));
? _localizedTextService.Localize("speechBubbles", "editMultiContentPublishedText", new[] { itemCount.ToInvariantString() })
: _localizedTextService.Localize("speechBubbles", "editContentPublishedText"));
}
else
{
foreach (var c in successfulCultures)
{
display.AddSuccessNotification(
_localizedTextService.Localize("speechBubbles/editContentPublishedHeader"),
_localizedTextService.Localize("speechBubbles", "editContentPublishedHeader"),
totalStatusCount > 1
? _localizedTextService.Localize("speechBubbles/editMultiVariantPublishedText", new[] { itemCount.ToInvariantString(), _allLangs.Value[c].CultureName })
: _localizedTextService.Localize("speechBubbles/editVariantPublishedText", new[] { _allLangs.Value[c].CultureName }));
? _localizedTextService.Localize("speechBubbles", "editMultiVariantPublishedText", new[] { itemCount.ToInvariantString(), _allLangs.Value[c].CultureName })
: _localizedTextService.Localize("speechBubbles", "editVariantPublishedText", new[] { _allLangs.Value[c].CultureName }));
}
}
}
@@ -2205,8 +2241,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
//TODO: This doesn't take into account variations with the successfulCultures param
var names = string.Join(", ", status.Select(x => $"'{x.Content.Name}'"));
display.AddWarningNotification(
_localizedTextService.Localize("publish"),
_localizedTextService.Localize("publish/contentPublishedFailedByParent",
_localizedTextService.Localize(null,"publish"),
_localizedTextService.Localize("publish", "contentPublishedFailedByParent",
new[] { names }).Trim());
}
break;
@@ -2214,7 +2250,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
{
//TODO: This doesn't take into account variations with the successfulCultures param
var names = string.Join(", ", status.Select(x => $"'{x.Content.Name}'"));
AddCancelMessage(display, message: "publish/contentPublishedFailedByEvent", messageParams: new[] { names });
AddCancelMessage(display, "publish","contentPublishedFailedByEvent", messageParams: new[] { names });
}
break;
case PublishResultType.FailedPublishAwaitingRelease:
@@ -2222,8 +2258,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
//TODO: This doesn't take into account variations with the successfulCultures param
var names = string.Join(", ", status.Select(x => $"'{x.Content.Name}'"));
display.AddWarningNotification(
_localizedTextService.Localize("publish"),
_localizedTextService.Localize("publish/contentPublishedFailedAwaitingRelease",
_localizedTextService.Localize(null,"publish"),
_localizedTextService.Localize("publish", "contentPublishedFailedAwaitingRelease",
new[] { names }).Trim());
}
break;
@@ -2232,8 +2268,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
//TODO: This doesn't take into account variations with the successfulCultures param
var names = string.Join(", ", status.Select(x => $"'{x.Content.Name}'"));
display.AddWarningNotification(
_localizedTextService.Localize("publish"),
_localizedTextService.Localize("publish/contentPublishedFailedExpired",
_localizedTextService.Localize(null,"publish"),
_localizedTextService.Localize("publish", "contentPublishedFailedExpired",
new[] { names }).Trim());
}
break;
@@ -2242,8 +2278,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
//TODO: This doesn't take into account variations with the successfulCultures param
var names = string.Join(", ", status.Select(x => $"'{x.Content.Name}'"));
display.AddWarningNotification(
_localizedTextService.Localize("publish"),
_localizedTextService.Localize("publish/contentPublishedFailedIsTrashed",
_localizedTextService.Localize(null,"publish"),
_localizedTextService.Localize("publish", "contentPublishedFailedIsTrashed",
new[] { names }).Trim());
}
break;
@@ -2253,8 +2289,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
{
var names = string.Join(", ", status.Select(x => $"'{x.Content.Name}'"));
display.AddWarningNotification(
_localizedTextService.Localize("publish"),
_localizedTextService.Localize("publish/contentPublishedFailedInvalid",
_localizedTextService.Localize(null,"publish"),
_localizedTextService.Localize("publish", "contentPublishedFailedInvalid",
new[] { names }).Trim());
}
else
@@ -2263,8 +2299,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
{
var names = string.Join(", ", status.Select(x => $"'{(x.Content.ContentType.VariesByCulture() ? x.Content.GetCultureName(c) : x.Content.Name)}'"));
display.AddWarningNotification(
_localizedTextService.Localize("publish"),
_localizedTextService.Localize("publish/contentPublishedFailedInvalid",
_localizedTextService.Localize(null,"publish"),
_localizedTextService.Localize("publish", "contentPublishedFailedInvalid",
new[] { names }).Trim());
}
}
@@ -2272,7 +2308,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
break;
case PublishResultType.FailedPublishMandatoryCultureMissing:
display.AddWarningNotification(
_localizedTextService.Localize("publish"),
_localizedTextService.Localize(null,"publish"),
"publish/contentPublishedFailedByCulture");
break;
default:
@@ -2286,12 +2322,22 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
/// </summary>
/// <param name="content"></param>
/// <returns></returns>
private ContentItemDisplay MapToDisplay(IContent content)
{
var display = _umbracoMapper.Map<ContentItemDisplay>(content, context =>
private ContentItemDisplay MapToDisplay(IContent content) =>
MapToDisplay(content, context =>
{
context.Items["CurrentUser"] = _backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
});
/// <summary>
/// Used to map an <see cref="IContent"/> instance to a <see cref="ContentItemDisplay"/> and ensuring AllowPreview is set correctly.
/// Also allows you to pass in an action for the mapper context where you can pass additional information on to the mapper.
/// </summary>
/// <param name="content"></param>
/// <param name="contextOptions"></param>
/// <returns></returns>
private ContentItemDisplay MapToDisplay(IContent content, Action<MapperContext> contextOptions)
{
var display = _umbracoMapper.Map<ContentItemDisplay>(content, contextOptions);
display.AllowPreview = display.AllowPreview && content.Trashed == false && content.ContentType.IsElement == false;
return display;
}
@@ -2404,11 +2450,11 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
case OperationResultType.FailedExceptionThrown:
case OperationResultType.NoOperation:
default:
return ValidationProblem(_localizedTextService.Localize("speechBubbles/operationFailedHeader"));
return ValidationProblem(_localizedTextService.Localize("speechBubbles", "operationFailedHeader"));
case OperationResultType.FailedCancelledByEvent:
return ValidationProblem(
_localizedTextService.Localize("speechBubbles/operationCancelledHeader"),
_localizedTextService.Localize("speechBubbles/operationCancelledText"));
_localizedTextService.Localize("speechBubbles", "operationCancelledHeader"),
_localizedTextService.Localize("speechBubbles", "operationCancelledText"));
}
}
}