Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 462a7a2a36 | |||
| 087e4780cb | |||
| 61e50f6196 | |||
| 5cea2d6815 | |||
| 78bb72a36c | |||
| 8b7546a20b |
@@ -737,6 +737,8 @@ namespace Umbraco.Web.Editors
|
||||
break;
|
||||
case ContentSaveAction.Publish:
|
||||
case ContentSaveAction.PublishNew:
|
||||
case ContentSaveAction.PublishWithDescendants:
|
||||
case ContentSaveAction.PublishWithDescendantsIncDrafts:
|
||||
PublishInternal(contentItem, ref publishStatus, out wasCancelled, out var successfulCultures);
|
||||
//global notifications
|
||||
AddMessageForPublishStatus(publishStatus, globalNotifications, successfulCultures);
|
||||
@@ -863,6 +865,38 @@ namespace Umbraco.Web.Editors
|
||||
wasCancelled = saveResult.Result == OperationResultType.FailedCancelledByEvent;
|
||||
successfulCultures = Array.Empty<string>();
|
||||
}
|
||||
|
||||
|
||||
//The above will deal with publishing the current node - below deals with descendants if the action has been set
|
||||
if(canPublish && (contentItem.Action == ContentSaveAction.PublishWithDescendants || contentItem.Action == ContentSaveAction.PublishWithDescendantsIncDrafts))
|
||||
{
|
||||
//TODO: Which one - mixed usages in this controller
|
||||
//Security.CurrentUser.Id
|
||||
//Security.GetUserId().ResultOr(0)
|
||||
|
||||
//Get a list of variant/cultures - due for publishing
|
||||
var culturesToPublish = contentItem.Variants.Where(x => x.Publish).Select(x => x.Name).ToArray();
|
||||
var includeDrafts = contentItem.Action == ContentSaveAction.PublishWithDescendantsIncDrafts;
|
||||
var bulkPublishResult = Services.ContentService.SaveAndPublishBranch(contentItem.PersistedContent, includeDrafts, culturesToPublish, Security.GetUserId().ResultOr(0));
|
||||
|
||||
|
||||
//Bulk Publish Result - returns a collection of 'PublishResult'
|
||||
var bulkResult = bulkPublishResult.FirstOrDefault(x => x.Success == false);
|
||||
if (bulkResult == null)
|
||||
{
|
||||
//No failures - so grab the first sucessful result
|
||||
bulkResult = bulkPublishResult.FirstOrDefault(x => x.Success);
|
||||
}
|
||||
|
||||
//Update the publish status - from the descendants/tree
|
||||
publishStatus = bulkResult;
|
||||
|
||||
//Was the result cancelled?
|
||||
wasCancelled = bulkResult.Result == PublishResultType.FailedCancelledByEvent;
|
||||
|
||||
//Not sure - we need to update this again as likely not changed?!
|
||||
successfulCultures = contentItem.Variants.Where(x => x.Publish).Select(x => x.Culture).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "contentPublish", Namespace = "")]
|
||||
public class ContentPublish
|
||||
{
|
||||
[DataMember(Name = "id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DataMember(Name = "includeDescendants")]
|
||||
public bool IncludeDescendants { get; set; }
|
||||
|
||||
[DataMember(Name = "publishDrafts")]
|
||||
public bool PublishDrafts { get; set; }
|
||||
|
||||
[DataMember(Name = "cultures")]
|
||||
public string[] Cultures { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,16 @@
|
||||
/// <summary>
|
||||
/// Creates and sends publish notification
|
||||
/// </summary>
|
||||
SendPublishNew = 5
|
||||
SendPublishNew = 5,
|
||||
|
||||
/// <summary>
|
||||
/// Saves and publishes the content item and it's descendants
|
||||
/// </summary>
|
||||
PublishWithDescendants = 6,
|
||||
|
||||
/// <summary>
|
||||
/// Saves and publishes the content item and it's descendants including drafts
|
||||
/// </summary>
|
||||
PublishWithDescendantsIncDrafts = 7
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,6 +147,7 @@
|
||||
<Compile Include="Media\TypeDetector\SvgDetector.cs" />
|
||||
<Compile Include="Media\TypeDetector\TIFFDetector.cs" />
|
||||
<Compile Include="Media\UploadAutoFillProperties.cs" />
|
||||
<Compile Include="Models\ContentEditing\ContentPublish.cs" />
|
||||
<Compile Include="Models\ContentEditing\RollbackVersion.cs" />
|
||||
<Compile Include="Models\ContentEditing\UnpublishContent.cs" />
|
||||
<Compile Include="Models\Mapping\MappingOperationOptionsExtensions.cs" />
|
||||
|
||||
Reference in New Issue
Block a user