* 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> # Conflicts: # src/Umbraco.Core/ContentEditing/ContentVersionMetaViewModel.cs # src/Umbraco.Core/Models/HistoricContentVersionMeta.cs # src/Umbraco.Infrastructure/Services/Implement/ContentService.cs # src/Umbraco.Tests/Persistence/Repositories/DocumentVersionRepository_Tests_Integration.cs # src/Umbraco.Tests/Services/ContentVersionCleanupService_Tests_UnitTests.cs # src/Umbraco.Web.BackOffice/Controllers/ContentController.cs # src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js # src/Umbraco.Web.UI/config/umbracoSettings.Release.config # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # src/Umbraco.Web/Umbraco.Web.csproj * Added tests * Misc - missed translation update * Bugfix - DocumentVersionRepository.Get should not join culture variation * Bugfix - Missing write lock * Removed unnecessary view model * Misc - kill some warnings * Misc - Kill some more warnings * Fixed cypress rollback test * Bugfix - Policy returns items to delete not items to keep. Switch to inverse behavior. # Conflicts: # src/Umbraco.Tests/Services/DefaultContentVersionCleanupPolicy_Tests_UnitTests.cs Co-authored-by: Paul Johnson <pmj@umbraco.com>
This commit is contained in:
@@ -62,6 +62,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
private readonly ActionCollection _actionCollection;
|
||||
private readonly ISqlContext _sqlContext;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly IContentVersionService _contentVersionService;
|
||||
private readonly Lazy<IDictionary<string, ILanguage>> _allLangs;
|
||||
private readonly ILogger<ContentController> _logger;
|
||||
private readonly IScopeProvider _scopeProvider;
|
||||
@@ -90,7 +91,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
ISqlContext sqlContext,
|
||||
IJsonSerializer serializer,
|
||||
IScopeProvider scopeProvider,
|
||||
IAuthorizationService authorizationService)
|
||||
IAuthorizationService authorizationService,
|
||||
IContentVersionService contentVersionService)
|
||||
: base(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService, serializer)
|
||||
{
|
||||
_propertyEditors = propertyEditors;
|
||||
@@ -109,6 +111,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
_actionCollection = actionCollection;
|
||||
_sqlContext = sqlContext;
|
||||
_authorizationService = authorizationService;
|
||||
_contentVersionService = contentVersionService;
|
||||
_logger = loggerFactory.CreateLogger<ContentController>();
|
||||
_scopeProvider = scopeProvider;
|
||||
_allLangs = new Lazy<IDictionary<string, ILanguage>>(() => _localizationService.GetAllLanguages().ToDictionary(x => x.IsoCode, x => x, StringComparer.InvariantCultureIgnoreCase));
|
||||
@@ -2504,6 +2507,53 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[JsonCamelCaseFormatter]
|
||||
public IActionResult GetPagedContentVersions(
|
||||
int contentId,
|
||||
int pageNumber = 1,
|
||||
int pageSize = 10,
|
||||
string culture = null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(culture))
|
||||
{
|
||||
if (!_allLangs.Value.TryGetValue(culture, out _))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerable<ContentVersionMeta> results = _contentVersionService.GetPagedContentVersions(
|
||||
contentId,
|
||||
pageNumber - 1,
|
||||
pageSize,
|
||||
out var totalRecords,
|
||||
culture);
|
||||
|
||||
var model = new PagedResult<ContentVersionMeta>(totalRecords, pageNumber, pageSize)
|
||||
{
|
||||
Items = results
|
||||
};
|
||||
|
||||
return Ok(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize(Policy = AuthorizationPolicies.ContentPermissionAdministrationById)]
|
||||
public IActionResult PostSetContentVersionPreventCleanup(int contentId, int versionId, bool preventCleanup)
|
||||
{
|
||||
IContent content = _contentService.GetVersion(versionId);
|
||||
|
||||
if (content == null || content.Id != contentId)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_contentVersionService.SetPreventCleanup(versionId, preventCleanup, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IEnumerable<RollbackVersion> GetRollbackVersions(int contentId, string culture = null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user