-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Member types: Implement containers #20706
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
Open
ronaldbarendse
wants to merge
10
commits into
main
Choose a base branch
from
v17/feature/member-type-containers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,021
−330
Open
Changes from 10 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ac20b43
Add MemberType/MemberTypeContainer to supported EntityContainer objec…
ronaldbarendse b9a5fd5
Implement MemberTypeContainerRepository
ronaldbarendse d5f2a88
Update and add member type container API endpoints
ronaldbarendse 577c03d
Complete server and client-side implementation for member type contai…
AndyButland f372f11
Merge branch 'main' into v17/feature/member-type-containers
AndyButland 9d59c05
Fix FE linting errors.
AndyButland 5b534bc
Export folder constants.
AndyButland 5fda6c1
Applied suggestions from code review.
AndyButland 9ad1414
Updated management API authorization tests for member types.
AndyButland 8c6351d
Merge branch 'main' into v17/feature/member-type-containers
AndyButland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
44 changes: 44 additions & 0 deletions
44
src/Umbraco.Cms.Api.Management/Controllers/MemberType/ExportMemberTypeController.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,44 @@ | ||
| using Asp.Versioning; | ||
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Umbraco.Cms.Api.Management.Factories; | ||
| using Umbraco.Cms.Core.Models; | ||
| using Umbraco.Cms.Core.Services; | ||
| using Umbraco.Cms.Core.Services.OperationStatus; | ||
| using Umbraco.Cms.Web.Common.Authorization; | ||
|
|
||
| namespace Umbraco.Cms.Api.Management.Controllers.MemberType; | ||
|
|
||
| [ApiVersion("1.0")] | ||
| [Authorize(Policy = AuthorizationPolicies.TreeAccessMemberTypes)] | ||
| public class ExportMemberTypeController : MemberTypeControllerBase | ||
| { | ||
| private readonly IMemberTypeService _memberTypeService; | ||
| private readonly IUdtFileContentFactory _fileContentFactory; | ||
|
|
||
| public ExportMemberTypeController( | ||
| IMemberTypeService memberTypeService, | ||
| IUdtFileContentFactory fileContentFactory) | ||
| { | ||
| _memberTypeService = memberTypeService; | ||
| _fileContentFactory = fileContentFactory; | ||
| } | ||
|
|
||
| [HttpGet("{id:guid}/export")] | ||
| [MapToApiVersion("1.0")] | ||
| [ProducesResponseType(typeof(FileContentResult), StatusCodes.Status200OK)] | ||
| [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] | ||
| public IActionResult Export( | ||
| CancellationToken cancellationToken, | ||
| Guid id) | ||
| { | ||
| IMemberType? memberType = _memberTypeService.Get(id); | ||
| if (memberType is null) | ||
| { | ||
| return OperationStatusResult(ContentTypeOperationStatus.NotFound); | ||
| } | ||
|
|
||
| return _fileContentFactory.Create(memberType); | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
src/Umbraco.Cms.Api.Management/Controllers/MemberType/ImportExistingMemberTypeController.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,46 @@ | ||
| using Asp.Versioning; | ||
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Umbraco.Cms.Api.Management.ViewModels.MemberType; | ||
| using Umbraco.Cms.Core; | ||
| using Umbraco.Cms.Core.Models; | ||
| using Umbraco.Cms.Core.Security; | ||
| using Umbraco.Cms.Core.Services.ImportExport; | ||
| using Umbraco.Cms.Core.Services.OperationStatus; | ||
| using Umbraco.Cms.Web.Common.Authorization; | ||
|
|
||
| namespace Umbraco.Cms.Api.Management.Controllers.MemberType; | ||
|
|
||
| [ApiVersion("1.0")] | ||
| [Authorize(Policy = AuthorizationPolicies.TreeAccessMemberTypes)] | ||
| public class ImportExistingMemberTypeController : MemberTypeControllerBase | ||
| { | ||
| private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; | ||
| private readonly IMemberTypeImportService _memberTypeImportService; | ||
|
|
||
| public ImportExistingMemberTypeController( | ||
| IBackOfficeSecurityAccessor backOfficeSecurityAccessor, | ||
| IMemberTypeImportService memberTypeImportService) | ||
| { | ||
| _backOfficeSecurityAccessor = backOfficeSecurityAccessor; | ||
| _memberTypeImportService = memberTypeImportService; | ||
| } | ||
|
|
||
| [HttpPut("{id:guid}/import")] | ||
| [MapToApiVersion("1.0")] | ||
| [ProducesResponseType(StatusCodes.Status200OK)] | ||
| [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] | ||
| [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)] | ||
| public async Task<IActionResult> Import( | ||
| CancellationToken cancellationToken, | ||
| Guid id, | ||
| ImportMemberTypeRequestModel model) | ||
| { | ||
| Attempt<IMemberType?, MemberTypeImportOperationStatus> importAttempt = await _memberTypeImportService.Import(model.File.Id, CurrentUserKey(_backOfficeSecurityAccessor)); | ||
|
|
||
| return importAttempt.Success is false | ||
| ? MemberTypeImportOperationStatusResult(importAttempt.Status) | ||
| : Ok(); | ||
| } | ||
| } |
45 changes: 45 additions & 0 deletions
45
src/Umbraco.Cms.Api.Management/Controllers/MemberType/ImportNewMemberTypeController.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,45 @@ | ||
| using Asp.Versioning; | ||
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Umbraco.Cms.Api.Management.ViewModels.MemberType; | ||
| using Umbraco.Cms.Core; | ||
| using Umbraco.Cms.Core.Models; | ||
| using Umbraco.Cms.Core.Security; | ||
| using Umbraco.Cms.Core.Services.ImportExport; | ||
| using Umbraco.Cms.Core.Services.OperationStatus; | ||
| using Umbraco.Cms.Web.Common.Authorization; | ||
|
|
||
| namespace Umbraco.Cms.Api.Management.Controllers.MemberType; | ||
|
|
||
| [ApiVersion("1.0")] | ||
| [Authorize(Policy = AuthorizationPolicies.TreeAccessMemberTypes)] | ||
| public class ImportNewMemberTypeController : MemberTypeControllerBase | ||
| { | ||
| private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; | ||
| private readonly IMemberTypeImportService _memberTypeImportService; | ||
|
|
||
| public ImportNewMemberTypeController( | ||
| IBackOfficeSecurityAccessor backOfficeSecurityAccessor, | ||
| IMemberTypeImportService memberTypeImportService) | ||
| { | ||
| _backOfficeSecurityAccessor = backOfficeSecurityAccessor; | ||
| _memberTypeImportService = memberTypeImportService; | ||
| } | ||
|
|
||
| [HttpPost("import")] | ||
| [MapToApiVersion("1.0")] | ||
| [ProducesResponseType(StatusCodes.Status201Created)] | ||
| [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] | ||
| [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)] | ||
| public async Task<IActionResult> Import( | ||
| CancellationToken cancellationToken, | ||
| ImportMemberTypeRequestModel model) | ||
| { | ||
| Attempt<IMemberType?, MemberTypeImportOperationStatus> importAttempt = await _memberTypeImportService.Import(model.File.Id, CurrentUserKey(_backOfficeSecurityAccessor)); | ||
|
|
||
| return importAttempt.Success is false | ||
| ? MemberTypeImportOperationStatusResult(importAttempt.Status) | ||
| : CreatedAtId<ByKeyMemberTypeController>(controller => nameof(controller.ByKey), importAttempt.Result!.Key); | ||
| } | ||
| } |
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
39 changes: 39 additions & 0 deletions
39
src/Umbraco.Cms.Api.Management/Controllers/MemberType/MoveMemberTypeController.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,39 @@ | ||
| using Asp.Versioning; | ||
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Umbraco.Cms.Api.Management.ViewModels.MemberType; | ||
| using Umbraco.Cms.Core; | ||
| using Umbraco.Cms.Core.Models; | ||
| using Umbraco.Cms.Core.Services; | ||
| using Umbraco.Cms.Core.Services.OperationStatus; | ||
| using Umbraco.Cms.Web.Common.Authorization; | ||
|
|
||
| namespace Umbraco.Cms.Api.Management.Controllers.MemberType; | ||
|
|
||
| [ApiVersion("1.0")] | ||
| [Authorize(Policy = AuthorizationPolicies.TreeAccessMemberTypes)] | ||
| public class MoveMemberTypeController : MemberTypeControllerBase | ||
| { | ||
| private readonly IMemberTypeService _memberTypeService; | ||
|
|
||
| public MoveMemberTypeController(IMemberTypeService memberTypeService) | ||
| => _memberTypeService = memberTypeService; | ||
|
|
||
| [HttpPut("{id:guid}/move")] | ||
| [MapToApiVersion("1.0")] | ||
| [ProducesResponseType(StatusCodes.Status200OK)] | ||
| [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)] | ||
| [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] | ||
| public async Task<IActionResult> Move( | ||
| CancellationToken cancellationToken, | ||
| Guid id, | ||
| MoveMemberTypeRequestModel moveMemberTypeRequestModel) | ||
| { | ||
| Attempt<IMemberType?, ContentTypeStructureOperationStatus> result = await _memberTypeService.MoveAsync(id, moveMemberTypeRequestModel.Target?.Id); | ||
|
|
||
| return result.Success | ||
| ? Ok() | ||
| : StructureOperationStatusResult(result.Status); | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
...braco.Cms.Api.Management/Controllers/MemberType/Tree/AncestorsMemberTypeTreeController.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,23 @@ | ||
| using Asp.Versioning; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Umbraco.Cms.Api.Management.Services.Flags; | ||
| using Umbraco.Cms.Api.Management.ViewModels.Tree; | ||
| using Umbraco.Cms.Core.Services; | ||
|
|
||
| namespace Umbraco.Cms.Api.Management.Controllers.MemberType.Tree; | ||
|
|
||
| [ApiVersion("1.0")] | ||
| public class AncestorsMemberTypeTreeController : MemberTypeTreeControllerBase | ||
| { | ||
| public AncestorsMemberTypeTreeController(IEntityService entityService, FlagProviderCollection flagProviders, IMemberTypeService memberTypeService) | ||
| : base(entityService, flagProviders, memberTypeService) | ||
| { | ||
| } | ||
|
|
||
| [HttpGet("ancestors")] | ||
| [MapToApiVersion("1.0")] | ||
| [ProducesResponseType(typeof(IEnumerable<MemberTypeTreeItemResponseModel>), StatusCodes.Status200OK)] | ||
| public async Task<ActionResult<IEnumerable<MemberTypeTreeItemResponseModel>>> Ancestors(CancellationToken cancellationToken, Guid descendantId) | ||
| => await GetAncestors(descendantId); | ||
| } |
31 changes: 31 additions & 0 deletions
31
...mbraco.Cms.Api.Management/Controllers/MemberType/Tree/ChildrenMemberTypeTreeController.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,31 @@ | ||
| using Asp.Versioning; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Umbraco.Cms.Api.Common.ViewModels.Pagination; | ||
| using Umbraco.Cms.Api.Management.Services.Flags; | ||
| using Umbraco.Cms.Api.Management.ViewModels.Tree; | ||
| using Umbraco.Cms.Core.Services; | ||
|
|
||
| namespace Umbraco.Cms.Api.Management.Controllers.MemberType.Tree; | ||
|
|
||
| [ApiVersion("1.0")] | ||
| public class ChildrenMemberTypeTreeController : MemberTypeTreeControllerBase | ||
| { | ||
| public ChildrenMemberTypeTreeController(IEntityService entityService, FlagProviderCollection flagProviders, IMemberTypeService memberTypeService) | ||
| : base(entityService, flagProviders, memberTypeService) | ||
| { } | ||
|
|
||
| [HttpGet("children")] | ||
| [MapToApiVersion("1.0")] | ||
| [ProducesResponseType(typeof(PagedViewModel<MemberTypeTreeItemResponseModel>), StatusCodes.Status200OK)] | ||
| public async Task<ActionResult<PagedViewModel<MemberTypeTreeItemResponseModel>>> Children( | ||
| CancellationToken cancellationToken, | ||
| Guid parentId, | ||
| int skip = 0, | ||
| int take = 100, | ||
| bool foldersOnly = false) | ||
| { | ||
| RenderFoldersOnly(foldersOnly); | ||
| return await GetChildren(parentId, skip, take); | ||
| } | ||
|
Check warning on line 30 in src/Umbraco.Cms.Api.Management/Controllers/MemberType/Tree/ChildrenMemberTypeTreeController.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
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
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.