From 944898d6e5fe9c736aec65ae334b5a1f54159648 Mon Sep 17 00:00:00 2001 From: Wincent Date: Tue, 21 Jun 2016 14:18:55 +0200 Subject: [PATCH 1/3] http://issues.umbraco.org/issue/U4-8530 Adds Preview property to ContentItemDisplay --- src/Umbraco.Web.UI.Client/src/views/content/edit.html | 2 +- .../Models/ContentEditing/ContentItemDisplay.cs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/content/edit.html b/src/Umbraco.Web.UI.Client/src/views/content/edit.html index be79f797a0..c07dad7555 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/content/edit.html @@ -58,7 +58,7 @@ { + public ContentItemDisplay() + { + Preview = true; + } + [DataMember(Name = "publishDate")] public DateTime? PublishDate { get; set; } @@ -34,7 +39,10 @@ namespace Umbraco.Web.Models.ContentEditing [DataMember(Name = "urls")] public string[] Urls { get; set; } - + + [DataMember( Name = "preview" )] + public bool Preview { get; set; } + /// /// The allowed 'actions' based on the user's permissions - Create, Update, Publish, Send to publish /// From 2c15db595085f36229c0bbe2de49232a88109706 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 4 Aug 2016 18:34:20 +0200 Subject: [PATCH 2/3] U4-8530 Make it possbile to hide preview button by DocumentType or ContentItem --- .../src/views/content/edit.html | 2 +- .../Models/ContentEditing/ContentItemDisplay.cs | 12 +++++++++--- src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/content/edit.html b/src/Umbraco.Web.UI.Client/src/views/content/edit.html index c07dad7555..baf1cd7b3d 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/content/edit.html @@ -58,7 +58,7 @@ + /// Determines whether previewing is allowed for this node + /// + /// + /// By default this is true but by using events developers can toggle this off for certain documents if there is nothing to preview + /// + [DataMember( Name = "allowPreview" )] + public bool AllowPreview { get; set; } /// /// The allowed 'actions' based on the user's permissions - Create, Update, Publish, Send to publish diff --git a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs index 7f50b618d4..e2cdd1f7e4 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs @@ -66,6 +66,7 @@ namespace Umbraco.Web.Models.Mapping ? new[] {"Cannot generate urls without a current Umbraco Context"} : content.GetContentUrls(UmbracoContext.Current))) .ForMember(display => display.Properties, expression => expression.Ignore()) + .ForMember(display => display.AllowPreview, expression => expression.Ignore()) .ForMember(display => display.TreeNodeUrl, expression => expression.Ignore()) .ForMember(display => display.Notifications, expression => expression.Ignore()) .ForMember(display => display.Errors, expression => expression.Ignore()) From 69b6044bc640ad27a65c9412eaf32f4800b40db5 Mon Sep 17 00:00:00 2001 From: Claus Date: Fri, 5 Aug 2016 14:01:25 +0200 Subject: [PATCH 3/3] fixing null check on UmbracoContext.Current in RedirectTrackingEventHandler's PageCacheRefresher_CacheUpdated. --- src/Umbraco.Web/Redirects/RedirectTrackingEventHandler.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Redirects/RedirectTrackingEventHandler.cs b/src/Umbraco.Web/Redirects/RedirectTrackingEventHandler.cs index 39b3351aac..417238bdbe 100644 --- a/src/Umbraco.Web/Redirects/RedirectTrackingEventHandler.cs +++ b/src/Umbraco.Web/Redirects/RedirectTrackingEventHandler.cs @@ -93,6 +93,8 @@ namespace Umbraco.Web.Redirects { get { + if (UmbracoContext.Current == null) + return null; var oldRoutes = (Dictionary>) UmbracoContext.Current.HttpContext.Items[ContextKey3]; if (oldRoutes == null) UmbracoContext.Current.HttpContext.Items[ContextKey3] = oldRoutes = new Dictionary>(); @@ -165,8 +167,11 @@ namespace Umbraco.Web.Redirects private void PageCacheRefresher_CacheUpdated(PageCacheRefresher sender, CacheRefresherEventArgs cacheRefresherEventArgs) { - var removeKeys = new List(); + if (OldRoutes == null) + return; + var removeKeys = new List(); + foreach (var oldRoute in OldRoutes) { // assuming we cannot have 'CacheUpdated' for only part of the infos else we'd need