ContentVersion cleanup backoffice UI (#11637)
* init rollback ui prototype * add busy state to button, deselect version, add pagination status * add localisation * style current version * disable rollback button when nothing is selected * stop click event * Endpoints for paginated content versions. Light on tests, tight on time. * Endpoints to "pin" content versions * camel case json output. Not sure why json formatter not set for controller, bit risky to add it now * wire up paging * wire up pin/unpin * rename getPagedRollbackVersions to getPagedContentVersions * prevent selection of current version and current draft * add current draft and current version to UI * remove pointer if the row is not selectable * Improve warning for globally disabled cleanup feature. * Fix current loses prevent cleanup state on publish. * Added umbracoLog audit entries for "pin" / "unpin" * Match v9 defaults for keepVersions settings * Fix - losing preventCleanup on save current with content changes * update pin/unpin button labels * fix pagination bug * add missing " * always send culture when a doc type can vary Co-authored-by: Mads Rasmussen <madsr@hey.com>
This commit is contained in:
@@ -2398,6 +2398,50 @@ namespace Umbraco.Web.Editors
|
||||
Services.NotificationService.SetNotifications(Security.CurrentUser, content, notifyOptions);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public PagedResult<ContentVersionMetaViewModel> GetPagedContentVersions(
|
||||
int contentId,
|
||||
int pageNumber = 1,
|
||||
int pageSize = 10,
|
||||
string culture = null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(culture))
|
||||
{
|
||||
if (!_allLangs.Value.TryGetValue(culture, out _))
|
||||
{
|
||||
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: v9 - don't service locate
|
||||
var contentVersionService = Current.Factory.GetInstance<IContentVersionService>();
|
||||
|
||||
var results = contentVersionService.GetPagedContentVersions(contentId, pageNumber - 1, pageSize, out var totalRecords, culture);
|
||||
|
||||
return new PagedResult<ContentVersionMetaViewModel>(totalRecords, pageNumber, pageSize)
|
||||
{
|
||||
Items = results.Select(x => new ContentVersionMetaViewModel(x))
|
||||
};
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[EnsureUserPermissionForContent("contentId", ActionUpdate.ActionLetter)]
|
||||
public HttpResponseMessage PostSetContentVersionPreventCleanup(int contentId, int versionId, bool preventCleanup)
|
||||
{
|
||||
var content = Services.ContentService.GetVersion(versionId);
|
||||
if (content == null || content.Id != contentId)
|
||||
{
|
||||
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
|
||||
}
|
||||
|
||||
// NOTE: v9 - don't service locate
|
||||
var contentVersionService = Current.Factory.GetInstance<IContentVersionService>();
|
||||
|
||||
contentVersionService.SetPreventCleanup(versionId, preventCleanup, Security.GetUserId().ResultOr(0));
|
||||
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IEnumerable<RollbackVersion> GetRollbackVersions(int contentId, string culture = null)
|
||||
{
|
||||
@@ -2486,6 +2530,7 @@ namespace Umbraco.Web.Editors
|
||||
return Request.CreateValidationErrorResponse(notificationModel);
|
||||
}
|
||||
|
||||
|
||||
[EnsureUserPermissionForContent("contentId", ActionProtect.ActionLetter)]
|
||||
[HttpGet]
|
||||
public HttpResponseMessage GetPublicAccess(int contentId)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "contentVersionMeta", Namespace = "")]
|
||||
public class ContentVersionMetaViewModel
|
||||
{
|
||||
[DataMember(Name = "contentId")]
|
||||
public int ContentId { get; set; }
|
||||
|
||||
[DataMember(Name = "contentTypeId")]
|
||||
public int ContentTypeId { get; set; }
|
||||
|
||||
[DataMember(Name = "versionId")]
|
||||
public int VersionId { get; set; }
|
||||
|
||||
[DataMember(Name = "userId")]
|
||||
public int UserId { get; set; }
|
||||
|
||||
[DataMember(Name = "versionDate")]
|
||||
public DateTime VersionDate { get; set; }
|
||||
|
||||
[DataMember(Name = "currentPublishedVersion")]
|
||||
public bool CurrentPublishedVersion { get; set; }
|
||||
|
||||
[DataMember(Name = "currentDraftVersion")]
|
||||
public bool CurrentDraftVersion { get; set; }
|
||||
|
||||
[DataMember(Name = "preventCleanup")]
|
||||
public bool PreventCleanup { get; set; }
|
||||
|
||||
[DataMember(Name = "username")]
|
||||
public string Username { get; set; }
|
||||
|
||||
public ContentVersionMetaViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public ContentVersionMetaViewModel(ContentVersionMeta dto)
|
||||
{
|
||||
ContentId = dto.ContentId;
|
||||
ContentTypeId = dto.ContentTypeId;
|
||||
VersionId = dto.VersionId;
|
||||
UserId = dto.UserId;
|
||||
VersionDate = dto.VersionDate;
|
||||
CurrentPublishedVersion = dto.CurrentPublishedVersion;
|
||||
CurrentDraftVersion = dto.CurrentDraftVersion;
|
||||
PreventCleanup = dto.PreventCleanup;
|
||||
Username = dto.Username;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,6 +255,7 @@
|
||||
<Compile Include="Models\AnchorsModel.cs" />
|
||||
<Compile Include="Models\ContentEditing\ContentTypesByAliases.cs" />
|
||||
<Compile Include="Models\ContentEditing\ContentTypesByKeys.cs" />
|
||||
<Compile Include="Models\ContentEditing\ContentVersionMetaViewModel.cs" />
|
||||
<Compile Include="Models\ContentEditing\DataTypeReferences.cs" />
|
||||
<Compile Include="Models\ContentEditing\HistoryCleanup.cs" />
|
||||
<Compile Include="Models\ContentEditing\LinkDisplay.cs" />
|
||||
|
||||
Reference in New Issue
Block a user