Merge release/10.0.0 into v10/dev

commit e0aa430d4c
Author: Paul Johnson <pmj@umbraco.com>
Date:   Thu May 19 10:00:57 2022 +0100

    Fix typo in pipeline yaml

commit 2ec450f2d6
Author: Paul Johnson <pmj@umbraco.com>
Date:   Thu May 19 09:14:47 2022 +0100

    Fix yaml conditions

commit c2d548039a
Author: Paul Johnson <pmj@umbraco.com>
Date:   Thu May 19 09:02:50 2022 +0100

    Azure pipeline refactor (#12428)

    * Skip symbols for Umbraco.Templates

    * Resolve some test issues

    + Fixed whitespace dependant tests to pass regardless of build OS vs
    run OS.

    + Snap dictionary tests were failing when Configuration was release

    + Removed hardcoded baseUrl from one of the acceptance tests

    * Move docfx setup to ./build and fix

    * Update UI docs title

    * Added dockerfile that can be used when running the acceptance tests.

    * Take explicit dependency on System.Security.Cryptography.Pkcs

    * Refactor ci/cd pipeline

commit ee8359af75
Author: Mole <nikolajlauridsen@protonmail.ch>
Date:   Thu May 19 09:57:21 2022 +0200

    V10: Reintroduce appsettings-schema.json (#12416)

    * Reintroduce language files tests (#12367)

    * Reintroducing language files tests

    * Fix casing

    * Update tests/Umbraco.Tests.UnitTests/Umbraco.Core/EmbeddedResources/LanguageXmlTests.cs

    Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

    * Change Umbraco.Cms and Umbraco.Templates nuspecs to csproj

    * Remove Umbraco.Templates from VerifyNuGet step

    * Remove duplicate and unnecessary properties

    * Generate json schema on build

    * Add targets file

    * Gitignore auto generated appsettings schema

    * Fix build not copying file

    * Use the new path in appsettings

    * Update copy message

    * Build json schema as release

    * Update json schema options

    Otherwise just running the project will put the file in the wrong place

    * Generate schema if it doesn't exist in Web.Ui

    * Update json schema options

    Otherwise just running the project will put the file in the wrong place

    Co-authored-by: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>
    Co-authored-by: Ronald Barendse <ronald@barend.se>

commit dd617ede80
Author: Ronald Barendse <ronald@barend.se>
Date:   Thu May 19 09:51:11 2022 +0200

    v10: Change Umbraco.Cms and Umbraco.Templates nuspecs to csproj (#12413)

    * Reintroduce language files tests (#12367)

    * Reintroducing language files tests

    * Fix casing

    * Update tests/Umbraco.Tests.UnitTests/Umbraco.Core/EmbeddedResources/LanguageXmlTests.cs

    Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

    * Change Umbraco.Cms and Umbraco.Templates nuspecs to csproj

    * Remove Umbraco.Templates from VerifyNuGet step

    * Remove duplicate and unnecessary properties

    Co-authored-by: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>
    Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

commit b83216876f
Author: Ronald Barendse <ronald@barend.se>
Date:   Thu May 19 08:36:04 2022 +0200

    v10: Project template database/connection string improvements (#12407)

    * Add new connection-string-provider-name parameter

    * Use template value forms to correctly encode JSON values

    * Add new development-database-type parameter

    * Update package template and fix App_Plugins directory rename

    * Remove conflicting short parameter name

    * Lowercase framework parameter to align with MS templates

    * Cleanup default template settings

    * Write unattended install parameters when either connection string or development database is set

    * Include RootNamespace in UmbracoPackage template

    * Update Umbraco specific gitignore rules

    * Revert "Lowercase framework parameter to align with MS templates"

    This reverts commit 22de389272a7e119df569ec2e54190265f6d0ae0.

    * Add exclude-gitignore parameter

    * Update template schemas

    * Add minimal-gitignore parameter

commit e40049dcf1
Author: Mole <nikolajlauridsen@protonmail.ch>
Date:   Wed May 18 15:22:51 2022 +0200

    Fix domain for invariant content nodes (#12405)

    Co-authored-by: Elitsa Marinovska <elm@umbraco.dk>

commit a3692b887a
Author: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>
Date:   Mon May 9 11:42:10 2022 +0200

    Use SnippetCollection to when working with snippets  (#12355)

    * Introducing a new Snippet type

    * Adding a SnippetCollection and SnippetCollectionBuilder

    * Using snippetCollection to get the snippets instead of fileService

    * Fixed fetching the correct content

    * Make ISnippet non-discoverable

    * Split the SnippetCollection into PartialViewSnippetCollection and PartialViewMacroSnippetCollection

    * Update CodeFileController to use the 2 snippet collections

    * Display the names with Empty.cshtml on top

    * Remove merging embedded snippets with custom snippets from ~\Umbraco.Web.UI\umbraco\PartialViewMacros\Templates folder for the Partial View Collection

    * Fix naming

    * Fix another naming

    * Cleanup + Use base items

    Co-authored-by: Bjarke Berg <mail@bergmania.dk>
    (cherry picked from commit 9326cc5fc6)

commit 4f48a4937b
Author: patrickdemooij9 <patrickdemooij98@hotmail.com>
Date:   Fri Oct 8 11:18:00 2021 +0200

    Cherry picked from 4c08b44684

commit 4fdbfee597
Author: Bjarne Fyrstenborg <bjarne_fyrstenborg@hotmail.com>
Date:   Wed May 11 00:51:37 2022 +0200

    Show nicer overlay when clicking block card for deleted element type (#12140)

    * Show nicer overlay when clicking block card for deleted element type

    * Cleanup

    * Remove stop-scrolling container

    * Use flex-start instead on start

    * Remove legacy flexbox fallback

    * Remove unnecessary hack

    * Use standard gap property instead

    * Localization of message

    * Fix translation

    * End sentence with a dot

    (cherry picked from commit ebb1dc21a9)

commit 3856bf8288
Author: Henk Jan Pluim <henkjan.pluim@greenchoice.nl>
Date:   Mon Apr 25 10:02:06 2022 +0200

    #fix 12254 return emptyresult

    (cherry picked from commit 7993d19c1b)

commit 7087c3d9f6
Author: Ronald Barendse <ronald@barend.se>
Date:   Tue May 17 12:59:01 2022 +0200

    v10: Use ForceCreateDatabase during unattended install and extend GetUmbracoConnectionString extension methods (#12397)

    * Add extension methods to get the Umbraco connection string/provider name from configuration

    * Added tests for configuration extension methods.

    * Fix issue with InstallMissingDatabase and ForceCreateDatabase

    * Fix comments

    * Revert casing change in GenerateConnectionString

    * Re-add AddOptions (without config binding) to fix test

    * Update src/Umbraco.Core/Configuration/Models/ConnectionStrings.cs

    Co-authored-by: Ronald Barendse <ronald@barend.se>

    * Update src/Umbraco.Core/Configuration/Models/ConnectionStrings.cs

    * Update src/Umbraco.Infrastructure/Runtime/RuntimeState.cs

    * Whitespace and documentation updates

    * Add DatabaseProviderMetadataExtensions

    * Filter before ordering

    * Replace DataDirectory placeholder when setting connection string

    Co-authored-by: Andy Butland <abutland73@gmail.com>
    Co-authored-by: Bjarke Berg <mail@bergmania.dk>
    (cherry picked from commit 8e6e262c7f)

commit e90bf26577
Author: Ronald Barendse <ronald@barend.se>
Date:   Tue May 17 07:33:54 2022 +0200

    v10: Support System.Data.SqlClient provider name (#12408)

    * Add support for System.Data.SqlClient provider name

    * Only update connection string when required

    (cherry picked from commit e82bcb1b76)

commit fd0637c96d
Author: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>
Date:   Mon May 16 14:23:59 2022 +0200

    Reintroduce language files tests (#12367)

    * Reintroducing language files tests

    * Fix casing

    * Update tests/Umbraco.Tests.UnitTests/Umbraco.Core/EmbeddedResources/LanguageXmlTests.cs

    Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>
    (cherry picked from commit 2ed71a64ec)
This commit is contained in:
Paul Johnson
2022-05-19 10:25:44 +01:00
parent 8d8592092f
commit 01d2d0326c
69 changed files with 1248 additions and 1567 deletions

View File

@@ -13,6 +13,7 @@ using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.PropertyEditors.Validators;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Sections;
using Umbraco.Cms.Core.Snippets;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Core.Tour;
using Umbraco.Cms.Core.Trees;
@@ -90,6 +91,8 @@ namespace Umbraco.Cms.Core.DependencyInjection
.Add<RedirectUrlDashboard>()
.Add<SettingsDashboard>()
.Add(builder.TypeLoader.GetTypes<IDashboard>());
builder.PartialViewSnippets();
builder.PartialViewMacroSnippets();
builder.DataValueReferenceFactories();
builder.PropertyValueConverters().Append(builder.TypeLoader.GetTypes<IPropertyValueConverter>());
builder.UrlSegmentProviders().Append<DefaultUrlSegmentProvider>();
@@ -200,6 +203,20 @@ namespace Umbraco.Cms.Core.DependencyInjection
public static DashboardCollectionBuilder Dashboards(this IUmbracoBuilder builder)
=> builder.WithCollectionBuilder<DashboardCollectionBuilder>();
/// <summary>
/// Gets the partial view snippets collection builder.
/// </summary>
/// <param name="builder">The builder.</param>
public static PartialViewSnippetCollectionBuilder? PartialViewSnippets(this IUmbracoBuilder builder)
=> builder.WithCollectionBuilder<PartialViewSnippetCollectionBuilder>();
/// <summary>
/// Gets the partial view macro snippets collection builder.
/// </summary>
/// <param name="builder">The builder.</param>
public static PartialViewMacroSnippetCollectionBuilder? PartialViewMacroSnippets(this IUmbracoBuilder builder)
=> builder.WithCollectionBuilder<PartialViewMacroSnippetCollectionBuilder>();
/// <summary>
/// Gets the cache refreshers collection builder.
/// </summary>

View File

@@ -35,6 +35,7 @@ using Umbraco.Cms.Core.Runtime;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Snippets;
using Umbraco.Cms.Core.Sync;
using Umbraco.Cms.Core.Telemetry;
using Umbraco.Cms.Core.Templates;

View File

@@ -2181,18 +2181,19 @@ Mange hilsner fra Umbraco robotten
være muligt. Indholdet vil blive vist som ikke understøttet indhold.
</key>
<key alias="blockConfigurationOverlayTitle"><![CDATA[Konfiguration af '%0%']]></key>
<key alias="elementTypeDoesNotExist">Kan ikke redigeres fordi elementtypen ikke eksisterer.</key>
<key alias="thumbnail">Billede</key>
<key alias="addThumbnail">Tilføj billede</key>
<key alias="tabCreateEmpty">Opret ny</key>
<key alias="tabClipboard">Udklipsholder</key>
<key alias="tabBlockSettings">Indstillinger</key>
<key alias="headlineAdvanced">Avanceret</key>
<key alias="forceHideContentEditor">Skjuld indholds editoren</key>
<key alias="forceHideContentEditor">Skjul indholdseditoren</key>
<key alias="blockHasChanges">Du har lavet ændringer til dette indhold. Er du sikker på at du vil kassere dem?</key>
<key alias="confirmCancelBlockCreationHeadline">Annuller oprettelse?</key>
<key alias="confirmCancelBlockCreationMessage"><![CDATA[Er du sikker på at du vil annullere oprettelsen.]]></key>
<key alias="elementTypeDoesNotExistHeadline">Error!</key>
<key alias="elementTypeDoesNotExistDescription">The ElementType of this block does not exist anymore</key>
<key alias="elementTypeDoesNotExistHeadline">Fejl!</key>
<key alias="elementTypeDoesNotExistDescription">Elementtypen for denne blok eksisterer ikke længere</key>
<key alias="addBlock">Tilføj indhold</key>
<key alias="addThis">Tilføj %0%</key>
<key alias="propertyEditorNotSupported">Feltet %0% bruger editor %1% som ikke er supporteret for blokke.</key>

View File

@@ -2714,6 +2714,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
will no longer be available and will be shown as unsupported content.
</key>
<key alias="blockConfigurationOverlayTitle"><![CDATA[Configuration of '%0%']]></key>
<key alias="elementTypeDoesNotExist">Cannot be edited cause ElementType does not exist.</key>
<key alias="thumbnail">Thumbnail</key>
<key alias="addThumbnail">Add thumbnail</key>
<key alias="tabCreateEmpty">Create empty</key>

View File

@@ -2802,6 +2802,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
will no longer be available and will be shown as unsupported content.
</key>
<key alias="blockConfigurationOverlayTitle"><![CDATA[Configuration of '%0%']]></key>
<key alias="elementTypeDoesNotExist">Cannot be edited cause ElementType does not exist.</key>
<key alias="thumbnail">Thumbnail</key>
<key alias="addThumbnail">Add thumbnail</key>
<key alias="tabCreateEmpty">Create empty</key>

View File

@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.IO;
using Umbraco.Cms.Core.Models;
namespace Umbraco.Cms.Core.Services
@@ -10,6 +7,7 @@ namespace Umbraco.Cms.Core.Services
/// </summary>
public interface IFileService : IService
{
[Obsolete("Please use SnippetCollection.GetPartialViewSnippetNames() or SnippetCollection.GetPartialViewMacroSnippetNames() instead. Scheduled for removal in V12.")]
IEnumerable<string> GetPartialViewSnippetNames(params string[] filterNames);
void CreatePartialViewFolder(string folderPath);
void CreatePartialViewMacroFolder(string folderPath);
@@ -295,6 +293,7 @@ namespace Umbraco.Cms.Core.Services
/// </summary>
/// <param name="snippetName">The name of the snippet</param>
/// <returns></returns>
[Obsolete("Please use SnippetCollection.GetPartialViewMacroSnippetContent instead. Scheduled for removal in V12.")]
string GetPartialViewMacroSnippetContent(string snippetName);
/// <summary>
@@ -302,6 +301,7 @@ namespace Umbraco.Cms.Core.Services
/// </summary>
/// <param name="snippetName">The name of the snippet</param>
/// <returns>The content of the partial view.</returns>
[Obsolete("Please use SnippetCollection.GetPartialViewSnippetContent instead. Scheduled for removal in V12.")]
string GetPartialViewSnippetContent(string snippetName);
}
}

View File

@@ -0,0 +1,18 @@
namespace Umbraco.Cms.Core.Snippets
{
/// <summary>
/// Defines a partial view macro snippet.
/// </summary>
public interface ISnippet
{
/// <summary>
/// Gets the name of the snippet.
/// </summary>
string Name { get; }
/// <summary>
/// Gets the content of the snippet.
/// </summary>
string Content { get; }
}
}

View File

@@ -0,0 +1,66 @@
using System.Text.RegularExpressions;
using Umbraco.Cms.Core.Composing;
using Umbraco.Extensions;
namespace Umbraco.Cms.Core.Snippets
{
/// <summary>
/// The collection of partial view macro snippets.
/// </summary>
public class PartialViewMacroSnippetCollection : BuilderCollectionBase<ISnippet>
{
public PartialViewMacroSnippetCollection(Func<IEnumerable<ISnippet>> items) : base(items)
{
}
/// <summary>
/// Gets the partial view macro snippet names.
/// </summary>
/// <returns>The names of all partial view macro snippets.</returns>
public IEnumerable<string> GetNames()
{
var snippetNames = this.Select(x => Path.GetFileNameWithoutExtension(x.Name)).ToArray();
// Ensure the ones that are called 'Empty' are at the top
var empty = snippetNames.Where(x => Path.GetFileName(x)?.InvariantStartsWith("Empty") ?? false)
.OrderBy(x => x?.Length).ToArray();
return empty.Union(snippetNames.Except(empty)).WhereNotNull();
}
/// <summary>
/// Gets the content of a partial view macro snippet as a string.
/// </summary>
/// <param name="snippetName">The name of the snippet.</param>
/// <returns>The content of the partial view macro.</returns>
public string GetContentFromName(string snippetName)
{
if (snippetName.IsNullOrWhiteSpace())
{
throw new ArgumentNullException(nameof(snippetName));
}
string partialViewMacroHeader = "@inherits Umbraco.Cms.Web.Common.Macros.PartialViewMacroPage";
var snippet = this.Where(x => x.Name.Equals(snippetName + ".cshtml")).FirstOrDefault();
// Try and get the snippet path
if (snippet is null)
{
throw new InvalidOperationException("Could not load snippet with name " + snippetName);
}
// Strip the @inherits if it's there
var snippetContent = StripPartialViewHeader(snippet.Content);
var content = $"{partialViewMacroHeader}{Environment.NewLine}{snippetContent}";
return content;
}
private string StripPartialViewHeader(string contents)
{
var headerMatch = new Regex("^@inherits\\s+?.*$", RegexOptions.Multiline);
return headerMatch.Replace(contents, string.Empty);
}
}
}

View File

@@ -0,0 +1,56 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Extensions;
namespace Umbraco.Cms.Core.Snippets
{
/// <summary>
/// The partial view macro snippet collection builder.
/// </summary>
public class PartialViewMacroSnippetCollectionBuilder : LazyCollectionBuilderBase<PartialViewMacroSnippetCollectionBuilder, PartialViewMacroSnippetCollection, ISnippet>
{
protected override PartialViewMacroSnippetCollectionBuilder This => this;
protected override IEnumerable<ISnippet> CreateItems(IServiceProvider factory)
{
var hostEnvironment = factory.GetRequiredService<IHostEnvironment>();
var embeddedSnippets = new List<ISnippet>(base.CreateItems(factory));
var snippetProvider = new EmbeddedFileProvider(typeof(IAssemblyProvider).Assembly, "Umbraco.Cms.Core.EmbeddedResources.Snippets");
var embeddedFiles = snippetProvider.GetDirectoryContents(string.Empty)
.Where(x => !x.IsDirectory && x.Name.EndsWith(".cshtml"));
foreach (var file in embeddedFiles)
{
using var stream = new StreamReader(file.CreateReadStream());
embeddedSnippets.Add(new Snippet(file.Name, stream.ReadToEnd().Trim()));
}
var customSnippetsDir = new DirectoryInfo(hostEnvironment.MapPathContentRoot($"{Constants.SystemDirectories.Umbraco}/PartialViewMacros/Templates"));
if (!customSnippetsDir.Exists)
{
return embeddedSnippets;
}
var customSnippets = customSnippetsDir.GetFiles().Select(f => new Snippet(f.Name, File.ReadAllText(f.FullName)));
var allSnippets = Merge(embeddedSnippets, customSnippets);
return allSnippets;
}
private IEnumerable<ISnippet> Merge(IEnumerable<ISnippet> embeddedSnippets, IEnumerable<ISnippet> customSnippets)
{
var allSnippets = embeddedSnippets.Concat(customSnippets);
var duplicates = allSnippets.GroupBy(s => s.Name)
.Where(gr => gr.Count() > 1) // Finds the snippets with the same name
.Select(s => s.First()); // Takes the first element from a grouping, which is the embeded snippet with that same name,
// since the physical snippet files are placed after the embedded ones in the all snippets colleciton
// Remove any embedded snippets if a physical file with the same name can be found
return allSnippets.Except(duplicates);
}
}
}

View File

@@ -0,0 +1,70 @@
using System.Text.RegularExpressions;
using Umbraco.Cms.Core.Composing;
using Umbraco.Extensions;
namespace Umbraco.Cms.Core.Snippets
{
/// <summary>
/// The collection of partial view snippets.
/// </summary>
public class PartialViewSnippetCollection : BuilderCollectionBase<ISnippet>
{
public PartialViewSnippetCollection(Func<IEnumerable<ISnippet>> items) : base(items)
{
}
/// <summary>
/// Gets the partial view snippet names.
/// </summary>
/// <returns>The names of all partial view snippets.</returns>
public IEnumerable<string> GetNames()
{
var snippetNames = this.Select(x => Path.GetFileNameWithoutExtension(x.Name)).ToArray();
// Ensure the ones that are called 'Empty' are at the top
var empty = snippetNames.Where(x => Path.GetFileName(x)?.InvariantStartsWith("Empty") ?? false)
.OrderBy(x => x?.Length).ToArray();
return empty.Union(snippetNames.Except(empty)).WhereNotNull();
}
/// <summary>
/// Gets the content of a partial view snippet as a string.
/// </summary>
/// <param name="snippetName">The name of the snippet.</param>
/// <returns>The content of the partial view.</returns>
public string GetContentFromName(string snippetName)
{
if (snippetName.IsNullOrWhiteSpace())
{
throw new ArgumentNullException(nameof(snippetName));
}
string partialViewHeader = "@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage";
var snippet = this.Where(x => x.Name.Equals(snippetName + ".cshtml")).FirstOrDefault();
// Try and get the snippet path
if (snippet is null)
{
throw new InvalidOperationException("Could not load snippet with name " + snippetName);
}
var snippetContent = CleanUpContents(snippet.Content);
var content = $"{partialViewHeader}{Environment.NewLine}{snippetContent}";
return content;
}
private string CleanUpContents(string content)
{
// Strip the @inherits if it's there
var headerMatch = new Regex("^@inherits\\s+?.*$", RegexOptions.Multiline);
var newContent = headerMatch.Replace(content, string.Empty);
return newContent
.Replace("Model.Content.", "Model.")
.Replace("(Model.Content)", "(Model)");
}
}
}

View File

@@ -0,0 +1,42 @@
using Microsoft.Extensions.FileProviders;
using Umbraco.Cms.Core.Composing;
namespace Umbraco.Cms.Core.Snippets
{
/// <summary>
/// The partial view snippet collection builder.
/// </summary>
public class PartialViewSnippetCollectionBuilder : LazyCollectionBuilderBase<PartialViewSnippetCollectionBuilder, PartialViewSnippetCollection, ISnippet>
{
protected override PartialViewSnippetCollectionBuilder This => this;
protected override IEnumerable<ISnippet> CreateItems(IServiceProvider factory)
{
var embeddedSnippets = new List<ISnippet>(base.CreateItems(factory));
// Ignore these
var filterNames = new List<string>
{
"Gallery",
"ListChildPagesFromChangeableSource",
"ListChildPagesOrderedByProperty",
"ListImagesFromMediaFolder"
};
var snippetProvider = new EmbeddedFileProvider(typeof(IAssemblyProvider).Assembly, "Umbraco.Cms.Core.EmbeddedResources.Snippets");
var embeddedFiles = snippetProvider.GetDirectoryContents(string.Empty)
.Where(x => !x.IsDirectory && x.Name.EndsWith(".cshtml"));
foreach (var file in embeddedFiles)
{
if (!filterNames.Contains(Path.GetFileNameWithoutExtension(file.Name)))
{
using var stream = new StreamReader(file.CreateReadStream());
embeddedSnippets.Add(new Snippet(file.Name, stream.ReadToEnd().Trim()));
}
}
return embeddedSnippets;
}
}
}

View File

@@ -0,0 +1,14 @@
namespace Umbraco.Cms.Core.Snippets
{
public class Snippet : ISnippet
{
public string Name { get; }
public string Content { get; }
public Snippet(string name, string content)
{
Name = name;
Content = content;
}
}
}