Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7777ba4
Fix broken selectable state for list view items (#13148)
kjac Oct 10, 2022
b8c73e7
Add sync rendering extensions for block grid and async ones for block…
kjac Oct 12, 2022
d13a557
Re-add IsPackable to Umbraco.Tests.Integration
nikolajlauridsen Oct 12, 2022
4a412bb
Fix for potential race condition in packages search (#13153)
iOvergaard Oct 12, 2022
6e7ecd0
Fix for potential race condition in packages search (#13153)
iOvergaard Oct 12, 2022
29ae87e
V10: Fix request accessor memory leak (#13152)
nikolajlauridsen Oct 13, 2022
9f6d5e9
Add missing ForceLeft and ForceRight (#13190)
nikolajlauridsen Oct 13, 2022
0b3a06f
V10: Fix request accessor memory leak (#13152)
nikolajlauridsen Oct 13, 2022
213dd71
Add missing ForceLeft and ForceRight (#13190)
nikolajlauridsen Oct 13, 2022
4ee8270
Merge remote-tracking branch 'origin/release/10.3' into release/10.3
Zeegaan Oct 13, 2022
63af4c4
Pass the node property to umb-property & umb-property-editor (#13151)
Zeegaan Oct 10, 2022
76b54c4
V10: 13099 fix validation error (#13170)
Zeegaan Oct 11, 2022
ab8d94b
move clear:both; to the flexbox example (#13194)
nielslyngsoe Oct 13, 2022
ff75fcd
remove pointer-events from Image, to make drag n' drop work on firefo…
nielslyngsoe Oct 13, 2022
a0931d2
area permission min-max inputs width increase (#13195)
nielslyngsoe Oct 13, 2022
cdc994d
Fix tags with CSV storage type (#13188)
elit0451 Oct 13, 2022
0fe2c22
Fix tags with CSV storage type (#13188)
elit0451 Oct 13, 2022
0a925fd
Add documentation for default block grid partial views in the renderi…
kjac Oct 13, 2022
2fa61fe
Add data-element to umb property so we can find it (#13199)
Zeegaan Oct 13, 2022
ed66fe1
Add data-element to umb property so we can find it (#13199)
Zeegaan Oct 13, 2022
41737a3
V10/bugfix/create simple package test (#13162)
andr317c Oct 13, 2022
e22c7ea
Merge BjarneF fix into 10.3 (#13220)
nielslyngsoe Oct 17, 2022
37424a6
make Area fit within block row (#13221)
nielslyngsoe Oct 17, 2022
8d8e4e0
10.3.0-RC: Change grid area input to number + change generic label (#…
matthew-darby Oct 17, 2022
96bf197
move below center, to make room (#13222)
nielslyngsoe Oct 17, 2022
2993f1b
highlight areas in dragging-mode for modern browsers (#13224)
nielslyngsoe Oct 18, 2022
733f0b8
Collect new .xml language files from different sources (#13212)
elit0451 Oct 18, 2022
5e96011
Collect new .xml language files from different sources (#13212)
elit0451 Oct 18, 2022
af468b6
Resync editors if content model changed (#13230)
nielslyngsoe Oct 18, 2022
4e9aa8d
Disable BlockGridEditor (#13229)
nikolajlauridsen Oct 18, 2022
75f628b
Merge branch 'release/10.3' into v10/dev
nikolajlauridsen Oct 18, 2022
629cc63
V10.4: Re-enable block grid editor (#13231)
nikolajlauridsen Oct 18, 2022
6d588f4
Merge remote-tracking branch 'origin/v10/dev' into v11/merge_v10
nikolajlauridsen Oct 19, 2022
bc3efd6
Fix nullable reference error
nikolajlauridsen Oct 19, 2022
ee8f890
Fix acceptance test package.json and package-lock.json
nikolajlauridsen Oct 19, 2022
56c43cf
Re-add wait-on
nikolajlauridsen Oct 19, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
justify-content: center;
width: 100%;
height: 100%;
min-height: 100%;
cursor: pointer;
color: black;
background-color: transparent;
Expand All @@ -35,7 +34,6 @@
color: #2152A3;// TODO: Set right colors:
}
img {
pointer-events: none;
object-fit: cover;
height: 100%;
width: 100%;
Expand Down
4 changes: 1 addition & 3 deletions src/Umbraco.Core/Models/Blocks/BlockGridItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Umbraco.Cms.Core.Models.Blocks
/// <summary>
/// Represents a layout item for the Block Grid editor.
/// </summary>
/// <seealso cref="Umbraco.Core.Models.Blocks.IBlockReference{Umbraco.Core.Models.PublishedContent.IPublishedElement,Umbraco.Core.Models.PublishedContent.IPublishedElement}" />
/// <seealso cref="IBlockReference{TContent,TSettings}" />
[DataContract(Name = "block", Namespace = "")]
public class BlockGridItem : IBlockReference<IPublishedElement, IPublishedElement>
{
Expand Down Expand Up @@ -116,7 +116,6 @@ public BlockGridItem(Udi contentUdi, IPublishedElement content, Udi settingsUdi,
/// Represents a layout item with a generic content type for the Block List editor.
/// </summary>
/// <typeparam name="T">The type of the content.</typeparam>
/// <seealso cref="Umbraco.Core.Models.Blocks.IBlockReference{Umbraco.Core.Models.PublishedContent.IPublishedElement}" />
public class BlockGridItem<T> : BlockGridItem
where T : IPublishedElement
{
Expand Down Expand Up @@ -149,7 +148,6 @@ public BlockGridItem(Udi contentUdi, T content, Udi settingsUdi, IPublishedEleme
/// </summary>
/// <typeparam name="TContent">The type of the content.</typeparam>
/// <typeparam name="TSettings">The type of the settings.</typeparam>
/// <seealso cref="Umbraco.Core.Models.Blocks.IBlockReference{Umbraco.Core.Models.PublishedContent.IPublishedElement}" />
public class BlockGridItem<TContent, TSettings> : BlockGridItem<TContent>
where TContent : IPublishedElement
where TSettings : IPublishedElement
Expand Down
23 changes: 16 additions & 7 deletions src/Umbraco.Core/Services/LocalizedTextServiceFileSources.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Globalization;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
using Microsoft.Extensions.FileProviders;
Expand Down Expand Up @@ -166,7 +167,7 @@ public LocalizedTextServiceFileSources(ILogger<LocalizedTextServiceFileSources>
}

/// <summary>
/// returns all xml sources for all culture files found in the folder
/// Returns all xml sources for all culture files found in the folder.
/// </summary>
/// <returns></returns>
public IDictionary<CultureInfo, Lazy<XDocument>> GetXmlSources() => _xmlSources.Value;
Expand All @@ -179,7 +180,15 @@ private IEnumerable<IFileInfo> GetLanguageFiles()
{
result.AddRange(
new PhysicalDirectoryContents(_fileSourceFolder.FullName)
.Where(x => !x.IsDirectory && x.Name.EndsWith(".xml")));
.Where(x => !x.IsDirectory && !x.Name.Contains("user") && x.Name.EndsWith(".xml"))); // Filter out *.user.xml
}

if (_supplementFileSources is not null)
{
// Get only the .xml files and filter out the user defined language files (*.user.xml) that overwrite the default
result.AddRange(_supplementFileSources
.Where(x => !x.FileInfo.Name.Contains("user") && x.FileInfo.Name.EndsWith(".xml"))
.Select(x => x.FileInfo));
}

if (_directoryContents.Exists)
Expand Down Expand Up @@ -236,8 +245,8 @@ private void MergeSupplementaryFiles(CultureInfo culture, XDocument xMasterDoc)
// now load in supplementary
IEnumerable<LocalizedTextServiceSupplementaryFileSource> found = _supplementFileSources.Where(x =>
{
var extension = Path.GetExtension(x.File.FullName);
var fileCultureName = Path.GetFileNameWithoutExtension(x.File.FullName).Replace("_", "-")
var extension = Path.GetExtension(x.FileInfo.Name);
var fileCultureName = Path.GetFileNameWithoutExtension(x.FileInfo.Name).Replace("_", "-")
.Replace(".user", string.Empty);
return extension.InvariantEquals(".xml") && (
fileCultureName.InvariantEquals(culture.Name)
Expand All @@ -246,16 +255,16 @@ private void MergeSupplementaryFiles(CultureInfo culture, XDocument xMasterDoc)

foreach (LocalizedTextServiceSupplementaryFileSource supplementaryFile in found)
{
using (FileStream fs = supplementaryFile.File.OpenRead())
using (Stream stream = supplementaryFile.FileInfo.CreateReadStream())
{
XDocument xChildDoc;
try
{
xChildDoc = XDocument.Load(fs);
xChildDoc = XDocument.Load(stream);
}
catch (Exception ex)
{
_logger.LogError(ex, "Could not load file into XML {File}", supplementaryFile.File.FullName);
_logger.LogError(ex, "Could not load file into XML {File}", supplementaryFile.FileInfo.Name);
continue;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.FileProviders.Physical;

namespace Umbraco.Cms.Core.Services;

public class LocalizedTextServiceSupplementaryFileSource
{
[Obsolete("Use other ctor. Will be removed in Umbraco 12")]
public LocalizedTextServiceSupplementaryFileSource(FileInfo file, bool overwriteCoreKeys)
: this(new PhysicalFileInfo(file), overwriteCoreKeys)
{
File = file ?? throw new ArgumentNullException("file");
}

public LocalizedTextServiceSupplementaryFileSource(IFileInfo file, bool overwriteCoreKeys)
{
FileInfo = file ?? throw new ArgumentNullException(nameof(file));
File = file is PhysicalFileInfo && file.PhysicalPath is not null ? new FileInfo(file.PhysicalPath) : null!;
OverwriteCoreKeys = overwriteCoreKeys;
}

[Obsolete("Use FileInfo instead. Will be removed in Umbraco 12")]
public FileInfo File { get; }

public IFileInfo FileInfo { get; }

public bool OverwriteCoreKeys { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,14 @@ private static LocalizedTextServiceFileSources CreateLocalizedTextServiceFileSou
IServiceProvider container)
{
IHostingEnvironment hostingEnvironment = container.GetRequiredService<IHostingEnvironment>();

// TODO: (for >= v13) Rethink whether all language files (.xml and .user.xml) should be located in ~/config/lang
// instead of ~/umbraco/config/lang and ~/config/lang.
// Currently when extending Umbraco, a new language file that the backoffice will be available in, should be placed
// in ~/umbraco/config/lang, while 'user' translation files for overrides are in ~/config/lang (according to our docs).
// Such change will be breaking and we would need to document this clearly.
var subPath = WebPath.Combine(Constants.SystemDirectories.Umbraco, "config", "lang");

var mainLangFolder = new DirectoryInfo(hostingEnvironment.MapPathContentRoot(subPath));

return new LocalizedTextServiceFileSources(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Services;
Expand Down Expand Up @@ -42,20 +44,30 @@ private static IEnumerable<LocalizedTextServiceSupplementaryFileSource> GetSuppl
// gets all langs files in /app_plugins real or virtual locations
IEnumerable<LocalizedTextServiceSupplementaryFileSource> pluginLangFileSources = GetPluginLanguageFileSources(webFileProvider, Cms.Core.Constants.SystemDirectories.AppPlugins, false);

// user defined langs that overwrite the default, these should not be used by plugin creators
// user defined language files that overwrite the default, these should not be used by plugin creators
var userConfigLangFolder = Cms.Core.Constants.SystemDirectories.Config
.TrimStart(Cms.Core.Constants.CharArrays.Tilde);

IEnumerable<LocalizedTextServiceSupplementaryFileSource> userLangFileSources = contentFileProvider.GetDirectoryContents(userConfigLangFolder)
.Where(x => x.IsDirectory && x.Name.InvariantEquals("lang"))
.Select(x => new DirectoryInfo(x.PhysicalPath!))
.SelectMany(x => x.GetFiles("*.user.xml", SearchOption.TopDirectoryOnly))
.Select(x => new LocalizedTextServiceSupplementaryFileSource(x, true));
var configLangFileSources = new List<LocalizedTextServiceSupplementaryFileSource>();

foreach (IFileInfo langFileSource in contentFileProvider.GetDirectoryContents(userConfigLangFolder))
{
if (langFileSource.IsDirectory && langFileSource.Name.InvariantEquals("lang"))
{
foreach (IFileInfo langFile in contentFileProvider.GetDirectoryContents($"{userConfigLangFolder}/{langFileSource.Name}"))
{
if (langFile.Name.InvariantEndsWith(".xml") && langFile.PhysicalPath is not null)
{
configLangFileSources.Add(new LocalizedTextServiceSupplementaryFileSource(langFile, true));
}
}
}
}

return
localPluginFileSources
.Concat(pluginLangFileSources)
.Concat(userLangFileSources);
.Concat(configLangFileSources);
}


Expand Down Expand Up @@ -83,13 +95,12 @@ private static IEnumerable<LocalizedTextServiceSupplementaryFileSource> GetPlugi
foreach (var langFolder in GetLangFolderPaths(fileProvider, pluginFolderPath))
{
// request all the files out of the path, these will have physicalPath set.
IEnumerable<FileInfo> localizationFiles = fileProvider
IEnumerable<IFileInfo> localizationFiles = fileProvider
.GetDirectoryContents(langFolder)
.Where(x => !string.IsNullOrEmpty(x.PhysicalPath))
.Where(x => x.Name.InvariantEndsWith(".xml"))
.Select(x => new FileInfo(x.PhysicalPath!));
.Where(x => x.Name.InvariantEndsWith(".xml"));

foreach (FileInfo file in localizationFiles)
foreach (IFileInfo file in localizationFiles)
{
yield return new LocalizedTextServiceSupplementaryFileSource(file, overwriteCoreKeys);
}
Expand Down
83 changes: 72 additions & 11 deletions src/Umbraco.Web.Common/Extensions/BlockGridTemplateExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,91 @@ public static class BlockGridTemplateExtensions
public const string DefaultItemsTemplate = "items";
public const string DefaultItemAreasTemplate = "areas";

#region Async

/// <summary>
/// Renders a block grid model into a grid layout
/// </summary>
/// <remarks>
/// By default this method uses a set of built-in partial views for rendering the blocks and areas in the grid model.
/// These partial views are embedded in the static assets (Umbraco.Cms.StaticAssets), so they won't show up in the
/// Views folder on your local disk.
///
/// If you need to tweak the grid rendering output, you can copy the partial views from GitHub to your local disk.
/// The partial views are found in "/src/Umbraco.Cms.StaticAssets/Views/Partials/blockgrid/" on GitHub and should
/// be copied to "Views/Partials/BlockGrid/" on your local disk.
/// </remarks>
/// <seealso href="https://our.umbraco.com/documentation/Fundamentals/Backoffice/Property-Editors/Built-in-Property-Editors/Block-Editor/Block-Grid-Editor/#1-default-rendering"/>
public static async Task<IHtmlContent> GetBlockGridHtmlAsync(this IHtmlHelper html, BlockGridModel? model, string template = DefaultTemplate)
{
if (model?.Count == 0)
{
return new HtmlString(string.Empty);
}

var view = $"{DefaultFolder}{template}";
return await html.PartialAsync(view, model);
return await html.PartialAsync(DefaultFolderTemplate(template), model);
}

/// <inheritdoc cref="GetBlockGridHtmlAsync(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper,Umbraco.Cms.Core.Models.Blocks.BlockGridModel?,string)"/>
public static async Task<IHtmlContent> GetBlockGridHtmlAsync(this IHtmlHelper html, IPublishedProperty property, string template = DefaultTemplate)
=> await GetBlockGridHtmlAsync(html, property.GetValue() as BlockGridModel, template);

/// <inheritdoc cref="GetBlockGridHtmlAsync(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper,Umbraco.Cms.Core.Models.Blocks.BlockGridModel?,string)"/>
public static async Task<IHtmlContent> GetBlockGridHtmlAsync(this IHtmlHelper html, IPublishedContent contentItem, string propertyAlias)
=> await GetBlockGridHtmlAsync(html, contentItem, propertyAlias, DefaultTemplate);

public static async Task<IHtmlContent> GetBlockGridHtmlAsync(this IHtmlHelper html, IPublishedContent contentItem, string propertyAlias, string template)
{
IPublishedProperty prop = GetRequiredProperty(contentItem, propertyAlias);
return await GetBlockGridHtmlAsync(html, prop.GetValue() as BlockGridModel, template);
}

public static async Task<IHtmlContent> GetBlockGridItemsHtmlAsync(this IHtmlHelper html, IEnumerable<BlockGridItem> items, string template = DefaultItemsTemplate)
=> await html.PartialAsync(DefaultFolderTemplate(template), items);

public static async Task<IHtmlContent> GetBlockGridItemAreasHtmlAsync(this IHtmlHelper html, BlockGridItem item, string template = DefaultItemAreasTemplate)
=> await html.PartialAsync(DefaultFolderTemplate(template), item);

#endregion

#region Sync

/// <inheritdoc cref="GetBlockGridHtmlAsync(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper,Umbraco.Cms.Core.Models.Blocks.BlockGridModel?,string)"/>
public static IHtmlContent GetBlockGridHtml(this IHtmlHelper html, BlockGridModel? model, string template = DefaultTemplate)
{
if (model?.Count == 0)
{
return new HtmlString(string.Empty);
}

return html.Partial(DefaultFolderTemplate(template), model);
}

/// <inheritdoc cref="GetBlockGridHtmlAsync(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper,Umbraco.Cms.Core.Models.Blocks.BlockGridModel?,string)"/>
public static IHtmlContent GetBlockGridHtml(this IHtmlHelper html, IPublishedProperty property, string template = DefaultTemplate)
=> GetBlockGridHtml(html, property.GetValue() as BlockGridModel, template);

/// <inheritdoc cref="GetBlockGridHtmlAsync(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper,Umbraco.Cms.Core.Models.Blocks.BlockGridModel?,string)"/>
public static IHtmlContent GetBlockGridHtml(this IHtmlHelper html, IPublishedContent contentItem, string propertyAlias)
=> GetBlockGridHtml(html, contentItem, propertyAlias, DefaultTemplate);

public static IHtmlContent GetBlockGridHtml(this IHtmlHelper html, IPublishedContent contentItem, string propertyAlias, string template)
{
IPublishedProperty prop = GetRequiredProperty(contentItem, propertyAlias);
return GetBlockGridHtml(html, prop.GetValue() as BlockGridModel, template);
}

public static IHtmlContent GetBlockGridItemsHtml(this IHtmlHelper html, IEnumerable<BlockGridItem> items, string template = DefaultItemsTemplate)
=> html.Partial(DefaultFolderTemplate(template), items);

public static IHtmlContent GetBlockGridItemAreasHtml(this IHtmlHelper html, BlockGridItem item, string template = DefaultItemAreasTemplate)
=> html.Partial(DefaultFolderTemplate(template), item);

#endregion

private static string DefaultFolderTemplate(string template) => $"{DefaultFolder}{template}";

private static IPublishedProperty GetRequiredProperty(IPublishedContent contentItem, string propertyAlias)
{
ArgumentNullException.ThrowIfNull(propertyAlias);

Expand All @@ -43,18 +110,12 @@ public static async Task<IHtmlContent> GetBlockGridHtmlAsync(this IHtmlHelper ht
nameof(propertyAlias));
}

IPublishedProperty? prop = contentItem.GetProperty(propertyAlias);
if (prop == null)
IPublishedProperty? property = contentItem.GetProperty(propertyAlias);
if (property == null)
{
throw new InvalidOperationException("No property type found with alias " + propertyAlias);
}

return await GetBlockGridHtmlAsync(html, prop.GetValue() as BlockGridModel, template);
return property;
}

public static async Task<IHtmlContent> GetBlockGridItemsHtmlAsync(this IHtmlHelper html, IEnumerable<BlockGridItem> items, string template = DefaultItemsTemplate)
=> await html.PartialAsync($"{DefaultFolder}{template}", items);

public static async Task<IHtmlContent> GetBlockGridItemAreasHtmlAsync(this IHtmlHelper html, BlockGridItem item, string template = DefaultItemAreasTemplate)
=> await html.PartialAsync($"{DefaultFolder}{template}", item);
}
Loading