Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ancestor endpoints and remove explicit parent context (#15746)
* Remove explicit parent context in API outputs * Add ancestor endpoints for document and data type (experimental for now) * Add ancestor endpoints for doctypes, media, mediatypes, partial views, scripts, static files, stylesheets and templates * Add unit tests for ancestor ID parsing * Add ancestor endpoint for dictionary items * Update OpenApi.json * Fix merge and regenerate OpenApi.json * Regenerate OpenApi.json * Rename "folder" to "parent" for consistency * Fix merge * Fix merge * Include "self" in ancestor endpoints * Handle ancestors for root items correctly * Remove "type" from recycle bin items * Tests against fixed values instead of calculated ones. --------- Co-authored-by: Sven Geusens <sge@umbraco.dk>
- Loading branch information
Showing
24 changed files
with
1,307 additions
and
52 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/Umbraco.Cms.Api.Management/Controllers/DataType/Tree/AncestorsDataTypeTreeController.cs
This file contains 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,22 @@ | ||
using Asp.Versioning; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Umbraco.Cms.Api.Management.ViewModels.Tree; | ||
using Umbraco.Cms.Core.Services; | ||
|
||
namespace Umbraco.Cms.Api.Management.Controllers.DataType.Tree; | ||
|
||
[ApiVersion("1.0")] | ||
public class AncestorsDataTypeTreeController : DataTypeTreeControllerBase | ||
{ | ||
public AncestorsDataTypeTreeController(IEntityService entityService, IDataTypeService dataTypeService) | ||
: base(entityService, dataTypeService) | ||
{ | ||
} | ||
|
||
[HttpGet("ancestors")] | ||
[MapToApiVersion("1.0")] | ||
[ProducesResponseType(typeof(IEnumerable<DataTypeTreeItemResponseModel>), StatusCodes.Status200OK)] | ||
public async Task<ActionResult<IEnumerable<DataTypeTreeItemResponseModel>>> Ancestors(Guid descendantId) | ||
=> await GetAncestors(descendantId); | ||
} |
22 changes: 22 additions & 0 deletions
22
...braco.Cms.Api.Management/Controllers/Dictionary/Tree/AncestorsDictionaryTreeController.cs
This file contains 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,22 @@ | ||
using Asp.Versioning; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Umbraco.Cms.Api.Management.ViewModels.Tree; | ||
using Umbraco.Cms.Core.Services; | ||
|
||
namespace Umbraco.Cms.Api.Management.Controllers.Dictionary.Tree; | ||
|
||
[ApiVersion("1.0")] | ||
public class AncestorsDictionaryTreeController : DictionaryTreeControllerBase | ||
{ | ||
public AncestorsDictionaryTreeController(IEntityService entityService, IDictionaryItemService dictionaryItemService) | ||
: base(entityService, dictionaryItemService) | ||
{ | ||
} | ||
|
||
[HttpGet("ancestors")] | ||
[MapToApiVersion("1.0")] | ||
[ProducesResponseType(typeof(IEnumerable<NamedEntityTreeItemResponseModel>), StatusCodes.Status200OK)] | ||
public async Task<ActionResult<IEnumerable<NamedEntityTreeItemResponseModel>>> Ancestors(Guid descendantId) | ||
=> await GetAncestors(descendantId); | ||
} |
This file contains 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 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 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
40 changes: 40 additions & 0 deletions
40
src/Umbraco.Cms.Api.Management/Controllers/Document/Tree/AncestorsDocumentTreeController.cs
This file contains 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,40 @@ | ||
using Asp.Versioning; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Umbraco.Cms.Api.Management.Factories; | ||
using Umbraco.Cms.Api.Management.Services.Entities; | ||
using Umbraco.Cms.Api.Management.ViewModels.Tree; | ||
using Umbraco.Cms.Core.Cache; | ||
using Umbraco.Cms.Core.Security; | ||
using Umbraco.Cms.Core.Services; | ||
|
||
namespace Umbraco.Cms.Api.Management.Controllers.Document.Tree; | ||
|
||
[ApiVersion("1.0")] | ||
public class AncestorsDocumentTreeController : DocumentTreeControllerBase | ||
{ | ||
public AncestorsDocumentTreeController( | ||
IEntityService entityService, | ||
IUserStartNodeEntitiesService userStartNodeEntitiesService, | ||
IDataTypeService dataTypeService, | ||
IPublicAccessService publicAccessService, | ||
AppCaches appCaches, | ||
IBackOfficeSecurityAccessor backofficeSecurityAccessor, | ||
IDocumentPresentationFactory documentPresentationFactory) | ||
: base( | ||
entityService, | ||
userStartNodeEntitiesService, | ||
dataTypeService, | ||
publicAccessService, | ||
appCaches, | ||
backofficeSecurityAccessor, | ||
documentPresentationFactory) | ||
{ | ||
} | ||
|
||
[HttpGet("ancestors")] | ||
[MapToApiVersion("1.0")] | ||
[ProducesResponseType(typeof(IEnumerable<DocumentTreeItemResponseModel>), StatusCodes.Status200OK)] | ||
public async Task<ActionResult<IEnumerable<DocumentTreeItemResponseModel>>> Ancestors(Guid descendantId) | ||
=> await GetAncestors(descendantId); | ||
} |
22 changes: 22 additions & 0 deletions
22
...o.Cms.Api.Management/Controllers/DocumentType/Tree/AncestorsDocumentTypeTreeController.cs
This file contains 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,22 @@ | ||
using Asp.Versioning; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Umbraco.Cms.Api.Management.ViewModels.Tree; | ||
using Umbraco.Cms.Core.Services; | ||
|
||
namespace Umbraco.Cms.Api.Management.Controllers.DocumentType.Tree; | ||
|
||
[ApiVersion("1.0")] | ||
public class AncestorsDocumentTypeTreeController : DocumentTypeTreeControllerBase | ||
{ | ||
public AncestorsDocumentTypeTreeController(IEntityService entityService, IContentTypeService contentTypeService) | ||
: base(entityService, contentTypeService) | ||
{ | ||
} | ||
|
||
[HttpGet("ancestors")] | ||
[MapToApiVersion("1.0")] | ||
[ProducesResponseType(typeof(IEnumerable<DocumentTypeTreeItemResponseModel>), StatusCodes.Status200OK)] | ||
public async Task<ActionResult<IEnumerable<DocumentTypeTreeItemResponseModel>>> Ancestors(Guid descendantId) | ||
=> await GetAncestors(descendantId); | ||
} |
32 changes: 32 additions & 0 deletions
32
src/Umbraco.Cms.Api.Management/Controllers/Media/Tree/AncestorsMediaTreeController.cs
This file contains 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 Asp.Versioning; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Umbraco.Cms.Api.Management.Factories; | ||
using Umbraco.Cms.Api.Management.Services.Entities; | ||
using Umbraco.Cms.Api.Management.ViewModels.Tree; | ||
using Umbraco.Cms.Core.Cache; | ||
using Umbraco.Cms.Core.Security; | ||
using Umbraco.Cms.Core.Services; | ||
|
||
namespace Umbraco.Cms.Api.Management.Controllers.Media.Tree; | ||
|
||
[ApiVersion("1.0")] | ||
public class AncestorsMediaTreeController : MediaTreeControllerBase | ||
{ | ||
public AncestorsMediaTreeController( | ||
IEntityService entityService, | ||
IUserStartNodeEntitiesService userStartNodeEntitiesService, | ||
IDataTypeService dataTypeService, | ||
AppCaches appCaches, | ||
IBackOfficeSecurityAccessor backofficeSecurityAccessor, | ||
IMediaPresentationFactory mediaPresentationFactory) | ||
: base(entityService, userStartNodeEntitiesService, dataTypeService, appCaches, backofficeSecurityAccessor, mediaPresentationFactory) | ||
{ | ||
} | ||
|
||
[HttpGet("ancestors")] | ||
[MapToApiVersion("1.0")] | ||
[ProducesResponseType(typeof(IEnumerable<MediaTreeItemResponseModel>), StatusCodes.Status200OK)] | ||
public async Task<ActionResult<IEnumerable<MediaTreeItemResponseModel>>> Ancestors(Guid descendantId) | ||
=> await GetAncestors(descendantId); | ||
} |
22 changes: 22 additions & 0 deletions
22
...Umbraco.Cms.Api.Management/Controllers/MediaType/Tree/AncestorsMediaTypeTreeController.cs
This file contains 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,22 @@ | ||
using Asp.Versioning; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Umbraco.Cms.Api.Management.ViewModels.Tree; | ||
using Umbraco.Cms.Core.Services; | ||
|
||
namespace Umbraco.Cms.Api.Management.Controllers.MediaType.Tree; | ||
|
||
[ApiVersion("1.0")] | ||
public class AncestorsMediaTypeTreeController : MediaTypeTreeControllerBase | ||
{ | ||
public AncestorsMediaTypeTreeController(IEntityService entityService, IMediaTypeService mediaTypeService) | ||
: base(entityService, mediaTypeService) | ||
{ | ||
} | ||
|
||
[HttpGet("ancestors")] | ||
[MapToApiVersion("1.0")] | ||
[ProducesResponseType(typeof(IEnumerable<MediaTypeTreeItemResponseModel>), StatusCodes.Status200OK)] | ||
public async Task<ActionResult<IEnumerable<MediaTypeTreeItemResponseModel>>> Ancestors(Guid descendantId) | ||
=> await GetAncestors(descendantId); | ||
} |
22 changes: 22 additions & 0 deletions
22
...aco.Cms.Api.Management/Controllers/PartialView/Tree/AncestorsPartialViewTreeController.cs
This file contains 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,22 @@ | ||
using Asp.Versioning; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Umbraco.Cms.Api.Management.ViewModels.Tree; | ||
using Umbraco.Cms.Core.IO; | ||
|
||
namespace Umbraco.Cms.Api.Management.Controllers.PartialView.Tree; | ||
|
||
[ApiVersion("1.0")] | ||
public class AncestorsPartialViewTreeController : PartialViewTreeControllerBase | ||
{ | ||
public AncestorsPartialViewTreeController(FileSystems fileSystems) | ||
: base(fileSystems) | ||
{ | ||
} | ||
|
||
[HttpGet("ancestors")] | ||
[MapToApiVersion("1.0")] | ||
[ProducesResponseType(typeof(IEnumerable<FileSystemTreeItemPresentationModel>), StatusCodes.Status200OK)] | ||
public async Task<ActionResult<IEnumerable<FileSystemTreeItemPresentationModel>>> Ancestors(string descendantPath) | ||
=> await GetAncestors(descendantPath); | ||
} |
This file contains 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
22 changes: 22 additions & 0 deletions
22
src/Umbraco.Cms.Api.Management/Controllers/Script/Tree/AncestorsScriptTreeController.cs
This file contains 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,22 @@ | ||
using Asp.Versioning; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Umbraco.Cms.Api.Management.ViewModels.Tree; | ||
using Umbraco.Cms.Core.IO; | ||
|
||
namespace Umbraco.Cms.Api.Management.Controllers.Script.Tree; | ||
|
||
[ApiVersion("1.0")] | ||
public class AncestorsScriptTreeController : ScriptTreeControllerBase | ||
{ | ||
public AncestorsScriptTreeController(FileSystems fileSystems) | ||
: base(fileSystems) | ||
{ | ||
} | ||
|
||
[HttpGet("ancestors")] | ||
[MapToApiVersion("1.0")] | ||
[ProducesResponseType(typeof(IEnumerable<FileSystemTreeItemPresentationModel>), StatusCodes.Status200OK)] | ||
public async Task<ActionResult<IEnumerable<FileSystemTreeItemPresentationModel>>> Ancestors(string descendantPath) | ||
=> await GetAncestors(descendantPath); | ||
} |
22 changes: 22 additions & 0 deletions
22
...braco.Cms.Api.Management/Controllers/StaticFile/Tree/AncestorsStaticFileTreeController.cs
This file contains 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,22 @@ | ||
using Asp.Versioning; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Umbraco.Cms.Api.Management.ViewModels.Tree; | ||
using Umbraco.Cms.Core.IO; | ||
|
||
namespace Umbraco.Cms.Api.Management.Controllers.StaticFile.Tree; | ||
|
||
[ApiVersion("1.0")] | ||
public class AncestorsStaticFileTreeController : StaticFileTreeControllerBase | ||
{ | ||
public AncestorsStaticFileTreeController(IPhysicalFileSystem physicalFileSystem) | ||
: base(physicalFileSystem) | ||
{ | ||
} | ||
|
||
[HttpGet("ancestors")] | ||
[MapToApiVersion("1.0")] | ||
[ProducesResponseType(typeof(IEnumerable<FileSystemTreeItemPresentationModel>), StatusCodes.Status200OK)] | ||
public async Task<ActionResult<IEnumerable<FileSystemTreeItemPresentationModel>>> Ancestors(string descendantPath) | ||
=> await GetAncestors(descendantPath); | ||
} |
This file contains 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
22 changes: 22 additions & 0 deletions
22
...braco.Cms.Api.Management/Controllers/Stylesheet/Tree/AncestorsStylesheetTreeController.cs
This file contains 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,22 @@ | ||
using Asp.Versioning; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Umbraco.Cms.Api.Management.ViewModels.Tree; | ||
using Umbraco.Cms.Core.IO; | ||
|
||
namespace Umbraco.Cms.Api.Management.Controllers.Stylesheet.Tree; | ||
|
||
[ApiVersion("1.0")] | ||
public class AncestorsStylesheetTreeController : StylesheetTreeControllerBase | ||
{ | ||
public AncestorsStylesheetTreeController(FileSystems fileSystems) | ||
: base(fileSystems) | ||
{ | ||
} | ||
|
||
[HttpGet("ancestors")] | ||
[MapToApiVersion("1.0")] | ||
[ProducesResponseType(typeof(IEnumerable<FileSystemTreeItemPresentationModel>), StatusCodes.Status200OK)] | ||
public async Task<ActionResult<IEnumerable<FileSystemTreeItemPresentationModel>>> Ancestors(string descendantPath) | ||
=> await GetAncestors(descendantPath); | ||
} |
Oops, something went wrong.