Skip to content

Commit 9186d1d

Browse files
committed
Merge branch 'v14/dev' into release/14.0
2 parents cbf9781 + beba9d9 commit 9186d1d

File tree

255 files changed

+9000
-4425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

255 files changed

+9000
-4425
lines changed

src/Umbraco.Cms.Api.Delivery/Json/DeliveryApiJsonTypeResolver.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,36 @@ public override JsonTypeInfo GetTypeInfo(Type type, JsonSerializerOptions option
1212
{
1313
JsonTypeInfo jsonTypeInfo = base.GetTypeInfo(type, options);
1414

15+
Type[] derivedTypes = GetDerivedTypes(jsonTypeInfo);
16+
if (derivedTypes.Length > 0)
17+
{
18+
ConfigureJsonPolymorphismOptions(jsonTypeInfo, derivedTypes);
19+
}
20+
21+
return jsonTypeInfo;
22+
}
23+
24+
protected virtual Type[] GetDerivedTypes(JsonTypeInfo jsonTypeInfo)
25+
{
1526
if (jsonTypeInfo.Type == typeof(IApiContent))
1627
{
17-
ConfigureJsonPolymorphismOptions(jsonTypeInfo, typeof(ApiContent));
28+
return new[] { typeof(ApiContent) };
1829
}
19-
else if (jsonTypeInfo.Type == typeof(IApiContentResponse))
30+
31+
if (jsonTypeInfo.Type == typeof(IApiContentResponse))
2032
{
21-
ConfigureJsonPolymorphismOptions(jsonTypeInfo, typeof(ApiContentResponse));
33+
return new[] { typeof(ApiContentResponse) };
2234
}
23-
else if (jsonTypeInfo.Type == typeof(IRichTextElement))
35+
36+
if (jsonTypeInfo.Type == typeof(IRichTextElement))
2437
{
25-
ConfigureJsonPolymorphismOptions(jsonTypeInfo, typeof(RichTextRootElement), typeof(RichTextGenericElement), typeof(RichTextTextElement));
38+
return new[] { typeof(RichTextRootElement), typeof(RichTextGenericElement), typeof(RichTextTextElement) };
2639
}
2740

28-
return jsonTypeInfo;
41+
return Array.Empty<Type>();
2942
}
3043

31-
private void ConfigureJsonPolymorphismOptions(JsonTypeInfo jsonTypeInfo, params Type[] derivedTypes)
44+
protected void ConfigureJsonPolymorphismOptions(JsonTypeInfo jsonTypeInfo, params Type[] derivedTypes)
3245
{
3346
jsonTypeInfo.PolymorphismOptions = new JsonPolymorphismOptions
3447
{

src/Umbraco.Cms.Api.Management/Controllers/Culture/AllCultureController.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,21 @@
55
using Umbraco.Cms.Core.Mapping;
66
using Umbraco.Cms.Api.Management.ViewModels.Culture;
77
using Umbraco.Cms.Api.Common.ViewModels.Pagination;
8+
using Umbraco.Cms.Core.Services;
89

910
namespace Umbraco.Cms.Api.Management.Controllers.Culture;
1011

1112
[ApiVersion("1.0")]
1213
public class AllCultureController : CultureControllerBase
1314
{
1415
private readonly IUmbracoMapper _umbracoMapper;
16+
private readonly ICultureService _cultureService;
1517

16-
public AllCultureController(IUmbracoMapper umbracoMapper) => _umbracoMapper = umbracoMapper;
18+
public AllCultureController(IUmbracoMapper umbracoMapper, ICultureService cultureService)
19+
{
20+
_umbracoMapper = umbracoMapper;
21+
_cultureService = cultureService;
22+
}
1723

1824
/// <summary>
1925
/// Returns all cultures available for creating languages.
@@ -24,10 +30,7 @@ public class AllCultureController : CultureControllerBase
2430
[ProducesResponseType(typeof(PagedViewModel<CultureReponseModel>), StatusCodes.Status200OK)]
2531
public async Task<PagedViewModel<CultureReponseModel>> GetAll(CancellationToken cancellationToken, int skip = 0, int take = 100)
2632
{
27-
CultureInfo[] all = CultureInfo.GetCultures(CultureTypes.AllCultures)
28-
.DistinctBy(x => x.Name)
29-
.OrderBy(x => x.EnglishName)
30-
.ToArray();
33+
CultureInfo[] all = _cultureService.GetValidCultureInfos();
3134

3235
var viewModel = new PagedViewModel<CultureReponseModel>
3336
{

src/Umbraco.Cms.Api.Management/Controllers/DocumentType/AllowedAtRootDocumentTypeController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Umbraco.Cms.Api.Management.Controllers.DocumentType;
1313

1414
[ApiVersion("1.0")]
15-
[Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentsOrDocumentTypes)]
1615
public class AllowedAtRootDocumentTypeController : DocumentTypeControllerBase
1716
{
1817
private readonly IContentTypeService _contentTypeService;

src/Umbraco.Cms.Api.Management/Controllers/DocumentType/AllowedChildrenDocumentTypeController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace Umbraco.Cms.Api.Management.Controllers.DocumentType;
1515

1616
[ApiVersion("1.0")]
17-
[Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentsOrDocumentTypes)]
1817
public class AllowedChildrenDocumentTypeController : DocumentTypeControllerBase
1918
{
2019
private readonly IContentTypeService _contentTypeService;

src/Umbraco.Cms.Api.Management/Controllers/DocumentType/AvailableCompositionDocumentTypeController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Authorization;
23
using Microsoft.AspNetCore.Http;
34
using Microsoft.AspNetCore.Mvc;
45
using Umbraco.Cms.Api.Management.Factories;
56
using Umbraco.Cms.Api.Management.ViewModels.DocumentType;
67
using Umbraco.Cms.Core.Models;
78
using Umbraco.Cms.Core.Services.ContentTypeEditing;
9+
using Umbraco.Cms.Web.Common.Authorization;
810

911
namespace Umbraco.Cms.Api.Management.Controllers.DocumentType;
1012

1113
[ApiVersion("1.0")]
14+
[Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentTypes)]
1215
public class AvailableCompositionDocumentTypeController : DocumentTypeControllerBase
1316
{
1417
private readonly IContentTypeEditingService _contentTypeEditingService;

src/Umbraco.Cms.Api.Management/Controllers/DocumentType/CompositionReferenceDocumentTypeController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Authorization;
23
using Microsoft.AspNetCore.Http;
34
using Microsoft.AspNetCore.Mvc;
45
using Umbraco.Cms.Api.Management.ViewModels.DocumentType;
56
using Umbraco.Cms.Core.Mapping;
67
using Umbraco.Cms.Core.Models;
78
using Umbraco.Cms.Core.Services;
89
using Umbraco.Cms.Core.Services.OperationStatus;
10+
using Umbraco.Cms.Web.Common.Authorization;
911

1012
namespace Umbraco.Cms.Api.Management.Controllers.DocumentType;
1113

1214
[ApiVersion("1.0")]
15+
[Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentTypes)]
1316
public class CompositionReferenceDocumentTypeController : DocumentTypeControllerBase
1417
{
1518
private readonly IContentTypeService _contentTypeService;

src/Umbraco.Cms.Api.Management/Controllers/DocumentType/ConfigurationDocumentTypeController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Authorization;
23
using Microsoft.AspNetCore.Http;
34
using Microsoft.AspNetCore.Mvc;
45
using Microsoft.Extensions.Options;
56
using Umbraco.Cms.Api.Management.ViewModels.DocumentType;
67
using Umbraco.Cms.Core.Configuration.Models;
78
using Umbraco.Cms.Core.Features;
9+
using Umbraco.Cms.Web.Common.Authorization;
810

911
namespace Umbraco.Cms.Api.Management.Controllers.DocumentType;
1012

1113
[ApiVersion("1.0")]
14+
[Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentTypes)]
1215
public class ConfigurationDocumentTypeController : DocumentTypeControllerBase
1316
{
1417
private readonly UmbracoFeatures _umbracoFeatures;

src/Umbraco.Cms.Api.Management/Controllers/DocumentType/CopyDocumentTypeController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Authorization;
23
using Microsoft.AspNetCore.Http;
34
using Microsoft.AspNetCore.Mvc;
45
using Umbraco.Cms.Api.Management.ViewModels.DocumentType;
56
using Umbraco.Cms.Core;
67
using Umbraco.Cms.Core.Models;
78
using Umbraco.Cms.Core.Services;
89
using Umbraco.Cms.Core.Services.OperationStatus;
10+
using Umbraco.Cms.Web.Common.Authorization;
911

1012
namespace Umbraco.Cms.Api.Management.Controllers.DocumentType;
1113

1214
[ApiVersion("1.0")]
15+
[Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentTypes)]
1316
public class CopyDocumentTypeController : DocumentTypeControllerBase
1417
{
1518
private readonly IContentTypeService _contentTypeService;

src/Umbraco.Cms.Api.Management/Controllers/DocumentType/CreateDocumentTypeController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Authorization;
23
using Microsoft.AspNetCore.Http;
34
using Microsoft.AspNetCore.Mvc;
45
using Umbraco.Cms.Api.Management.Factories;
@@ -9,10 +10,12 @@
910
using Umbraco.Cms.Core.Security;
1011
using Umbraco.Cms.Core.Services.ContentTypeEditing;
1112
using Umbraco.Cms.Core.Services.OperationStatus;
13+
using Umbraco.Cms.Web.Common.Authorization;
1214

1315
namespace Umbraco.Cms.Api.Management.Controllers.DocumentType;
1416

1517
[ApiVersion("1.0")]
18+
[Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentTypes)]
1619
public class CreateDocumentTypeController : DocumentTypeControllerBase
1720
{
1821
private readonly IDocumentTypeEditingPresentationFactory _documentTypeEditingPresentationFactory;

src/Umbraco.Cms.Api.Management/Controllers/DocumentType/DeleteDocumentTypeController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Authorization;
23
using Microsoft.AspNetCore.Http;
34
using Microsoft.AspNetCore.Mvc;
45
using Umbraco.Cms.Api.Management.ViewModels.DocumentType;
56
using Umbraco.Cms.Core.Security;
67
using Umbraco.Cms.Core.Services;
78
using Umbraco.Cms.Core.Services.OperationStatus;
9+
using Umbraco.Cms.Web.Common.Authorization;
810

911
namespace Umbraco.Cms.Api.Management.Controllers.DocumentType;
1012

1113
[ApiVersion("1.0")]
14+
[Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentTypes)]
1215
public class DeleteDocumentTypeController : DocumentTypeControllerBase
1316
{
1417
private readonly IContentTypeService _contentTypeService;

0 commit comments

Comments
 (0)