Skip to content
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

V11: merge dev to contrib #13438

Merged
merged 11 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ stages:
workingDirectory: tests/Umbraco.Tests.AcceptanceTest
env:
CI: true
CommitId: $(Build.SourceVersion)
AgentOs: $(Agent.OS)
- pwsh: |
docker logs $(dockerImageName) > $(Build.ArtifactStagingDirectory)/playwright.log 2>&1
docker stop $(dockerImageName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class SearcherSearchSearchController : SearchControllerBase

[HttpGet("searcher/{searcherName}/search")]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(PagedViewModel<PagedViewModel<SearchResultViewModel>>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(PagedViewModel<SearchResultViewModel>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
public async Task<ActionResult<PagedViewModel<SearchResultViewModel>>> GetSearchResults(string searcherName, string? query, int skip, int take)
{
Expand Down
16 changes: 16 additions & 0 deletions src/Umbraco.Cms.ManagementApi/Factories/IndexViewModelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ public IndexViewModel Create(IIndex index)

Attempt<string?> isHealthy = indexDiag.IsHealthy();

var properties = new Dictionary<string, object?>();

foreach (var property in indexDiag.Metadata)
{
if (property.Value is null)
{
properties[property.Key] = null;
}
else
{
var propertyType = property.Value.GetType();
properties[property.Key] = propertyType.IsClass && !propertyType.IsArray ? property.Value?.ToString() : property.Value;
}
}

var indexerModel = new IndexViewModel
{
Name = index.Name,
Expand All @@ -45,6 +60,7 @@ public IndexViewModel Create(IIndex index)
SearcherName = index.Searcher.Name,
DocumentCount = indexDiag.GetDocumentCount(),
FieldCount = indexDiag.GetFieldNames().Count(),
ProviderProperties = properties,
};

return indexerModel;
Expand Down
38 changes: 15 additions & 23 deletions src/Umbraco.Cms.ManagementApi/OpenApi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2827,7 +2827,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PagedPaged"
"$ref": "#/components/schemas/PagedSearchResult"
}
}
}
Expand Down Expand Up @@ -4854,11 +4854,18 @@
"additionalProperties": false
},
"Index": {
"required": [
"canRebuild",
"documentCount",
"fieldCount",
"isHealthy",
"name"
],
"type": "object",
"properties": {
"name": {
"type": "string",
"nullable": true
"minLength": 1,
"type": "string"
},
"healthStatus": {
"type": "string",
Expand All @@ -4882,6 +4889,11 @@
"fieldCount": {
"type": "integer",
"format": "int32"
},
"providerProperties": {
"type": "object",
"additionalProperties": {},
"nullable": true
}
},
"additionalProperties": false
Expand Down Expand Up @@ -5754,26 +5766,6 @@
},
"additionalProperties": false
},
"PagedPaged": {
"required": [
"items",
"total"
],
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int64"
},
"items": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PagedSearchResult"
}
}
},
"additionalProperties": false
},
"PagedRecycleBinItem": {
"required": [
"items",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
namespace Umbraco.Cms.ManagementApi.ViewModels.Search;
using System.ComponentModel.DataAnnotations;

namespace Umbraco.Cms.ManagementApi.ViewModels.Search;

public class IndexViewModel
{
[Required]
public string Name { get; init; } = null!;

public string? HealthStatus { get; init; }

[Required]
public bool IsHealthy => HealthStatus == "Healthy";

[Required]
public bool CanRebuild { get; init; }

public string SearcherName { get; init; } = null!;

[Required]
public long DocumentCount { get; init; }

[Required]
public int FieldCount { get; init; }

public IReadOnlyDictionary<string, object?>? ProviderProperties { get; init; }
}
28 changes: 28 additions & 0 deletions src/Umbraco.Core/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Umbraco.Cms.Core.Models.Blocks.BlockGridItem.get_ForceLeft</Target>
<Left>lib/net7.0/Umbraco.Core.dll</Left>
<Right>lib/net7.0/Umbraco.Core.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Umbraco.Cms.Core.Models.Blocks.BlockGridItem.get_ForceRight</Target>
<Left>lib/net7.0/Umbraco.Core.dll</Left>
<Right>lib/net7.0/Umbraco.Core.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Umbraco.Cms.Core.Models.Blocks.BlockGridItem.set_ForceLeft(System.Boolean)</Target>
<Left>lib/net7.0/Umbraco.Core.dll</Left>
<Right>lib/net7.0/Umbraco.Core.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Umbraco.Cms.Core.Models.Blocks.BlockGridItem.set_ForceRight(System.Boolean)</Target>
<Left>lib/net7.0/Umbraco.Core.dll</Left>
<Right>lib/net7.0/Umbraco.Core.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>M:Umbraco.Cms.Core.Deploy.IDataTypeConfigurationConnector.FromArtifact(Umbraco.Cms.Core.Models.IDataType,System.String,Umbraco.Cms.Core.Deploy.IContextCache)</Target>
Expand Down
6 changes: 3 additions & 3 deletions src/Umbraco.Core/Configuration/ContentSettingsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public static class ContentSettingsExtensions
/// Allow upload if extension is whitelisted OR if there is no whitelist and extension is NOT blacklisted.
/// </summary>
public static bool IsFileAllowedForUpload(this ContentSettings contentSettings, string extension) =>
contentSettings.AllowedUploadFiles.Any(x => x.InvariantEquals(extension)) ||
(contentSettings.AllowedUploadFiles.Any() == false &&
contentSettings.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension)) == false);
contentSettings.AllowedUploadedFileExtensions.Any(x => x.InvariantEquals(extension)) ||
(contentSettings.AllowedUploadedFileExtensions.Any() == false &&
contentSettings.DisallowedUploadedFileExtensions.Any(x => x.InvariantEquals(extension)) == false);

/// <summary>
/// Gets the auto-fill configuration for a specified property alias.
Expand Down
13 changes: 13 additions & 0 deletions src/Umbraco.Core/Configuration/Models/ContentSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,13 @@ @keyframes umbraco-preview-badge--effect {{
/// Gets or sets a value for the collection of file extensions that are disallowed for upload.
/// </summary>
[DefaultValue(StaticDisallowedUploadFiles)]
[Obsolete("Please use DisAllowedUploadedFileExtensions instead, scheduled for removal in V13")]
public IEnumerable<string> DisallowedUploadFiles { get; set; } = StaticDisallowedUploadFiles.Split(',');

/// <summary>
/// Gets or sets a value for the collection of file extensions that are allowed for upload.
/// </summary>
[Obsolete("Please use AllowedUploadedFileExtensions instead, scheduled for removal in V13")]
public IEnumerable<string> AllowedUploadFiles { get; set; } = Array.Empty<string>();

/// <summary>
Expand Down Expand Up @@ -249,4 +251,15 @@ @keyframes umbraco-preview-badge--effect {{
/// </summary>
[DefaultValue(StaticAllowEditInvariantFromNonDefault)]
public bool AllowEditInvariantFromNonDefault { get; set; } = StaticAllowEditInvariantFromNonDefault;

/// <summary>
/// Gets or sets a value for the collection of file extensions that are allowed for upload.
/// </summary>
public string[] AllowedUploadedFileExtensions { get; set; } = Array.Empty<string>();

/// <summary>
/// Gets or sets a value for the collection of file extensions that are disallowed for upload.
/// </summary>
[DefaultValue(StaticDisallowedUploadFiles)]
public string[] DisallowedUploadedFileExtensions { get; set; } = StaticDisallowedUploadFiles.Split(',');
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,32 @@ public static IUmbracoBuilder AddConfiguration(this IUmbracoBuilder builder)
}
});

// TODO: Remove this in V13
// This is to avoid a breaking change in ContentSettings, if the old AllowedFileUploads has a value, and the new
// AllowedFileUploadExtensions does not, copy the value over, if the new has a value, use that instead.
builder.Services.Configure<ContentSettings>(settings =>
{
// We have to use Config.GetSection().Get<string[]>, as the GetSection.GetValue<string[]> simply cannot retrieve a string array
var allowedUploadedFileExtensionsValue = builder.Config.GetSection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.AllowedUploadedFileExtensions)}").Get<string[]>();
var allowedUploadFilesValue = builder.Config.GetSection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.AllowedUploadFiles)}").Get<string[]>();

if (allowedUploadedFileExtensionsValue is null && allowedUploadFilesValue is not null)
{
settings.AllowedUploadedFileExtensions = allowedUploadFilesValue;
}
});

// TODO: Remove this in V13
builder.Services.Configure<ContentSettings>(settings =>
{
var disallowedUploadedFileExtensionsValue = builder.Config.GetSection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.DisallowedUploadedFileExtensions)}").Get<string[]>();
var disallowedUploadFilesValue = builder.Config.GetSection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.DisallowedUploadFiles)}").Get<string[]>();

if (disallowedUploadedFileExtensionsValue is null && disallowedUploadFilesValue is not null)
{
settings.DisallowedUploadedFileExtensions = disallowedUploadFilesValue;
}
});
return builder;
}
}
28 changes: 28 additions & 0 deletions src/Umbraco.Infrastructure/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Umbraco.Cms.Core.Models.Blocks.BlockGridLayoutItem.get_ForceLeft</Target>
<Left>lib/net7.0/Umbraco.Infrastructure.dll</Left>
<Right>lib/net7.0/Umbraco.Infrastructure.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Umbraco.Cms.Core.Models.Blocks.BlockGridLayoutItem.get_ForceRight</Target>
<Left>lib/net7.0/Umbraco.Infrastructure.dll</Left>
<Right>lib/net7.0/Umbraco.Infrastructure.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Umbraco.Cms.Core.Models.Blocks.BlockGridLayoutItem.set_ForceLeft(System.Boolean)</Target>
<Left>lib/net7.0/Umbraco.Infrastructure.dll</Left>
<Right>lib/net7.0/Umbraco.Infrastructure.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Umbraco.Cms.Core.Models.Blocks.BlockGridLayoutItem.set_ForceRight(System.Boolean)</Target>
<Left>lib/net7.0/Umbraco.Infrastructure.dll</Left>
<Right>lib/net7.0/Umbraco.Infrastructure.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>M:Umbraco.Cms.Core.Deploy.IGridCellValueConnector.GetValue(Umbraco.Cms.Core.Models.GridValue.GridControl,System.Collections.Generic.ICollection{Umbraco.Cms.Core.Deploy.ArtifactDependency},Umbraco.Cms.Core.Deploy.IContextCache)</Target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,11 +543,11 @@ internal async Task<Dictionary<string, object>> GetServerVariablesAsync()
},
{
"disallowedUploadFiles",
string.Join(",", _contentSettings.DisallowedUploadFiles)
string.Join(",", _contentSettings.DisallowedUploadedFileExtensions)
},
{
"allowedUploadFiles",
string.Join(",", _contentSettings.AllowedUploadFiles)
string.Join(",", _contentSettings.AllowedUploadedFileExtensions)
},
{
"maxFileSize",
Expand Down
14 changes: 7 additions & 7 deletions tests/Umbraco.Tests.AcceptanceTest/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/Umbraco.Tests.AcceptanceTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"dependencies": {
"@umbraco/json-models-builders": "^1.0.2",
"@umbraco/playwright-testhelpers": "^1.0.12",
"@umbraco/playwright-testhelpers": "^1.0.18",
"camelize": "^1.0.0",
"faker": "^4.1.0",
"form-data": "^4.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ test.describe('BlockListEditorContent', () => {
// Won't work if I use the to alias for the elementAlias
const elementAlias = 'testElement';

test.beforeEach(async ({page, umbracoApi, umbracoUi}) => {
test.beforeEach(async ({page, umbracoApi, umbracoUi}, testInfo) => {
await umbracoApi.report.report(testInfo);
await umbracoApi.login();
await umbracoApi.documentTypes.ensureNameNotExists(documentName);
await umbracoApi.documentTypes.ensureNameNotExists(elementName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ test.describe('BlockListEditorDataType', () => {

const elementAlias = AliasHelper.toAlias(elementName);

test.beforeEach(async ({page, umbracoApi, umbracoUi}) => {
test.beforeEach(async ({page, umbracoApi, umbracoUi}, testInfo) => {
await umbracoApi.report.report(testInfo);
await umbracoApi.login();
await umbracoApi.documentTypes.ensureNameNotExists(documentName);
await umbracoApi.dataTypes.ensureNameNotExists(blockListName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ test.describe('BlockListEditorDocument', () => {
const blockListAlias = AliasHelper.toAlias(blockListName);
const elementAlias = AliasHelper.toAlias(elementName);

test.beforeEach(async ({page, umbracoApi, umbracoUi}) => {
test.beforeEach(async ({page, umbracoApi, umbracoUi}, testInfo) => {
await umbracoApi.report.report(testInfo);
await umbracoApi.login();
await umbracoApi.documentTypes.ensureNameNotExists(documentName);
await umbracoApi.dataTypes.ensureNameNotExists(blockListName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { expect } from "@playwright/test";

test.describe('Umbraco Logo Information', () => {

test.beforeEach(async ({ page, umbracoApi }) => {
// TODO: REMOVE THIS WHEN SQLITE IS FIXED
// Wait so we don't bombard the API
await page.waitForTimeout(1000);
test.beforeEach(async ({ page, umbracoApi }, testInfo) => {
await umbracoApi.report.report(testInfo);
await umbracoApi.login();
});

Expand Down
Loading