Added copy functionality for data types (#11867)

* Added copy functionality for data types

* Fix errors

* Add logic to default interface

* PR Feedback

* PR feedback

* Fix error
This commit is contained in:
patrickdemooij9
2022-08-19 10:19:36 +02:00
committed by GitHub
parent f33b724c8e
commit 56e282946f
8 changed files with 571 additions and 332 deletions

View File

@@ -383,6 +383,30 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
}
}
public IActionResult PostCopy(MoveOrCopy copy)
{
var toCopy = _dataTypeService.GetDataType(copy.Id);
if (toCopy is null)
{
return NotFound();
}
Attempt<OperationResult<MoveOperationStatusType, IDataType>?> result = _dataTypeService.Copy(toCopy, copy.ParentId);
if (result.Success)
{
return Content(toCopy.Path, MediaTypeNames.Text.Plain, Encoding.UTF8);
}
return result.Result?.Result switch
{
MoveOperationStatusType.FailedParentNotFound => NotFound(),
MoveOperationStatusType.FailedCancelledByEvent => ValidationProblem(),
MoveOperationStatusType.FailedNotAllowedByPath => ValidationProblem(
_localizedTextService.Localize("moveOrCopy", "notAllowedByPath")),
_ => throw new ArgumentOutOfRangeException()
};
}
public IActionResult PostRenameContainer(int id, string name)
{
var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity?.CurrentUser;

View File

@@ -181,8 +181,9 @@ public class DataTypeTreeController : TreeController, ISearchableTree
menu.Items.Add<ActionDelete>(LocalizedTextService, opensDialog: true, useLegacyIcon: false);
}
menu.Items.Add<ActionMove>(LocalizedTextService, hasSeparator: true, opensDialog: true, useLegacyIcon: false);
}
menu.Items.Add<ActionMove>(LocalizedTextService, hasSeparator: true, opensDialog: true, useLegacyIcon: false);
menu.Items.Add<ActionCopy>(LocalizedTextService, hasSeparator: true, opensDialog: true, useLegacyIcon: false);
}
return menu;
}