From 92ca4128e3d7a83853a895bfaec7e3c37c80d85e Mon Sep 17 00:00:00 2001 From: Matteo Piovanelli Date: Thu, 17 May 2018 21:21:59 +0200 Subject: [PATCH] Fix List.cshtml with new permission (#8053) --- .../Core/Contents/Views/Admin/List.cshtml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Orchard.Web/Core/Contents/Views/Admin/List.cshtml b/src/Orchard.Web/Core/Contents/Views/Admin/List.cshtml index 474d4b6bd..a2459180c 100644 --- a/src/Orchard.Web/Core/Contents/Views/Admin/List.cshtml +++ b/src/Orchard.Web/Core/Contents/Views/Admin/List.cshtml @@ -6,16 +6,19 @@ var typeDisplayName = Model.TypeDisplayName; var pageTitle = T("Manage Content"); var createLinkText = T("Create New Content"); - var userCanCreateContent = false; + // if no specific type is selected, we assume we should show the "Create" button + var showCreateContentButton = string.IsNullOrWhiteSpace(typeDisplayName); IAuthorizationService _authorizationService; WorkContext.TryResolve(out _authorizationService); - if (!string.IsNullOrWhiteSpace(typeDisplayName)) { + if (!showCreateContentButton) { + // being here it means there is a specific type we are considering pageTitle = T("Manage {0} Content", Html.Raw(typeDisplayName)); createLinkText = T("Create New {0}", Html.Raw(typeDisplayName)); - var permission = DynamicPermissions.CreateDynamicPermission(DynamicPermissions.PermissionTemplates[Permissions.CreateContent.Name], Model.ContentType); + var permission = DynamicPermissions + .CreateDynamicPermission(DynamicPermissions.PermissionTemplates[Permissions.CreateContent.Name], Model.ContentType); if (_authorizationService.TryCheckAccess(permission, WorkContext.CurrentUser, null)) { - userCanCreateContent = true; + showCreateContentButton = true; } } @@ -23,7 +26,7 @@ Layout.Title = pageTitle.Text; } -@if (userCanCreateContent) { +@if (showCreateContentButton) {
@Html.ActionLink(createLinkText.Text, "Create", new { Area = "Contents", Id = (string)Model.Options.SelectedFilter }, new { @class = "button primaryAction" })