Merge pull request #4418 from kjac/v8-feature-allow-all-at-root

V8: Allow all content types at root if none are explicitly allowed
This commit is contained in:
Warren Buckley
2019-02-07 13:47:33 +00:00
committed by GitHub
3 changed files with 13 additions and 5 deletions

View File

@@ -1830,8 +1830,10 @@ namespace Umbraco.Web.Editors
}
if (model.ParentId < 0)
{
//cannot move if the content item is not allowed at the root
if (toMove.ContentType.AllowedAsRoot == false)
//cannot move if the content item is not allowed at the root unless there are
//none allowed at root (in which case all should be allowed at root)
var contentTypeService = Services.ContentTypeService;
if (toMove.ContentType.AllowedAsRoot == false && contentTypeService.GetAll().Any(ct => ct.AllowedAsRoot))
{
throw new HttpResponseException(
Request.CreateNotificationValidationErrorResponse(

View File

@@ -393,7 +393,11 @@ namespace Umbraco.Web.Editors
IEnumerable<IContentType> types;
if (contentId == Constants.System.Root)
{
types = Services.ContentTypeService.GetAll().Where(x => x.AllowedAsRoot).ToList();
var allContentTypes = Services.ContentTypeService.GetAll().ToList();
bool AllowedAsRoot(IContentType x) => x.AllowedAsRoot;
types = allContentTypes.Any(AllowedAsRoot)
? allContentTypes.Where(AllowedAsRoot).ToList()
: allContentTypes;
}
else
{

View File

@@ -870,8 +870,10 @@ namespace Umbraco.Web.Editors
}
if (model.ParentId < 0)
{
//cannot move if the content item is not allowed at the root
if (toMove.ContentType.AllowedAsRoot == false)
//cannot move if the content item is not allowed at the root unless there are
//none allowed at root (in which case all should be allowed at root)
var mediaTypeService = Services.MediaTypeService;
if (toMove.ContentType.AllowedAsRoot == false && mediaTypeService.GetAll().Any(ct => ct.AllowedAsRoot))
{
var notificationModel = new SimpleNotificationModel();
notificationModel.AddErrorNotification(Services.TextService.Localize("moveOrCopy/notAllowedAtRoot"), "");