From 8a85c3cbf9230a01cce5563ac9da89226fa79c60 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Tue, 15 Oct 2019 17:57:06 +0200 Subject: [PATCH] V8: It should be possible to disallow all types at content root (#6580) --- .../src/views/content/content.create.controller.js | 9 +++++---- .../src/views/content/create.html | 10 ++++++++-- src/Umbraco.Web.UI/Umbraco/config/lang/en.xml | 1 + src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml | 1 + src/Umbraco.Web/Editors/ContentController.cs | 6 ++---- src/Umbraco.Web/Editors/ContentTypeController.cs | 6 +----- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.create.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.create.controller.js index 9940a7a218..64f601f8b7 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/content.create.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.create.controller.js @@ -22,7 +22,8 @@ function contentCreateController($scope, function initialize() { $scope.loading = true; $scope.allowedTypes = null; - + $scope.countTypes = contentTypeResource.getCount; + var getAllowedTypes = contentTypeResource.getAllowedTypes($scope.currentNode.id).then(function (data) { $scope.allowedTypes = iconHelper.formatContentTypeIcons(data); }); @@ -97,7 +98,7 @@ function contentCreateController($scope, $scope.close = function() { close(); - } + }; $scope.closeDialog = function (showMenu) { navigationService.hideDialog(showMenu); @@ -106,12 +107,12 @@ function contentCreateController($scope, $scope.createContentType = function () { $location.path("/settings/documenttypes/edit/-1").search("create", "true"); close(); - } + }; $scope.editContentType = function () { $location.path("/settings/documenttypes/edit/" + $scope.contentTypeId).search("view", "permissions"); close(); - } + }; $scope.createBlank = createBlank; $scope.createOrSelectBlueprintIfAny = createOrSelectBlueprintIfAny; diff --git a/src/Umbraco.Web.UI.Client/src/views/content/create.html b/src/Umbraco.Web.UI.Client/src/views/content/create.html index 0b6f23c23a..cd883daf5f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/create.html +++ b/src/Umbraco.Web.UI.Client/src/views/content/create.html @@ -19,10 +19,16 @@
-

+ +

+ +

+ + +

-
diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml index 8804ec3870..8a421c6e70 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml @@ -337,6 +337,7 @@ The selected page in the content tree doesn't allow for any pages to be created below it. Edit permissions for this document type Create a new document type + Document Types within the Settings section, by changing the Allow as root option under Permissions.]]> Media Types Types within the Settings section, by editing the Allowed child node types under Permissions.]]> The selected media in the tree doesn't allow for any other media to be created below it. Edit permissions for this media type diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml index 8a759fb6cc..2834e68a0f 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml @@ -342,6 +342,7 @@ The selected page in the content tree doesn't allow for any pages to be created below it. Edit permissions for this document type Create a new document type + Document Types within the Settings section, by changing the Allow as root option under Permissions.]]> Media Types Types within the Settings section, by editing the Allowed child node types under Permissions.]]> The selected media in the tree doesn't allow for any other media to be created below it. Edit permissions for this media type Document Type without a template diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index 9d5af028e3..d19c066861 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -1926,10 +1926,8 @@ namespace Umbraco.Web.Editors } if (model.ParentId < 0) { - //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)) + //cannot move if the content item is not allowed at the root + if (toMove.ContentType.AllowedAsRoot == false) { throw new HttpResponseException( Request.CreateNotificationValidationErrorResponse( diff --git a/src/Umbraco.Web/Editors/ContentTypeController.cs b/src/Umbraco.Web/Editors/ContentTypeController.cs index 7c63061159..0f51c35a14 100644 --- a/src/Umbraco.Web/Editors/ContentTypeController.cs +++ b/src/Umbraco.Web/Editors/ContentTypeController.cs @@ -414,11 +414,7 @@ namespace Umbraco.Web.Editors IEnumerable types; if (contentId == Constants.System.Root) { - var allContentTypes = Services.ContentTypeService.GetAll().ToList(); - bool AllowedAsRoot(IContentType x) => x.AllowedAsRoot; - types = allContentTypes.Any(AllowedAsRoot) - ? allContentTypes.Where(AllowedAsRoot).ToList() - : allContentTypes; + types = Services.ContentTypeService.GetAll().Where(x => x.AllowedAsRoot).ToList(); } else {