From c9936058b5112ec8913e7c8746ed87ec08f7ed3d Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Tue, 5 Feb 2019 07:54:42 +0100 Subject: [PATCH 1/2] Allow creating any content type at root if none are marked as "AllowAsRoot" --- src/Umbraco.Web/Editors/ContentTypeController.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Editors/ContentTypeController.cs b/src/Umbraco.Web/Editors/ContentTypeController.cs index 0aa7b75143..8df753bfe7 100644 --- a/src/Umbraco.Web/Editors/ContentTypeController.cs +++ b/src/Umbraco.Web/Editors/ContentTypeController.cs @@ -393,7 +393,11 @@ namespace Umbraco.Web.Editors IEnumerable 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 { From 9579b42330199621c96c472a928ad033936e1d0e Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Tue, 5 Feb 2019 07:54:59 +0100 Subject: [PATCH 2/2] Allow copying/moving any content type to root if none are marked as "AllowAsRoot" --- src/Umbraco.Web/Editors/ContentController.cs | 6 ++++-- src/Umbraco.Web/Editors/MediaController.cs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index ee056e38f0..4e8c26b8e1 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -1822,8 +1822,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( diff --git a/src/Umbraco.Web/Editors/MediaController.cs b/src/Umbraco.Web/Editors/MediaController.cs index 5662680a8a..5fab734f6c 100644 --- a/src/Umbraco.Web/Editors/MediaController.cs +++ b/src/Umbraco.Web/Editors/MediaController.cs @@ -868,8 +868,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"), "");