Skip to content

Commit

Permalink
Merge branch 'v15/dev' into v15/chore/random-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
madsrasmussen authored Nov 25, 2024
2 parents 792abce + 7162efc commit 45dd4de
Show file tree
Hide file tree
Showing 175 changed files with 6,306 additions and 1,780 deletions.
13 changes: 9 additions & 4 deletions build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ parameters:
displayName: Run SQL Server Integration Tests
type: boolean
default: false
- name: sqlServerLinuxAcceptanceTests
displayName: Run SQL Server Linux Acceptance Tests
type: boolean
default: false
- name: myGetDeploy
displayName: Deploy to MyGet
type: boolean
Expand Down Expand Up @@ -559,10 +563,11 @@ stages:
CONNECTIONSTRINGS__UMBRACODBDSN_PROVIDERNAME: Microsoft.Data.SqlClient
strategy:
matrix:
Linux:
vmImage: "ubuntu-latest"
SA_PASSWORD: $(UMBRACO__CMS__UNATTENDED__UNATTENDEDUSERPASSWORD)
CONNECTIONSTRINGS__UMBRACODBDSN: "Server=(local);Database=Umbraco;User Id=sa;Password=$(SA_PASSWORD);TrustServerCertificate=True"
${{ if eq(parameters.sqlServerLinuxAcceptanceTests, True) }} :
Linux:
vmImage: "ubuntu-latest"
SA_PASSWORD: $(UMBRACO__CMS__UNATTENDED__UNATTENDEDUSERPASSWORD)
CONNECTIONSTRINGS__UMBRACODBDSN: "Server=(local);Database=Umbraco;User Id=sa;Password=$(SA_PASSWORD);TrustServerCertificate=True"
Windows:
vmImage: "windows-latest"
pool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Umbraco.Cms.Api.Management.Controllers.DataType;

[VersionedApiBackOfficeRoute(Constants.UdiEntityType.DataType)]
[ApiExplorerSettings(GroupName = "Data Type")]
[Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentOrMediaOrContentTypes)]
[Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentsOrMediaOrMembersOrContentTypes)]
public abstract class DataTypeControllerBase : ManagementApiControllerBase
{
protected IActionResult DataTypeOperationStatusResult(DataTypeOperationStatus status) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ void AddAllowedApplicationsPolicy(string policyName, params string[] allowedClai
AddAllowedApplicationsPolicy(AuthorizationPolicies.TreeAccessDocuments, Constants.Applications.Content);
AddAllowedApplicationsPolicy(AuthorizationPolicies.TreeAccessDocumentsOrDocumentTypes, Constants.Applications.Content, Constants.Applications.Settings);
AddAllowedApplicationsPolicy(AuthorizationPolicies.TreeAccessDocumentOrMediaOrContentTypes, Constants.Applications.Content, Constants.Applications.Settings, Constants.Applications.Media);
AddAllowedApplicationsPolicy(AuthorizationPolicies.TreeAccessDocumentsOrMediaOrMembersOrContentTypes, Constants.Applications.Content, Constants.Applications.Media, Constants.Applications.Members, Constants.Applications.Settings);
AddAllowedApplicationsPolicy(AuthorizationPolicies.TreeAccessDocumentTypes, Constants.Applications.Settings);
AddAllowedApplicationsPolicy(AuthorizationPolicies.TreeAccessLanguages, Constants.Applications.Settings);
AddAllowedApplicationsPolicy(AuthorizationPolicies.TreeAccessMediaTypes, Constants.Applications.Settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@ internal sealed class DocumentPresentationFactory : IDocumentPresentationFactory
private readonly ITemplateService _templateService;
private readonly IPublicAccessService _publicAccessService;
private readonly TimeProvider _timeProvider;
private readonly IIdKeyMap _idKeyMap;

public DocumentPresentationFactory(
IUmbracoMapper umbracoMapper,
IDocumentUrlFactory documentUrlFactory,
ITemplateService templateService,
IPublicAccessService publicAccessService,
TimeProvider timeProvider)
TimeProvider timeProvider,
IIdKeyMap idKeyMap)
{
_umbracoMapper = umbracoMapper;
_documentUrlFactory = documentUrlFactory;
_templateService = templateService;
_publicAccessService = publicAccessService;
_timeProvider = timeProvider;
_idKeyMap = idKeyMap;
}

public async Task<DocumentResponseModel> CreateResponseModelAsync(IContent content)
Expand Down Expand Up @@ -73,10 +76,14 @@ public async Task<PublishedDocumentResponseModel> CreatePublishedResponseModelAs

public DocumentItemResponseModel CreateItemResponseModel(IDocumentEntitySlim entity)
{
Attempt<Guid> parentKeyAttempt = _idKeyMap.GetKeyForId(entity.ParentId, UmbracoObjectTypes.Document);

var responseModel = new DocumentItemResponseModel
{
Id = entity.Key,
IsTrashed = entity.Trashed
IsTrashed = entity.Trashed,
Parent = parentKeyAttempt.Success ? new ReferenceByIdModel { Id = parentKeyAttempt.Result } : null,
HasChildren = entity.HasChildren,
};

responseModel.IsProtected = _publicAccessService.IsProtected(entity.Path);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
using Umbraco.Cms.Api.Management.ViewModels.Content;
using Umbraco.Cms.Api.Management.ViewModels;
using Umbraco.Cms.Api.Management.ViewModels.Content;
using Umbraco.Cms.Api.Management.ViewModels.Media;
using Umbraco.Cms.Api.Management.ViewModels.Media.Item;
using Umbraco.Cms.Api.Management.ViewModels.MediaType;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Mapping;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Services;

namespace Umbraco.Cms.Api.Management.Factories;

internal sealed class MediaPresentationFactory : IMediaPresentationFactory
{
private readonly IUmbracoMapper _umbracoMapper;
private readonly IMediaUrlFactory _mediaUrlFactory;
private readonly IIdKeyMap _idKeyMap;

public MediaPresentationFactory(
IUmbracoMapper umbracoMapper,
IMediaUrlFactory mediaUrlFactory)
IMediaUrlFactory mediaUrlFactory,
IIdKeyMap idKeyMap)
{
_umbracoMapper = umbracoMapper;
_mediaUrlFactory = mediaUrlFactory;
_idKeyMap = idKeyMap;
}

public MediaResponseModel CreateResponseModel(IMedia media)
Expand All @@ -32,10 +38,14 @@ public MediaResponseModel CreateResponseModel(IMedia media)

public MediaItemResponseModel CreateItemResponseModel(IMediaEntitySlim entity)
{
Attempt<Guid> parentKeyAttempt = _idKeyMap.GetKeyForId(entity.ParentId, UmbracoObjectTypes.Media);

var responseModel = new MediaItemResponseModel
{
Id = entity.Key,
IsTrashed = entity.Trashed
IsTrashed = entity.Trashed,
Parent = parentKeyAttempt.Success ? new ReferenceByIdModel { Id = parentKeyAttempt.Result } : null,
HasChildren = entity.HasChildren,
};

responseModel.MediaType = _umbracoMapper.Map<MediaTypeReferenceResponseModel>(entity)!;
Expand Down
24 changes: 24 additions & 0 deletions src/Umbraco.Cms.Api.Management/OpenApi.json
Original file line number Diff line number Diff line change
Expand Up @@ -36738,6 +36738,7 @@
"DocumentItemResponseModel": {
"required": [
"documentType",
"hasChildren",
"id",
"isProtected",
"isTrashed",
Expand All @@ -36755,6 +36756,17 @@
"isProtected": {
"type": "boolean"
},
"parent": {
"oneOf": [
{
"$ref": "#/components/schemas/ReferenceByIdModel"
}
],
"nullable": true
},
"hasChildren": {
"type": "boolean"
},
"documentType": {
"oneOf": [
{
Expand Down Expand Up @@ -38895,6 +38907,7 @@
},
"MediaItemResponseModel": {
"required": [
"hasChildren",
"id",
"isTrashed",
"mediaType",
Expand All @@ -38909,6 +38922,17 @@
"isTrashed": {
"type": "boolean"
},
"parent": {
"oneOf": [
{
"$ref": "#/components/schemas/ReferenceByIdModel"
}
],
"nullable": true
},
"hasChildren": {
"type": "boolean"
},
"mediaType": {
"oneOf": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ public class DocumentItemResponseModel : ItemResponseModelBase

public bool IsProtected { get; set; }

public ReferenceByIdModel? Parent { get; set; }

public bool HasChildren { get; set; }

public DocumentTypeReferenceResponseModel DocumentType { get; set; } = new();

public IEnumerable<DocumentVariantItemResponseModel> Variants { get; set; } = Enumerable.Empty<DocumentVariantItemResponseModel>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ public class MediaItemResponseModel : ItemResponseModelBase
{
public bool IsTrashed { get; set; }

public ReferenceByIdModel? Parent { get; set; }

public bool HasChildren { get; set; }

public MediaTypeReferenceResponseModel MediaType { get; set; } = new();

public IEnumerable<VariantItemResponseModel> Variants { get; set; } = Enumerable.Empty<VariantItemResponseModel>();
Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Core/Constants-Icons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static class Icons
/// <summary>
/// System media audio icon.
/// </summary>
public const string MediaAudio = "icon-sound-waves";
public const string MediaAudio = "icon-audio-lines";

/// <summary>
/// System media article icon
Expand All @@ -77,7 +77,7 @@ public static class Icons
/// <summary>
/// System media vector icon.
/// </summary>
public const string MediaVectorGraphics = "icon-picture";
public const string MediaVectorGraphics = "icon-origami";

/// <summary>
/// System media folder icon.
Expand Down
9 changes: 6 additions & 3 deletions src/Umbraco.Core/EmbeddedResources/Snippets/Breadcrumb.cshtml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
@using Umbraco.Cms.Core.PublishedCache
@using Umbraco.Cms.Core.Routing
@using Umbraco.Extensions
@using Umbraco.Cms.Core.Services.Navigation
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@inject IPublishedContentCache PublishedContentCache
@inject IDocumentNavigationQueryService DocumentNavigationQueryService
@inject IPublishedUrlProvider PublishedUrlProvider
@*
This snippet makes a breadcrumb of parents using an unordered HTML list.
How it works:
- It uses the Ancestors() method to get all parents and then generates links so the visitor can go back
- It uses the Ancestors method to get all parents and then generates links so the visitor can go back
- Finally it outputs the name of the current page (without a link)
*@

@{ var selection = Model?.Content.Ancestors().ToArray(); }
@{ var selection = Model?.Content.Ancestors(PublishedContentCache, DocumentNavigationQueryService).ToArray(); }

@if (selection?.Length > 0)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
@using Umbraco.Cms.Core.PublishedCache
@using Umbraco.Cms.Core.Routing
@using Umbraco.Extensions
@using Umbraco.Cms.Core.Services.Navigation
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@inject IPublishedContentCache PublishedContentCache
@inject IDocumentNavigationQueryService DocumentNavigationQueryService
@inject IPublishedUrlProvider PublishedUrlProvider
@*
This snippet makes a list of links to the of parents of the current page using an unordered HTML list.
How it works:
- It uses the Ancestors() method to get all parents and then generates links so the visitor can go back
- It uses the Ancestors method to get all parents and then generates links so the visitor can go back
- Finally it outputs the name of the current page (without a link)
*@

@{ var selection = Model?.Content.Ancestors().ToArray(); }
@{ var selection = Model?.Content.Ancestors(PublishedContentCache, DocumentNavigationQueryService).ToArray(); }

@if (selection?.Length > 0)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
@using Umbraco.Cms.Core
@using Umbraco.Cms.Core.Models.PublishedContent
@using Umbraco.Cms.Core.PublishedCache
@using Umbraco.Cms.Core.Routing
@using Umbraco.Extensions
@using Umbraco.Cms.Core.Services.Navigation
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@inject IVariationContextAccessor VariationContextAccessor
@inject IPublishedContentCache PublishedContentCache
@inject IDocumentNavigationQueryService DocumentNavigationQueryService
@inject IPublishedValueFallback PublishedValueFallback
@inject IPublishedUrlProvider PublishedUrlProvider
@*
Expand All @@ -13,7 +16,7 @@
- It then generates links so the visitor can go to each page
*@

@{ var selection = Model?.Content.Children.Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); }
@{ var selection = Model?.Content.Children(VariationContextAccessor, PublishedContentCache, DocumentNavigationQueryService).Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); }

@if (selection?.Length > 0)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
@using Umbraco.Cms.Core
@using Umbraco.Cms.Core.Models.PublishedContent
@using Umbraco.Cms.Core.PublishedCache
@using Umbraco.Cms.Core.Routing
@using Umbraco.Extensions
@using Umbraco.Cms.Core.Services.Navigation
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@inject IVariationContextAccessor VariationContextAccessor
@inject IPublishedContentCache PublishedContentCache
@inject IDocumentNavigationQueryService DocumentNavigationQueryService
@inject IPublishedValueFallback PublishedValueFallback
@inject IPublishedUrlProvider PublishedUrlProvider
@*
Expand All @@ -14,7 +17,7 @@
- It then generates links so the visitor can go to each page
*@

@{ var selection = Model?.Content.Children.Where(x => x.IsVisible(PublishedValueFallback)).OrderByDescending(x => x.CreateDate).ToArray(); }
@{ var selection = Model?.Content.Children(VariationContextAccessor, PublishedContentCache, DocumentNavigationQueryService).Where(x => x.IsVisible(PublishedValueFallback)).OrderByDescending(x => x.CreateDate).ToArray(); }

@if (selection?.Length > 0)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
@using Umbraco.Cms.Core
@using Umbraco.Cms.Core.Models.PublishedContent
@using Umbraco.Cms.Core.PublishedCache
@using Umbraco.Cms.Core.Routing
@using Umbraco.Extensions
@using Umbraco.Cms.Core.Services.Navigation
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@inject IVariationContextAccessor VariationContextAccessor
@inject IPublishedContentCache PublishedContentCache
@inject IDocumentNavigationQueryService DocumentNavigationQueryService
@inject IPublishedValueFallback PublishedValueFallback
@inject IPublishedUrlProvider PublishedUrlProvider
@*
Expand All @@ -14,14 +17,14 @@
- It then generates links so the visitor can go to each page
*@

@{ var selection = Model?.Content.Children.Where(x => x.IsVisible(PublishedValueFallback)).OrderBy(x => x.Name).ToArray(); }
@{ var selection = Model?.Content.Children(VariationContextAccessor, PublishedContentCache, DocumentNavigationQueryService).Where(x => x.IsVisible(PublishedValueFallback)).OrderBy(x => x.Name).ToArray(); }

@if (selection?.Length > 0)
{
<ul>
@foreach (var item in selection)
{
<li><a href="@item.Url(PublishedUrlProvider))">@item.Name</a></li>
<li><a href="@item.Url(PublishedUrlProvider)">@item.Name</a></li>
}
</ul>
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
@using Umbraco.Cms.Core
@using Umbraco.Cms.Core.Models.PublishedContent
@using Umbraco.Cms.Core.PublishedCache
@using Umbraco.Cms.Core.Routing
@using Umbraco.Extensions
@using Umbraco.Cms.Core.Services.Navigation
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@inject IVariationContextAccessor VariationContextAccessor
@inject IPublishedContentCache PublishedContentCache
@inject IDocumentNavigationQueryService DocumentNavigationQueryService
@inject IPublishedValueFallback PublishedValueFallback
@inject IPublishedUrlProvider PublishedUrlProvider
@*
Expand All @@ -13,7 +15,7 @@
(You can find the alias of your Document Type by editing it in the Settings section)
*@

@{ var selection = Model?.Content.Children<IPublishedContent>(VariationContextAccessor).Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); }
@{ var selection = Model?.Content.Children<IPublishedContent>(VariationContextAccessor, PublishedContentCache, DocumentNavigationQueryService).Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); }

@if (selection?.Length > 0)
{
Expand Down
9 changes: 6 additions & 3 deletions src/Umbraco.Core/EmbeddedResources/Snippets/Navigation.cshtml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
@using Umbraco.Cms.Core
@using Umbraco.Cms.Core.Models.PublishedContent
@using Umbraco.Cms.Core.PublishedCache
@using Umbraco.Cms.Core.Routing
@using Umbraco.Extensions
@using Umbraco.Cms.Core.Services.Navigation
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@inject IVariationContextAccessor VariationContextAccessor
@inject IPublishedContentCache PublishedContentCache
@inject IDocumentNavigationQueryService DocumentNavigationQueryService
@inject IPublishedValueFallback PublishedValueFallback
@inject IPublishedUrlProvider PublishedUrlProvider
@*
Expand All @@ -11,7 +14,7 @@
It also highlights the current active page/section in the navigation with the CSS class "current".
*@

@{ var selection = Model?.Content.Root().Children.Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); }
@{ var selection = Model?.Content.Root(PublishedContentCache, DocumentNavigationQueryService).Children(VariationContextAccessor, PublishedContentCache, DocumentNavigationQueryService).Where(x => x.IsVisible(PublishedValueFallback)).ToArray(); }

@if (selection?.Length > 0)
{
Expand Down
Loading

0 comments on commit 45dd4de

Please sign in to comment.