-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Global Elements - take one #21431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Global Elements - take one #21431
Changes from all commits
Commits
Show all changes
101 commits
Select commit
Hold shift + click to select a range
148ac51
CRUD + folders + API
kjac b25ee76
Merge branch 'main' into v16/temp/element-poc
kjac eea3c57
Fix infinite recursion
kjac d2e0416
Distributed cache handling for Elements
kjac 70b5c52
Publishing for Elements (incl. refactor)
kjac 251b8a4
Fix bad file name
kjac fd59a8b
Added "foldersOnly" option to the siblings endpoint
kjac eadd6ec
Update src/Umbraco.Core/Models/UmbracoObjectTypes.cs
kjac 523d96a
Merge branch 'main' into v16/temp/element-poc
kjac d6b5d57
API for publishing elements
kjac 632b89d
Published element cache (WIP)
kjac ca9f0bd
Fix delete at repo level
kjac feb07a2
Fixing up a little tests
kjac 3a53a9b
Element picker property editor
kjac d7b4fad
Added tests to prove published element status
kjac 2ce2b51
Merge branch 'main' into v16/temp/element-poc
kjac 28abcf3
Move scheduled content keys to base abstraction
kjac 0a2a518
Add request caching for published element creation (similar to publis…
kjac 264f4c1
Merge branch 'main' into v16/temp/element-poc
kjac e7ae4ab
Apply conditional appcache access to elements as well
kjac 26ed5fb
Fix test build errors
kjac 064c7bd
Merge branch 'main' into v16/temp/element-poc
kjac 1644b0e
Fix merge from main
kjac 0e9c45f
Merge branch 'main' into v16/temp/element-poc
kjac 9962072
Fix merge
kjac 5fd8f54
Merge branch 'main' into v16/temp/element-poc
kjac 8defac5
Merge branch 'main' into v16/temp/element-poc
kjac 908b4de
Add cache invalidation on update (like content and media)
kjac 6359d45
Move element (incl. tests)
kjac f0031a7
Element copying
kjac 922fbc8
Add items endpoint incl. variation info at item level
kjac 8bc3b8b
Make the Element tree items look like Document tree items (with varia…
kjac a566528
Rename all things ElementType to DocumentType
kjac 058798c
Move ElementRepository to the right place
kjac abdc2f0
Merge branch 'main' into v16/temp/element-poc
kjac 9146adf
Fix auditing after merge (changes from #19357)
kjac 47443fa
Fix dates after merge (changes from #19822)
kjac 1c6ff8b
Fix NPoco querying after merge (changes from #20184)
kjac 6f0b217
Fix various build errors after merge
kjac 9af0d1b
Merge branch 'main' into v17/feature/global-elements
kjac 87fadc9
Merge branch 'main' into v17/feature/global-elements
kjac 1fa9fd5
Move containers
kjac b019c31
Merge branch 'main' into v17/feature/global-elements
kjac 9ff9103
Add migration to create element tables
kjac 223d0d9
Merge branch 'main' into v17/feature/global-elements
kjac 6396c1f
Re-implement #21105 at base class level
kjac b33297e
Merge branch 'main' into v17/feature/global-elements
kjac c9130eb
Fix merge
kjac ea5a797
Add element tree recycle bin + move element to/from recycle bin
kjac f1d02c6
Controllers for move to recycle bin + recycle bin root
kjac b355e1e
Support element containers in recycle bin (no controllers)
kjac b3c14d6
Handle error cases for element moves and add more tests
kjac cf2433b
Do not allow creation of IPublishedElement for trashed elements
kjac 42e86df
Amend recycle bin controller output and add children controller
kjac 59e93e5
Merge branch 'main' into v17/feature/global-elements
kjac 97782a1
Regenerate OpenApi.json with Element APIs
kjac ab50f7e
Housekeeping: Organize element container service tests
kjac e1b648e
Fix bad housekeeping
kjac 4b2a3f3
Add missing siblings controller for recycle bin
kjac 352dbc0
Add "delete from recycle bin" and "empty recycle bin" operations (inc…
kjac 9e28241
Updated OpenApi.json to reflect new endpoints
kjac d21746a
Added `CreateDate` to `ElementTreeItemResponseModel`
leekelleher 30f2f46
Re-generated OpenAPI.json
leekelleher 7659b46
Add configuration endpoint for Elements
kjac 453da71
Explicitly unpublish published elements when restoring from recycle bin.
kjac 3d00fee
Merge branch 'main' into v17/feature/global-elements
kjac bf0fd20
Merge branch 'v18/dev' into v17/feature/global-elements
lauraneto 1ee7f0e
Elements: Remove invalid templateId from ElementVersionDto index defi…
lauraneto cc1dd48
Fix the ordering of items in the tree
kjac ec87d88
It's 2026 now...
kjac 6f92c61
Fix missing project structure
kjac 2088567
Amend empty recycle bin
kjac f0cb616
Elements: Fix element recycle bin node insertion on SQL Server (#21390)
lauraneto a3ff86f
Fix count trashed children
kjac fd3b1ac
Moved newly added entity service tests to an isolated, per-test DB cl…
kjac e3fef11
Elements: Element start node permissions (#21375)
lauraneto 98b9359
Elements: Add rollback (#21393)
kjac b8f4bbe
Elements: Regenerate OpenApi.json
lauraneto d6cb11f
Elements: Add default and granular permissions for Element controller…
lauraneto 577f351
Merge branch 'v18/dev' into v17/feature/global-elements
kjac 2a58892
Add element folder "item" endpoint
kjac 79e3965
Include "isTrashed" in folder response models
kjac 4852c93
Update TODOs
kjac 095af03
Rollback a few unnecessarily breaking signature changes
kjac 59f838a
Merge remote-tracking branch 'origin/v18/dev' into v17/feature/global…
kjac f522d04
Use schema constants from #21327
kjac e6f7c88
Elements: Add admin group element permissions during upgrade (#21452)
lauraneto 94bf319
Elements: Fix Writer expected status codes in Element controller perm…
lauraneto d91a829
Elements: Fix duplicate column name in DocumentVersionDto index defin…
lauraneto 7e01fc0
Add missing element mapper and allow deleting element types with acti…
kjac c85d9d7
Update src/Umbraco.Core/Cache/Refreshers/Implement/ElementCacheRefres…
kjac 5dab68b
Review comment: ReadOnlyUserGroup constructor
kjac 0d907b0
Merge remote-tracking branch 'origin/v17/feature/global-elements' int…
kjac 625e814
Update comments in ElementEditingService
kjac 085602e
Add Library section access to content, media, and member tree policies
lauraneto 58252f6
Elements: Add Elements access to data type, document type, and relati…
lauraneto 90c2c6d
Merge branch 'v18/dev' into v17/feature/global-elements
kjac 886ff16
Merge branch 'v18/dev' into v17/feature/global-elements
kjac 204ce53
Amend merge from v18/dev
kjac b63020e
Merge branch 'v18/dev' into v17/feature/global-elements
lauraneto 416f544
Global Elements: Backoffice UI implementation (#21410)
leekelleher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/Umbraco.Cms.Api.Management/Controllers/Element/ByKeyElementController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| using Asp.Versioning; | ||
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Umbraco.Cms.Api.Management.Factories; | ||
| using Umbraco.Cms.Api.Management.ViewModels.Element; | ||
| using Umbraco.Cms.Core.Actions; | ||
| using Umbraco.Cms.Core.Models; | ||
| using Umbraco.Cms.Core.Security.Authorization; | ||
| using Umbraco.Cms.Core.Services; | ||
| using Umbraco.Cms.Core.Services.OperationStatus; | ||
| using Umbraco.Cms.Web.Common.Authorization; | ||
| using Umbraco.Extensions; | ||
|
|
||
| namespace Umbraco.Cms.Api.Management.Controllers.Element; | ||
|
|
||
| [ApiVersion("1.0")] | ||
| public class ByKeyElementController : ElementControllerBase | ||
| { | ||
| private readonly IAuthorizationService _authorizationService; | ||
| private readonly IElementService _elementService; | ||
| private readonly IElementPresentationFactory _elementPresentationFactory; | ||
|
|
||
| public ByKeyElementController( | ||
| IAuthorizationService authorizationService, | ||
| IElementService elementService, | ||
| IElementPresentationFactory elementPresentationFactory) | ||
| { | ||
| _authorizationService = authorizationService; | ||
| _elementService = elementService; | ||
| _elementPresentationFactory = elementPresentationFactory; | ||
| } | ||
|
|
||
| [HttpGet("{id:guid}")] | ||
| [MapToApiVersion("1.0")] | ||
| [ProducesResponseType(typeof(ElementResponseModel), StatusCodes.Status200OK)] | ||
| [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] | ||
| public async Task<IActionResult> ByKey(CancellationToken cancellationToken, Guid id) | ||
| { | ||
| AuthorizationResult authorizationResult = await _authorizationService.AuthorizeResourceAsync( | ||
| User, | ||
| ElementPermissionResource.WithKeys(ActionElementBrowse.ActionLetter, id), | ||
| AuthorizationPolicies.ElementPermissionByResource); | ||
|
|
||
| if (!authorizationResult.Succeeded) | ||
| { | ||
| return Forbidden(); | ||
| } | ||
|
|
||
| IElement? element = _elementService.GetById(id); | ||
| if (element is null) | ||
| { | ||
| return ContentEditingOperationStatusResult(ContentEditingOperationStatus.NotFound); | ||
| } | ||
|
|
||
| ContentScheduleCollection contentScheduleCollection = _elementService.GetContentScheduleByContentId(id); | ||
|
|
||
| ElementResponseModel model = _elementPresentationFactory.CreateResponseModel(element, contentScheduleCollection); | ||
| return Ok(model); | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
src/Umbraco.Cms.Api.Management/Controllers/Element/ConfigurationElementController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| using Asp.Versioning; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Umbraco.Cms.Api.Management.Factories; | ||
| using Umbraco.Cms.Api.Management.ViewModels.Element; | ||
|
|
||
| namespace Umbraco.Cms.Api.Management.Controllers.Element; | ||
|
|
||
| [ApiVersion("1.0")] | ||
| public class ConfigurationElementController : ElementControllerBase | ||
| { | ||
| private readonly IConfigurationPresentationFactory _configurationPresentationFactory; | ||
|
|
||
| public ConfigurationElementController(IConfigurationPresentationFactory configurationPresentationFactory) | ||
| => _configurationPresentationFactory = configurationPresentationFactory; | ||
|
|
||
| [HttpGet("configuration")] | ||
| [MapToApiVersion("1.0")] | ||
| [ProducesResponseType(typeof(ElementConfigurationResponseModel), StatusCodes.Status200OK)] | ||
| public Task<IActionResult> Configuration(CancellationToken cancellationToken) | ||
| { | ||
| ElementConfigurationResponseModel responseModel = _configurationPresentationFactory.CreateElementConfigurationResponseModel(); | ||
| return Task.FromResult<IActionResult>(Ok(responseModel)); | ||
| } | ||
| } |
72 changes: 72 additions & 0 deletions
72
src/Umbraco.Cms.Api.Management/Controllers/Element/CopyElementController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| using Asp.Versioning; | ||
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Umbraco.Cms.Api.Management.ViewModels.Element; | ||
| using Umbraco.Cms.Core; | ||
| using Umbraco.Cms.Core.Actions; | ||
| using Umbraco.Cms.Core.Models; | ||
| using Umbraco.Cms.Core.Security; | ||
| using Umbraco.Cms.Core.Security.Authorization; | ||
| using Umbraco.Cms.Core.Services; | ||
| using Umbraco.Cms.Core.Services.OperationStatus; | ||
| using Umbraco.Cms.Web.Common.Authorization; | ||
| using Umbraco.Extensions; | ||
|
|
||
| namespace Umbraco.Cms.Api.Management.Controllers.Element; | ||
|
|
||
| [ApiVersion("1.0")] | ||
| public class CopyElementController : ElementControllerBase | ||
| { | ||
| private readonly IAuthorizationService _authorizationService; | ||
| private readonly IElementEditingService _elementEditingService; | ||
| private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; | ||
|
|
||
| public CopyElementController( | ||
| IAuthorizationService authorizationService, | ||
| IElementEditingService elementEditingService, | ||
| IBackOfficeSecurityAccessor backOfficeSecurityAccessor) | ||
| { | ||
| _authorizationService = authorizationService; | ||
| _elementEditingService = elementEditingService; | ||
| _backOfficeSecurityAccessor = backOfficeSecurityAccessor; | ||
| } | ||
|
|
||
| [HttpPost("{id:guid}/copy")] | ||
| [MapToApiVersion("1.0")] | ||
| [ProducesResponseType(StatusCodes.Status201Created)] | ||
| [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] | ||
| public async Task<IActionResult> Copy(CancellationToken cancellationToken, Guid id, CopyElementRequestModel copyElementRequestModel) | ||
| { | ||
| // Check Copy permission on source element | ||
| AuthorizationResult sourceAuthorizationResult = await _authorizationService.AuthorizeResourceAsync( | ||
| User, | ||
| ElementPermissionResource.WithKeys(ActionElementCopy.ActionLetter, id), | ||
| AuthorizationPolicies.ElementPermissionByResource); | ||
|
|
||
| if (!sourceAuthorizationResult.Succeeded) | ||
| { | ||
| return Forbidden(); | ||
| } | ||
|
|
||
| // Check Create permission on target (where we're copying to) | ||
| AuthorizationResult targetAuthorizationResult = await _authorizationService.AuthorizeResourceAsync( | ||
| User, | ||
| ElementPermissionResource.WithKeys(ActionElementNew.ActionLetter, copyElementRequestModel.Target?.Id), | ||
| AuthorizationPolicies.ElementPermissionByResource); | ||
|
|
||
| if (!targetAuthorizationResult.Succeeded) | ||
| { | ||
| return Forbidden(); | ||
| } | ||
|
|
||
| Attempt<IElement?, ContentEditingOperationStatus> result = await _elementEditingService.CopyAsync( | ||
| id, | ||
| copyElementRequestModel.Target?.Id, | ||
| CurrentUserKey(_backOfficeSecurityAccessor)); | ||
|
|
||
| return result.Success | ||
| ? CreatedAtId<ByKeyElementController>(controller => nameof(controller.ByKey), result.Result!.Key) | ||
| : ContentEditingOperationStatusResult(result.Status); | ||
| } | ||
| } | ||
50 changes: 50 additions & 0 deletions
50
src/Umbraco.Cms.Api.Management/Controllers/Element/CreateElementController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| using Asp.Versioning; | ||
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Umbraco.Cms.Api.Management.Factories; | ||
| using Umbraco.Cms.Api.Management.ViewModels.Element; | ||
| using Umbraco.Cms.Core; | ||
| using Umbraco.Cms.Core.Models.ContentEditing; | ||
| using Umbraco.Cms.Core.Security; | ||
| using Umbraco.Cms.Core.Services; | ||
| using Umbraco.Cms.Core.Services.OperationStatus; | ||
|
|
||
| namespace Umbraco.Cms.Api.Management.Controllers.Element; | ||
|
|
||
| [ApiVersion("1.0")] | ||
| public class CreateElementController : CreateElementControllerBase | ||
| { | ||
| private readonly IElementEditingPresentationFactory _elementEditingPresentationFactory; | ||
| private readonly IElementEditingService _elementEditingService; | ||
| private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; | ||
|
|
||
| public CreateElementController( | ||
| IAuthorizationService authorizationService, | ||
| IElementEditingPresentationFactory elementEditingPresentationFactory, | ||
| IElementEditingService elementEditingService, | ||
| IBackOfficeSecurityAccessor backOfficeSecurityAccessor) | ||
| : base(authorizationService) | ||
| { | ||
| _elementEditingPresentationFactory = elementEditingPresentationFactory; | ||
| _elementEditingService = elementEditingService; | ||
| _backOfficeSecurityAccessor = backOfficeSecurityAccessor; | ||
| } | ||
|
|
||
| [HttpPost] | ||
| [MapToApiVersion("1.0")] | ||
| [ProducesResponseType(StatusCodes.Status201Created)] | ||
| [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)] | ||
| [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] | ||
| public async Task<IActionResult> Create(CancellationToken cancellationToken, CreateElementRequestModel requestModel) | ||
kjac marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| => await HandleRequest(requestModel, async () => | ||
| { | ||
| ElementCreateModel model = _elementEditingPresentationFactory.MapCreateModel(requestModel); | ||
| Attempt<ElementCreateResult, ContentEditingOperationStatus> result = | ||
| await _elementEditingService.CreateAsync(model, CurrentUserKey(_backOfficeSecurityAccessor)); | ||
|
|
||
| return result.Success | ||
| ? CreatedAtId<ByKeyElementController>(controller => nameof(controller.ByKey), result.Result.Content!.Key) | ||
| : ContentEditingOperationStatusResult(result.Status); | ||
| }); | ||
| } | ||
32 changes: 32 additions & 0 deletions
32
src/Umbraco.Cms.Api.Management/Controllers/Element/CreateElementControllerBase.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Umbraco.Cms.Api.Management.ViewModels.Element; | ||
| using Umbraco.Cms.Core.Actions; | ||
| using Umbraco.Cms.Core.Security.Authorization; | ||
| using Umbraco.Cms.Web.Common.Authorization; | ||
| using Umbraco.Extensions; | ||
|
|
||
| namespace Umbraco.Cms.Api.Management.Controllers.Element; | ||
|
|
||
| public abstract class CreateElementControllerBase : ElementControllerBase | ||
| { | ||
| private readonly IAuthorizationService _authorizationService; | ||
|
|
||
| protected CreateElementControllerBase(IAuthorizationService authorizationService) | ||
| => _authorizationService = authorizationService; | ||
|
|
||
| protected async Task<IActionResult> HandleRequest(CreateElementRequestModel requestModel, Func<Task<IActionResult>> authorizedHandler) | ||
| { | ||
| AuthorizationResult authorizationResult = await _authorizationService.AuthorizeResourceAsync( | ||
| User, | ||
| ElementPermissionResource.WithKeys(ActionElementNew.ActionLetter, requestModel.Parent?.Id), | ||
| AuthorizationPolicies.ElementPermissionByResource); | ||
|
|
||
| if (authorizationResult.Succeeded is false) | ||
| { | ||
| return Forbidden(); | ||
| } | ||
|
|
||
| return await authorizedHandler(); | ||
| } | ||
| } |
57 changes: 57 additions & 0 deletions
57
src/Umbraco.Cms.Api.Management/Controllers/Element/DeleteElementController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| using Asp.Versioning; | ||
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Umbraco.Cms.Core; | ||
| using Umbraco.Cms.Core.Actions; | ||
| using Umbraco.Cms.Core.Models; | ||
| using Umbraco.Cms.Core.Security; | ||
| using Umbraco.Cms.Core.Security.Authorization; | ||
| using Umbraco.Cms.Core.Services; | ||
| using Umbraco.Cms.Core.Services.OperationStatus; | ||
| using Umbraco.Cms.Web.Common.Authorization; | ||
| using Umbraco.Extensions; | ||
|
|
||
| namespace Umbraco.Cms.Api.Management.Controllers.Element; | ||
|
|
||
| [ApiVersion("1.0")] | ||
| public class DeleteElementController : ElementControllerBase | ||
| { | ||
| private readonly IAuthorizationService _authorizationService; | ||
| private readonly IElementEditingService _elementEditingService; | ||
| private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; | ||
|
|
||
| public DeleteElementController( | ||
| IAuthorizationService authorizationService, | ||
| IElementEditingService elementEditingService, | ||
| IBackOfficeSecurityAccessor backOfficeSecurityAccessor) | ||
| { | ||
| _authorizationService = authorizationService; | ||
| _elementEditingService = elementEditingService; | ||
| _backOfficeSecurityAccessor = backOfficeSecurityAccessor; | ||
| } | ||
|
|
||
| [HttpDelete("{id:guid}")] | ||
| [MapToApiVersion("1.0")] | ||
| [ProducesResponseType(StatusCodes.Status200OK)] | ||
| [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)] | ||
| [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] | ||
| public async Task<IActionResult> Delete(CancellationToken cancellationToken, Guid id) | ||
| { | ||
| AuthorizationResult authorizationResult = await _authorizationService.AuthorizeResourceAsync( | ||
| User, | ||
| ElementPermissionResource.WithKeys(ActionElementDelete.ActionLetter, id), | ||
| AuthorizationPolicies.ElementPermissionByResource); | ||
|
|
||
| if (!authorizationResult.Succeeded) | ||
| { | ||
| return Forbidden(); | ||
| } | ||
|
|
||
| Attempt<IElement?, ContentEditingOperationStatus> result = await _elementEditingService.DeleteAsync(id, CurrentUserKey(_backOfficeSecurityAccessor)); | ||
|
|
||
| return result.Success | ||
| ? Ok() | ||
| : ContentEditingOperationStatusResult(result.Status); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.