Merge remote-tracking branch 'origin/v11/dev' into v12/dev

This commit is contained in:
Nikolaj
2022-12-15 09:56:28 +01:00
6 changed files with 66 additions and 7 deletions

View File

@@ -326,7 +326,7 @@ public class SqliteSyntaxProvider : SqlSyntaxProviderBase<SqliteSyntaxProvider>
{
IEnumerable<string> tables = GetTablesInSchema(db);
db.OpenSharedConnection();
db.BeginTransaction();
foreach (var table in tables)
{
DbCommand? cmd = db.CreateCommand(db.Connection, CommandType.Text, $"PRAGMA table_info({table})");
@@ -341,6 +341,8 @@ public class SqliteSyntaxProvider : SqlSyntaxProviderBase<SqliteSyntaxProvider>
yield return new ColumnInfo(table, columnName, ordinal, notNull, type);
}
}
db.CompleteTransaction();
}
/// <inheritdoc />

View File

@@ -8,6 +8,7 @@ using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Xml;
using Microsoft.Extensions.Primitives;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Collections;
@@ -189,9 +190,10 @@ public static class ObjectExtensions
else
{
// target is not a generic type
if (input is string inputString)
var inputString = input as string ?? (input is StringValues sv ? sv.ToString() : null);
if (inputString != null)
{
// Try convert from string, returns an Attempt if the string could be
// Try convert from string or StringValues, returns an Attempt if the string could be
// processed (either succeeded or failed), else null if we need to try
// other methods
Attempt<object?>? result = TryConvertToFromString(inputString, target);

View File

@@ -133,7 +133,7 @@ public class PackagingService : IPackagingService
var currentPlans = installedPackage.PackageMigrationPlans.ToList();
if (keyValues is null || keyValues.TryGetValue(
Constants.Conventions.Migrations.KeyValuePrefix + plan.Name,
out var currentState))
out var currentState) is false)
{
currentState = null;
}

View File

@@ -136,7 +136,7 @@ public class ContentTreeController : ContentTreeControllerBase, ISearchableTreeW
var documentEntity = (IDocumentEntitySlim)entity;
if (!documentEntity.Variations.VariesByCulture())
if (!documentEntity.Variations.VariesByCulture() || culture.IsNullOrWhiteSpace())
{
if (!documentEntity.Published)
{

View File

@@ -41,8 +41,9 @@
function BlockConfigurationController($scope, $element, $http, elementTypeResource, overlayService, localizationService, editorService, eventsService, udiService, dataTypeResource, umbRequestHelper) {
var unsubscribe = [];
const vm = this;
vm.openBlock = null;
vm.showSampleDataCTA = false;
@@ -56,6 +57,7 @@
if (blockGroupModel.value == null) {
blockGroupModel.value = [];
}
vm.blockGroups = blockGroupModel.value;
if (!$scope.model.value) {
@@ -87,6 +89,7 @@
}
}
}
unsubscribe.push(eventsService.on("editors.documentType.saved", updateUsedElementTypes));
function removeReferencesToElementTypeKey(contentElementTypeKey) {
@@ -264,7 +267,7 @@
vm.openBlockOverlay = function (block, openAreas) {
var elementType = vm.getElementTypeByKey(block.contentElementTypeKey);
if (elementType) {
localizationService.localize("blockEditor_blockConfigurationOverlayTitle", [elementType.name]).then(function (data) {
@@ -356,6 +359,7 @@
});
}
}
dataTypeResource.getAll().then(function(dataTypes) {
if (dataTypes.filter(x => x.alias === "Umbraco.BlockGrid").length === 0) {
vm.showSampleDataCTA = true;

View File

@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using Microsoft.Extensions.Primitives;
using NUnit.Framework;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Tests.Common.TestHelpers;
@@ -281,6 +282,56 @@ public class ObjectExtensionsTests
Assert.AreEqual(new DateTime(2016, 6, 7), conv.Result);
}
[TestCase("d72f12a9-29db-42b4-9ffb-25a3ba4dcef5")]
[TestCase("D72F12A9-29DB-42B4-9FFB-25A3BA4DCEF5")]
public void CanConvertToGuid(string guidValue)
{
var conv = guidValue.TryConvertTo<Guid>();
Assert.IsTrue(conv);
Assert.AreEqual(Guid.Parse(guidValue), conv.Result);
}
[TestCase("d72f12a9-29db-42b4-9ffb-25a3ba4dcef5")]
[TestCase("D72F12A9-29DB-42B4-9FFB-25A3BA4DCEF5")]
public void CanConvertToNullableGuid(string guidValue)
{
var conv = guidValue.TryConvertTo<Guid?>();
Assert.IsTrue(conv);
Assert.AreEqual(Guid.Parse(guidValue), conv.Result);
}
[TestCase("d72f12a9-29db-42b4-9ffb-25a3ba4dcef5")]
[TestCase("D72F12A9-29DB-42B4-9FFB-25A3BA4DCEF5")]
public void CanConvertStringValuesToNullableGuid(string guidValue)
{
StringValues stringValues = guidValue;
var conv = stringValues.TryConvertTo<Guid?>();
Assert.IsTrue(conv);
Assert.AreEqual(Guid.Parse(guidValue), conv.Result);
}
[TestCase(10)]
[TestCase(0)]
[TestCase(-10)]
[TestCase(int.MinValue)]
[TestCase(int.MaxValue)]
public void CanConvertStringValuesToInt(int intValue)
{
StringValues stringValues = intValue.ToString();
var conv = stringValues.TryConvertTo<int>();
Assert.IsTrue(conv);
Assert.AreEqual(intValue, conv.Result);
}
[Test]
public void CanConvertStringValuesToString()
{
StringValues stringValues = "This is a string";
var conv = stringValues.TryConvertTo<string>();
Assert.IsTrue(conv);
Assert.AreEqual("This is a string", conv.Result);
}
[Test]
public void Value_Editor_Can_Convert_Decimal_To_Decimal_Clr_Type()
{