From dd5a144bcd90c547a9a5a1c0d64c5c4b2546d851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Thu, 22 Feb 2024 14:13:20 +0100 Subject: [PATCH 01/91] Update NuGet versions to pre-release. --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index 0818917..d25e2ed 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -36,18 +36,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From 79280590efe9cfb995f0596d51366d93ed4ac661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Fri, 23 Feb 2024 20:24:07 +0100 Subject: [PATCH 02/91] Fix compilation errors. --- .../Views/ContentSetContentPickerField.cshtml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Views/ContentSetContentPickerField.cshtml b/Lombiq.HelpfulExtensions/Views/ContentSetContentPickerField.cshtml index 4e5884f..62ea50f 100644 --- a/Lombiq.HelpfulExtensions/Views/ContentSetContentPickerField.cshtml +++ b/Lombiq.HelpfulExtensions/Views/ContentSetContentPickerField.cshtml @@ -2,12 +2,13 @@ @using OrchardCore @using OrchardCore.ContentManagement.Metadata.Settings @using OrchardCore.Mvc.Utilities +@using System.Text.Json.Nodes @{ var name = (Model.PartFieldDefinition.PartDefinition.Name + "-" + Model.PartFieldDefinition.Name).HtmlClassify(); - var settings = Model.PartFieldDefinition.Settings.GetMaybe(nameof(ContentPartFieldSettings)); - var displayName = settings?.ToObject()?.DisplayName ?? Model.PartFieldDefinition.Name; + var settings = Model.PartFieldDefinition.Settings?.ToObject(); + var displayName = settings?.DisplayName ?? Model.PartFieldDefinition.Name; var links = Model .MemberLinks From 4a90771886d24312b759b052258b5372f6ba4f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Fri, 23 Feb 2024 21:10:55 +0100 Subject: [PATCH 03/91] Refactor CodeGenerationDisplayDriver. --- .../CodeGenerationDisplayDriver.cs | 86 ++++++++----------- 1 file changed, 35 insertions(+), 51 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs b/Lombiq.HelpfulExtensions/Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs index 67edb7f..9a9c433 100644 --- a/Lombiq.HelpfulExtensions/Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs +++ b/Lombiq.HelpfulExtensions/Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs @@ -1,5 +1,4 @@ using Microsoft.Extensions.Localization; -using Newtonsoft.Json.Linq; using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.ContentTypes.Editors; @@ -9,11 +8,15 @@ using System.Globalization; using System.Linq; using System.Text; +using System.Text.Json.Nodes; namespace Lombiq.HelpfulExtensions.Extensions.CodeGeneration; public class CodeGenerationDisplayDriver : ContentTypeDefinitionDisplayDriver { + private const int IndentationDepth = 4; + private const string EmptyString = "\"\""; + private readonly IStringLocalizer T; public CodeGenerationDisplayDriver(IStringLocalizer stringLocalizer) => @@ -37,7 +40,7 @@ public override IDisplayResult Edit(ContentTypeDefinition model) => codeBuilder.AppendLine(CultureInfo.InvariantCulture, $" .DisplayedAs(\"{model.DisplayName}\")"); GenerateCodeForSettings(codeBuilder, model.GetSettings()); - AddSettingsWithout(codeBuilder, model.Settings, 4); + AddSettingsWithout(codeBuilder, model.Settings); GenerateCodeForParts(codeBuilder, model.Parts); codeBuilder.AppendLine(");"); @@ -63,7 +66,7 @@ private void GenerateCodeForParts(StringBuilder codeBuilder, IEnumerable(codeBuilder, part.Settings, 8); + AddSettingsWithout(codeBuilder, part.Settings, 2 * IndentationDepth); // Checking if anything was added to the part's settings. if (codeBuilder.Length == partStartingLength) @@ -102,7 +105,7 @@ private void GenerateCodeForPartsWithFields( AddWithLine(codeBuilder, nameof(partSettings.Description), partSettings.Description); AddWithLine(codeBuilder, nameof(partSettings.DefaultPosition), partSettings.DefaultPosition); - AddSettingsWithout(codeBuilder, part.Settings, 4); + AddSettingsWithout(codeBuilder, part.Settings); foreach (var field in part.Fields) { @@ -116,7 +119,7 @@ private void GenerateCodeForPartsWithFields( AddWithLine(codeBuilder, nameof(fieldSettings.DisplayMode), fieldSettings.DisplayMode); AddWithLine(codeBuilder, nameof(fieldSettings.Position), fieldSettings.Position); - AddSettingsWithout(codeBuilder, field.Settings, 8); + AddSettingsWithout(codeBuilder, field.Settings, 2 * IndentationDepth); codeBuilder.AppendLine(" )"); } @@ -125,32 +128,20 @@ private void GenerateCodeForPartsWithFields( } } - private string ConvertJToken(JToken jToken, int indentationDepth) - { - switch (jToken) + private string ConvertNode(JsonNode node, int indentationDepth) => + node switch { - case JValue jValue: - var value = jValue.Value; - return value switch - { - bool boolValue => boolValue ? "true" : "false", - string => $"\"{value}\"", - _ => value?.ToString()?.Replace(',', '.'), // Replace decimal commas. - }; - case JArray jArray: - return ConvertJArray(jArray, indentationDepth); - case JObject jObject: - return ConvertJObject(jObject, indentationDepth); - default: - throw new NotSupportedException($"Settings values of type {jToken.GetType()} are not supported."); - } - } + JsonValue jsonValue => jsonValue.ToString(), + JsonArray jsonArray => ConvertJsonArray(jsonArray, indentationDepth), + JsonObject jsonObject => ConvertJsonObject(jsonObject, indentationDepth), + _ => throw new NotSupportedException($"Settings values of type {node.GetType()} are not supported."), + }; - private string ConvertJArray(JArray jArray, int indentationDepth) + private string ConvertJsonArray(JsonArray jArray, int indentationDepth) { - var indentation = new string(' ', indentationDepth + 4); + var indentation = new string(' ', indentationDepth + IndentationDepth); - var items = jArray.Select(item => ConvertJToken(item, indentationDepth + 8)).ToList(); + var items = jArray.Select(item => ConvertNode(item, indentationDepth + (2 * IndentationDepth))).ToList(); // If the items are formatted (for ListValueOption) then don't inject line-by-line formatting. if (items.Exists(item => item.ContainsOrdinalIgnoreCase(Environment.NewLine))) @@ -164,7 +155,7 @@ private string ConvertJArray(JArray jArray, int indentationDepth) stringArrayCodeBuilder.AppendLine(); stringArrayCodeBuilder.AppendLine(CultureInfo.InvariantCulture, $"{indentation}{{"); - var itemIndentation = new string(' ', indentationDepth + 8); + var itemIndentation = new string(' ', indentationDepth + (2 * IndentationDepth)); foreach (var item in items) { @@ -176,17 +167,17 @@ private string ConvertJArray(JArray jArray, int indentationDepth) return stringArrayCodeBuilder.ToString(); } - private string ConvertJObject(JObject jObject, int indentationDepth) + private string ConvertJsonObject(JsonObject jObject, int indentationDepth) { var braceIndentation = new string(' ', indentationDepth); - var propertyIndentation = new string(' ', indentationDepth + 4); - if (jObject["name"] != null && jObject["value"] != null) + var propertyIndentation = new string(' ', indentationDepth + IndentationDepth); + if (jObject["name"] is { } name && jObject["value"] is { } value) { var objectCodeBuilder = new StringBuilder(); objectCodeBuilder.AppendLine(CultureInfo.InvariantCulture, $"{braceIndentation}new ListValueOption"); objectCodeBuilder.AppendLine(CultureInfo.InvariantCulture, $"{braceIndentation}{{"); - objectCodeBuilder.AppendLine(CultureInfo.InvariantCulture, $"{propertyIndentation}Name = \"{jObject["name"]}\","); - objectCodeBuilder.AppendLine(CultureInfo.InvariantCulture, $"{propertyIndentation}Value = \"{jObject["value"]}\","); + objectCodeBuilder.AppendLine(CultureInfo.InvariantCulture, $"{propertyIndentation}Name = \"{name}\","); + objectCodeBuilder.AppendLine(CultureInfo.InvariantCulture, $"{propertyIndentation}Value = \"{value}\","); objectCodeBuilder.AppendLine(CultureInfo.InvariantCulture, $"{braceIndentation}}},"); return objectCodeBuilder.ToString(); @@ -196,33 +187,26 @@ private string ConvertJObject(JObject jObject, int indentationDepth) return T["\"FIX ME! Couldn't determine the actual type to instantiate.\" {0}", jObject.ToString()]; } - private void AddSettingsWithout(StringBuilder codeBuilder, JObject settings, int indentationDepth) + private void AddSettingsWithout(StringBuilder codeBuilder, JsonObject settings, int indentationDepth = IndentationDepth) { var indentation = new string(' ', indentationDepth); - var filteredSettings = ((IEnumerable>)settings) - .Where(setting => setting.Key != typeof(T).Name); + var filteredSettings = settings + .Where(pair => pair.Key != typeof(T).Name && pair.Value is JsonObject) + .Select(pair => (pair.Key, (JsonObject)pair.Value)); - foreach (var setting in filteredSettings) + foreach (var (typeName, properties) in filteredSettings) { - var properties = setting.Value.Where(property => property is JProperty).Cast().ToArray(); + if (properties.Count == 0) continue; - if (properties.Length == 0) continue; - - codeBuilder.AppendLine(CultureInfo.InvariantCulture, $"{indentation}.WithSettings(new {setting.Key}"); + codeBuilder.AppendLine(CultureInfo.InvariantCulture, $"{indentation}.WithSettings(new {typeName}"); codeBuilder.AppendLine(indentation + "{"); - // This doesn't support multi-level object hierarchies for settings but come on, who uses complex settings - // objects? - for (int i = 0; i < properties.Length; i++) + foreach (var (name, value) in properties) { - var property = properties[i]; - - var propertyValue = ConvertJToken(property.Value, indentationDepth); - - propertyValue ??= "\"\""; - - codeBuilder.AppendLine(CultureInfo.InvariantCulture, $"{indentation} {property.Name} = {propertyValue},"); + codeBuilder.AppendLine( + CultureInfo.InvariantCulture, + $"{indentation} {name} = {ConvertNode(value, indentationDepth) ?? EmptyString},"); } codeBuilder.AppendLine(indentation + "})"); From 87c3db9cae076ea737997c1b7693fd8185c57b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Fri, 23 Feb 2024 21:45:16 +0100 Subject: [PATCH 04/91] Fix compilation errors. --- .../ContentSets/ViewModels/ContentSetPartViewModel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Extensions/ContentSets/ViewModels/ContentSetPartViewModel.cs b/Lombiq.HelpfulExtensions/Extensions/ContentSets/ViewModels/ContentSetPartViewModel.cs index 641bc03..64cf2dc 100644 --- a/Lombiq.HelpfulExtensions/Extensions/ContentSets/ViewModels/ContentSetPartViewModel.cs +++ b/Lombiq.HelpfulExtensions/Extensions/ContentSets/ViewModels/ContentSetPartViewModel.cs @@ -8,6 +8,7 @@ using OrchardCore.ContentManagement.Metadata.Settings; using System.Collections.Generic; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; namespace Lombiq.HelpfulExtensions.Extensions.ContentSets.ViewModels; @@ -33,8 +34,7 @@ public class ContentSetPartViewModel public string DisplayName => Definition? .Settings? - .Property(nameof(ContentTypePartSettings))? - .Value + .GetMaybe(nameof(ContentTypePartSettings))? .ToObject()? .DisplayName ?? Definition?.Name; From d9d5d9c3dfaf3c8c59a96df7b0e889e5ce093c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sat, 24 Feb 2024 02:05:25 +0100 Subject: [PATCH 05/91] Remove "using Newtonsoft.Json" --- .../WorkflowContentSetEventHandler.cs | 19 ++++++++++++------- .../OrchardExportToRecipeConverter.cs | 6 +++--- .../Drivers/MvcConditionDisplayDriver.cs | 4 ++-- .../Views/MvcCondition.Fields.Edit.cshtml | 5 +++-- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Extensions/ContentSets/Workflows/Handlers/WorkflowContentSetEventHandler.cs b/Lombiq.HelpfulExtensions/Extensions/ContentSets/Workflows/Handlers/WorkflowContentSetEventHandler.cs index f7e34c3..645fa1f 100644 --- a/Lombiq.HelpfulExtensions/Extensions/ContentSets/Workflows/Handlers/WorkflowContentSetEventHandler.cs +++ b/Lombiq.HelpfulExtensions/Extensions/ContentSets/Workflows/Handlers/WorkflowContentSetEventHandler.cs @@ -4,8 +4,6 @@ using Lombiq.HelpfulExtensions.Extensions.ContentSets.Workflows.Activities; using Lombiq.HelpfulExtensions.Extensions.ContentSets.Workflows.Models; using Lombiq.HelpfulLibraries.OrchardCore.Workflow; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.Workflows.Models; @@ -13,6 +11,8 @@ using System.Collections.Generic; using System.Dynamic; using System.Linq; +using System.Text.Json; +using System.Text.Json.Nodes; using System.Threading.Tasks; namespace Lombiq.HelpfulExtensions.Extensions.ContentSets.Workflows.Handlers; @@ -54,14 +54,16 @@ public async Task> GetSupportedOptionsAsync case ContentSetLinkViewModel viewModel: links.Add(viewModel); break; - case IEnumerable collection when collection.CastWhere() is { } objects && objects.Any(): - links.AddRange(JToken.FromObject(objects).ToObject>()); - break; case ExpandoObject expandoObject: - links.Add(JToken.FromObject(expandoObject).ToObject()); + links.Add(SerializeAndDeserialize(expandoObject)); + break; + case IEnumerable collection when + collection.CastWhere().ToList() is { } objects && + objects.Count != 0: + links.AddRange(SerializeAndDeserialize>(objects)); break; case string json when !string.IsNullOrWhiteSpace(json): - links.AddRange(JsonConvert.DeserializeObject>(json)); + links.AddRange(JsonSerializer.Deserialize>(json)); break; default: continue; } @@ -79,4 +81,7 @@ public Task CreatingAsync( new CreatingContext(content, definition, contentSet, newKey), $"{nameof(WorkflowContentSetEventHandler)}.{nameof(CreatingAsync)}" + $"({content.ContentItemId}, {definition.Name}, {contentSet}, {newKey})"); + + private static T SerializeAndDeserialize(object source) => + JsonSerializer.SerializeToNode(source).ToObject(); } diff --git a/Lombiq.HelpfulExtensions/Extensions/OrchardRecipeMigration/Services/OrchardExportToRecipeConverter.cs b/Lombiq.HelpfulExtensions/Extensions/OrchardRecipeMigration/Services/OrchardExportToRecipeConverter.cs index 5eddadb..ef460c1 100644 --- a/Lombiq.HelpfulExtensions/Extensions/OrchardRecipeMigration/Services/OrchardExportToRecipeConverter.cs +++ b/Lombiq.HelpfulExtensions/Extensions/OrchardRecipeMigration/Services/OrchardExportToRecipeConverter.cs @@ -1,4 +1,3 @@ -using Newtonsoft.Json.Linq; using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Metadata; using OrchardCore.Entities; @@ -6,6 +5,7 @@ using OrchardCore.Users.Models; using System.Collections.Generic; using System.Linq; +using System.Text.Json; using System.Threading.Tasks; using System.Xml.Linq; using System.Xml.XPath; @@ -72,8 +72,8 @@ await _contentConverters await converter.UpdateContentItemsAsync(export, contentItems); } - var recipe = JObject.FromObject(new RecipeDescriptor()); - recipe["steps"] = JArray.FromObject(new[] { new { name = "content", data = contentItems } }); + var recipe = JsonSerializer.SerializeToNode(new RecipeDescriptor())!; + recipe["steps"] = JsonSerializer.SerializeToNode(new[] { new { name = "content", data = contentItems } }); return recipe.ToString(); } diff --git a/Lombiq.HelpfulExtensions/Extensions/Widgets/Drivers/MvcConditionDisplayDriver.cs b/Lombiq.HelpfulExtensions/Extensions/Widgets/Drivers/MvcConditionDisplayDriver.cs index 54df6e6..d8e6785 100644 --- a/Lombiq.HelpfulExtensions/Extensions/Widgets/Drivers/MvcConditionDisplayDriver.cs +++ b/Lombiq.HelpfulExtensions/Extensions/Widgets/Drivers/MvcConditionDisplayDriver.cs @@ -3,10 +3,10 @@ using Microsoft.AspNetCore.Html; using Microsoft.AspNetCore.Mvc.Localization; using Microsoft.Extensions.Localization; -using Newtonsoft.Json; using OrchardCore.DisplayManagement.ModelBinding; using OrchardCore.DisplayManagement.Views; using System.Linq; +using System.Text.Json; using System.Threading.Tasks; namespace Lombiq.HelpfulExtensions.Extensions.Widgets.Drivers; @@ -77,7 +77,7 @@ static IHtmlContentBuilder AppendIfNotEmpty(IHtmlContentBuilder summaryHint, str if (condition.OtherRouteValues.Any()) { summaryHint = summaryHint.AppendHtml( - H["Other route values: {0}", JsonConvert.SerializeObject(condition.OtherRouteValues)]); + H["Other route values: {0}", JsonSerializer.Serialize(condition.OtherRouteValues)]); } return new ConditionViewModel diff --git a/Lombiq.HelpfulExtensions/Views/MvcCondition.Fields.Edit.cshtml b/Lombiq.HelpfulExtensions/Views/MvcCondition.Fields.Edit.cshtml index f75783b..34df581 100644 --- a/Lombiq.HelpfulExtensions/Views/MvcCondition.Fields.Edit.cshtml +++ b/Lombiq.HelpfulExtensions/Views/MvcCondition.Fields.Edit.cshtml @@ -1,4 +1,5 @@ -@using Newtonsoft.Json +@using System.Text.Json +@using Lombiq.HelpfulLibraries.OrchardCore.TagHelpers @model MvcConditionViewModel @{ @@ -19,7 +20,7 @@
From 8186703039eac1383e3493dcd553efb4f9e6754b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sat, 24 Feb 2024 15:46:10 +0100 Subject: [PATCH 06/91] Fix MenuWidgetLiquidFilter. --- .../Widgets/Liquid/MenuWidgetLiquidFilter.cs | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Extensions/Widgets/Liquid/MenuWidgetLiquidFilter.cs b/Lombiq.HelpfulExtensions/Extensions/Widgets/Liquid/MenuWidgetLiquidFilter.cs index 2cc0ac4..e5733d0 100644 --- a/Lombiq.HelpfulExtensions/Extensions/Widgets/Liquid/MenuWidgetLiquidFilter.cs +++ b/Lombiq.HelpfulExtensions/Extensions/Widgets/Liquid/MenuWidgetLiquidFilter.cs @@ -6,13 +6,14 @@ using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.AspNetCore.Mvc.Routing; using Microsoft.Extensions.Localization; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using OrchardCore.Liquid; using OrchardCore.Navigation; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Nodes; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace Lombiq.HelpfulExtensions.Extensions.Widgets.Liquid; @@ -45,23 +46,18 @@ public ValueTask ProcessAsync(FluidValue input, FilterArguments argu localNav = arguments[nameof(localNav)].ToBooleanValue(); classes = arguments[nameof(classes)].ToStringValue(); - var converter = new LocalizedStringJsonConverter(T); - var serializer = new JsonSerializer(); - serializer.Converters.Add(converter); - var serializerSettings = new JsonSerializerSettings(); - serializerSettings.Converters.Add(converter); - + var serializerOptions = LocalizedStringJsonConverter.Add(T); var menuItems = input?.Type switch { - FluidValues.String => JsonConvert.DeserializeObject>( + FluidValues.String => JsonSerializer.Deserialize>( input!.ToStringValue(), - serializerSettings), + serializerOptions), FluidValues.Object => input!.ToObjectValue() switch { IEnumerable enumerable => enumerable.AsList(), MenuItem single => new[] { single }, - JArray jArray => jArray.ToObject>(serializer), - JObject jObject => new[] { jObject.ToObject(serializer) }, + JsonArray jsonArray => jsonArray.ToObject>(serializerOptions), + JsonObject jsonObject => new[] { jsonObject.ToObject(serializerOptions) }, _ => null, }, _ => null, @@ -102,32 +98,36 @@ public class LocalizedStringJsonConverter : JsonConverter { private readonly IStringLocalizer T; - public LocalizedStringJsonConverter(IStringLocalizer stringLocalizer) => + private LocalizedStringJsonConverter(IStringLocalizer stringLocalizer) => T = stringLocalizer; - public override void WriteJson(JsonWriter writer, LocalizedString value, JsonSerializer serializer) => - writer.WriteValue(value?.Value); + public override void Write(Utf8JsonWriter writer, LocalizedString value, JsonSerializerOptions options) => + writer.WriteStringValue(value?.Value); [SuppressMessage("Style", "IDE0010:Add missing cases", Justification = "We don't want to handle other token types.")] - public override LocalizedString ReadJson( - JsonReader reader, - Type objectType, - LocalizedString existingValue, - bool hasExistingValue, - JsonSerializer serializer) + public override LocalizedString Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { switch (reader.TokenType) { - case JsonToken.String: - return JToken.ReadFrom(reader).ToObject() is { } text ? T[text] : null; - case JsonToken.StartObject: + case JsonTokenType.String: + return JsonSerializer.Deserialize(ref reader, options) is { } text ? T[text] : null; + case JsonTokenType.StartObject: var data = new Dictionary( - JToken.ReadFrom(reader).ToObject>(), + JsonSerializer.Deserialize>(ref reader, options), StringComparer.OrdinalIgnoreCase); return new LocalizedString(data[nameof(LocalizedString.Name)], data[nameof(LocalizedString.Value)]); default: throw new InvalidOperationException("Unable to parse JSON!"); } } + + public static JsonSerializerOptions Add(IStringLocalizer stringLocalizer, JsonSerializerOptions options = null) + { + options ??= new JsonSerializerOptions(JsonSerializerOptions.Default); + options.Converters.RemoveAll(converter => converter is JsonConverter); + options.Converters.Add(new LocalizedStringJsonConverter(stringLocalizer)); + + return options; + } } } From 2c38547272fb70f5c80bda25419b45c8d7757cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Mon, 4 Mar 2024 00:22:13 +0100 Subject: [PATCH 07/91] Update OC to latest (because of bug fix for WorkflowTypeStep) --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index 3018153..f2b2834 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -36,18 +36,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From 22b85a486386b4550f97d50e81a71c569fc9fb39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Mon, 4 Mar 2024 00:42:05 +0100 Subject: [PATCH 08/91] ISmtpService is obsolete. --- .../Emails/Extensions/EmailSenderShellScopeExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Extensions/Emails/Extensions/EmailSenderShellScopeExtensions.cs b/Lombiq.HelpfulExtensions/Extensions/Emails/Extensions/EmailSenderShellScopeExtensions.cs index 0b3dd43..d6629e1 100644 --- a/Lombiq.HelpfulExtensions/Extensions/Emails/Extensions/EmailSenderShellScopeExtensions.cs +++ b/Lombiq.HelpfulExtensions/Extensions/Emails/Extensions/EmailSenderShellScopeExtensions.cs @@ -18,8 +18,8 @@ public static class EmailSenderShellScopeExtensions public static void SendEmailDeferred(this ShellScope shellScope, EmailParameters parameters) => shellScope.AddDeferredTask(async scope => { - var smtpService = scope.ServiceProvider.GetRequiredService(); - var result = await smtpService.SendAsync(new MailMessage + var emailService = scope.ServiceProvider.GetRequiredService(); + var result = await emailService.SendAsync(new MailMessage { Sender = parameters.Sender, To = parameters.To?.Join(","), From c0874566f1274e8bb0ec445d9808df783c86a787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Mon, 4 Mar 2024 21:30:47 +0100 Subject: [PATCH 09/91] Update method name. --- Lombiq.HelpfulExtensions/Extensions/SiteTexts/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.HelpfulExtensions/Extensions/SiteTexts/Startup.cs b/Lombiq.HelpfulExtensions/Extensions/SiteTexts/Startup.cs index 36b3bf9..d2fc4f0 100644 --- a/Lombiq.HelpfulExtensions/Extensions/SiteTexts/Startup.cs +++ b/Lombiq.HelpfulExtensions/Extensions/SiteTexts/Startup.cs @@ -21,7 +21,7 @@ public class ContentLocalizationStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.RemoveImplementations(); + services.RemoveImplementationsOf(); services.AddScoped(); } } From dc1d164f7604a9952c6d21db9149810ab832b2aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Fri, 8 Mar 2024 00:09:14 +0100 Subject: [PATCH 10/91] Update OC preview version. --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index f2b2834..aed75f3 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -36,18 +36,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From 68c7cf5e84e20dcf0a85ae4b9e5488fcfcd34b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 13 Mar 2024 05:14:53 +0100 Subject: [PATCH 11/91] Update code generation test due to change in serialization. --- .../Constants/GeneratedMigrationCodes.cs | 74 +++++++++++-------- .../TestCaseUITestContextExtensions.cs | 3 +- 2 files changed, 44 insertions(+), 33 deletions(-) diff --git a/Lombiq.HelpfulExtensions.Tests.UI/Constants/GeneratedMigrationCodes.cs b/Lombiq.HelpfulExtensions.Tests.UI/Constants/GeneratedMigrationCodes.cs index f03fda0..fde596c 100644 --- a/Lombiq.HelpfulExtensions.Tests.UI/Constants/GeneratedMigrationCodes.cs +++ b/Lombiq.HelpfulExtensions.Tests.UI/Constants/GeneratedMigrationCodes.cs @@ -1,39 +1,49 @@ +using Shouldly; using System; +using System.Diagnostics.CodeAnalysis; namespace Lombiq.HelpfulExtensions.Tests.UI.Constants; internal static class GeneratedMigrationCodes { - // Environment.NewLine is used for this to work regardless of the mismatch of line ending style between the code - // file, the platform where it was compiled, and where it was executed. - public static string Page = - string.Join( - Environment.NewLine, - "_contentDefinitionManager.AlterTypeDefinition(\"Page\", type => type", - " .DisplayedAs(\"Page\")", - " .Creatable()", - " .Listable()", - " .Draftable()", - " .Versionable()", - " .Securable()", - " .WithPart(\"TitlePart\", part => part", - " .WithPosition(\"0\")", - " )", - " .WithPart(\"AutoroutePart\", part => part", - " .WithPosition(\"1\")", - " .WithSettings(new AutoroutePartSettings", - " {", - " AllowCustomPath = true,", - " ShowHomepageOption = true,", - " Pattern = \"{{ Model.ContentItem | display_text | slugify }}\",", - " })", - " )", - " .WithPart(\"FlowPart\", part => part", - " .WithPosition(\"2\")", - " )", - " .WithPart(\"Page\", part => part", - " .WithPosition(\"3\")", - " )", - ");", - string.Empty); + [SuppressMessage( + "Usage", + "MA0136:Raw String contains an implicit end of line character", + Justification = "It's wrapped to prevent issues related to that.")] + private const string Page = + """ + _contentDefinitionManager.AlterTypeDefinition("Page", type => type + .DisplayedAs("Page") + .Creatable() + .Listable() + .Draftable() + .Versionable() + .Securable() + .WithPart("TitlePart", part => part + .WithPosition("0") + ) + .WithPart("AutoroutePart", part => part + .WithPosition("1") + .WithSettings(new AutoroutePartSettings + { + AllowCustomPath = true, + Pattern = {{ Model.ContentItem | display_text | slugify }}, + ShowHomepageOption = true, + AllowUpdatePath = false, + AllowDisabled = false, + AllowRouteContainedItems = false, + ManageContainedItemRoutes = false, + AllowAbsolutePath = false, + }) + ) + .WithPart("FlowPart", part => part + .WithPosition("2") + ) + .WithPart("Page", part => part + .WithPosition("3") + ) + ); + """; + + public static void ShouldBePage(string actual) => actual.ShouldBeByLine(Page); } diff --git a/Lombiq.HelpfulExtensions.Tests.UI/Extensions/TestCaseUITestContextExtensions.cs b/Lombiq.HelpfulExtensions.Tests.UI/Extensions/TestCaseUITestContextExtensions.cs index 3765cc7..ef9a75a 100644 --- a/Lombiq.HelpfulExtensions.Tests.UI/Extensions/TestCaseUITestContextExtensions.cs +++ b/Lombiq.HelpfulExtensions.Tests.UI/Extensions/TestCaseUITestContextExtensions.cs @@ -116,7 +116,8 @@ await context.RetryIfStaleOrFailAsync(async () => { await context.ClickReliablyOnAsync(By.ClassName("toggle-showing-generated-migration-code")); - context.Get(By.Id("generated-migration-code").OfAnyVisibility()).GetValue().ShouldBe(GeneratedMigrationCodes.Page); + GeneratedMigrationCodes.ShouldBePage( + context.Get(By.Id("generated-migration-code").OfAnyVisibility()).GetValue()); // Making sure that the collapsible area is open. context.Get(By.CssSelector("#generated-migration-code-container.collapse.show")); From 4a695abbf2e6c7309968971e2fb43e3717b9b241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 13 Mar 2024 06:15:24 +0100 Subject: [PATCH 12/91] Update OC package --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index aed75f3..956e6c3 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -36,18 +36,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From aec510e0d818ff0d20de1227abc7c30547733c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 13 Mar 2024 21:33:56 +0100 Subject: [PATCH 13/91] Code cleanup. --- .../Constants/GeneratedMigrationCodes.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Lombiq.HelpfulExtensions.Tests.UI/Constants/GeneratedMigrationCodes.cs b/Lombiq.HelpfulExtensions.Tests.UI/Constants/GeneratedMigrationCodes.cs index fde596c..02626b9 100644 --- a/Lombiq.HelpfulExtensions.Tests.UI/Constants/GeneratedMigrationCodes.cs +++ b/Lombiq.HelpfulExtensions.Tests.UI/Constants/GeneratedMigrationCodes.cs @@ -1,5 +1,4 @@ using Shouldly; -using System; using System.Diagnostics.CodeAnalysis; namespace Lombiq.HelpfulExtensions.Tests.UI.Constants; From e6a3888d85be233626faeb45d8954d38eb0aa290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 2 Apr 2024 14:53:22 +0200 Subject: [PATCH 14/91] Use JObject.FromObject instead of JsonSerializer.SerializeToNode where applicable. --- .../Workflows/Handlers/WorkflowContentSetEventHandler.cs | 2 +- .../Services/OrchardExportToRecipeConverter.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Extensions/ContentSets/Workflows/Handlers/WorkflowContentSetEventHandler.cs b/Lombiq.HelpfulExtensions/Extensions/ContentSets/Workflows/Handlers/WorkflowContentSetEventHandler.cs index 645fa1f..df0ae76 100644 --- a/Lombiq.HelpfulExtensions/Extensions/ContentSets/Workflows/Handlers/WorkflowContentSetEventHandler.cs +++ b/Lombiq.HelpfulExtensions/Extensions/ContentSets/Workflows/Handlers/WorkflowContentSetEventHandler.cs @@ -83,5 +83,5 @@ public Task CreatingAsync( $"({content.ContentItemId}, {definition.Name}, {contentSet}, {newKey})"); private static T SerializeAndDeserialize(object source) => - JsonSerializer.SerializeToNode(source).ToObject(); + JObject.FromObject(source).ToObject(); } diff --git a/Lombiq.HelpfulExtensions/Extensions/OrchardRecipeMigration/Services/OrchardExportToRecipeConverter.cs b/Lombiq.HelpfulExtensions/Extensions/OrchardRecipeMigration/Services/OrchardExportToRecipeConverter.cs index ef460c1..c06fdf0 100644 --- a/Lombiq.HelpfulExtensions/Extensions/OrchardRecipeMigration/Services/OrchardExportToRecipeConverter.cs +++ b/Lombiq.HelpfulExtensions/Extensions/OrchardRecipeMigration/Services/OrchardExportToRecipeConverter.cs @@ -5,7 +5,7 @@ using OrchardCore.Users.Models; using System.Collections.Generic; using System.Linq; -using System.Text.Json; +using System.Text.Json.Nodes; using System.Threading.Tasks; using System.Xml.Linq; using System.Xml.XPath; @@ -72,8 +72,8 @@ await _contentConverters await converter.UpdateContentItemsAsync(export, contentItems); } - var recipe = JsonSerializer.SerializeToNode(new RecipeDescriptor())!; - recipe["steps"] = JsonSerializer.SerializeToNode(new[] { new { name = "content", data = contentItems } }); + var recipe = JObject.FromObject(new RecipeDescriptor())!; + recipe["steps"] = JObject.FromObject(new[] { new { name = "content", data = contentItems } }); return recipe.ToString(); } From f35bde38d4b8e747230523a1a3dead23b67825f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 23 Apr 2024 11:33:43 +0200 Subject: [PATCH 15/91] Fix SerializeAndDeserialize --- .../Workflows/Handlers/WorkflowContentSetEventHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.HelpfulExtensions/Extensions/ContentSets/Workflows/Handlers/WorkflowContentSetEventHandler.cs b/Lombiq.HelpfulExtensions/Extensions/ContentSets/Workflows/Handlers/WorkflowContentSetEventHandler.cs index df0ae76..91621e9 100644 --- a/Lombiq.HelpfulExtensions/Extensions/ContentSets/Workflows/Handlers/WorkflowContentSetEventHandler.cs +++ b/Lombiq.HelpfulExtensions/Extensions/ContentSets/Workflows/Handlers/WorkflowContentSetEventHandler.cs @@ -83,5 +83,5 @@ public Task CreatingAsync( $"({content.ContentItemId}, {definition.Name}, {contentSet}, {newKey})"); private static T SerializeAndDeserialize(object source) => - JObject.FromObject(source).ToObject(); + JNode.FromObject(source).ToObject(); } From bfd977fad15f4f156ec6b928fdf481f092ec1a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 23 Apr 2024 17:17:29 +0200 Subject: [PATCH 16/91] Update OC preview version. --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index 956e6c3..3f9117e 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -36,18 +36,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From 33639b9c0661da8e946f2c98526f74cd944037e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 23 Apr 2024 21:52:20 +0200 Subject: [PATCH 17/91] Update AddCondition to AddRuleCondition --- Lombiq.HelpfulExtensions/Extensions/Widgets/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.HelpfulExtensions/Extensions/Widgets/Startup.cs b/Lombiq.HelpfulExtensions/Extensions/Widgets/Startup.cs index 3308e13..be3cea0 100644 --- a/Lombiq.HelpfulExtensions/Extensions/Widgets/Startup.cs +++ b/Lombiq.HelpfulExtensions/Extensions/Widgets/Startup.cs @@ -26,7 +26,7 @@ public override void ConfigureServices(IServiceCollection services) services .AddScoped, MvcConditionDisplayDriver>() - .AddCondition>() + .AddRuleCondition>() .AddScoped(sp => (IContentDisplayDriver)sp.GetRequiredService()); services.AddTagHelpers(); From 75b5863dd345bd330d01c9e7139e6ef47cf5c9fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sat, 27 Apr 2024 19:31:45 +0200 Subject: [PATCH 18/91] Update OC package version. --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index 3f9117e..d3796f7 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -36,18 +36,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From 547b55eb199e11432b9d345a5eb4ab72d37b0c88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sat, 4 May 2024 12:57:04 +0200 Subject: [PATCH 19/91] Update OC versions --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index d3796f7..5d2932b 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -36,18 +36,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From eadc295ca18248f9fe6aa5489cc4bd388f9d9efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sat, 4 May 2024 13:59:19 +0200 Subject: [PATCH 20/91] Post merge and OC update fixup --- .../Extensions/Flows/FlowPartShapeTableProvider.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Extensions/Flows/FlowPartShapeTableProvider.cs b/Lombiq.HelpfulExtensions/Extensions/Flows/FlowPartShapeTableProvider.cs index bd729f6..10464bf 100644 --- a/Lombiq.HelpfulExtensions/Extensions/Flows/FlowPartShapeTableProvider.cs +++ b/Lombiq.HelpfulExtensions/Extensions/Flows/FlowPartShapeTableProvider.cs @@ -1,10 +1,16 @@ using OrchardCore.DisplayManagement.Descriptors; +using System.Threading.Tasks; namespace Lombiq.HelpfulExtensions.Extensions.Flows; internal sealed class FlowPartShapeTableProvider : IShapeTableProvider { - public void Discover(ShapeTableBuilder builder) => builder - .Describe("FlowPart") - .OnDisplaying(displaying => displaying.Shape.Metadata.Alternates.Add("Lombiq_HelpfulExtensions_Flows_FlowPart")); + public ValueTask DiscoverAsync(ShapeTableBuilder builder) + { + builder + .Describe("FlowPart") + .OnDisplaying(displaying => displaying.Shape.Metadata.Alternates.Add("Lombiq_HelpfulExtensions_Flows_FlowPart")); + + return ValueTask.CompletedTask; + } } From 5800d7b01784a9d107f18207a563e3e4d18caf3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 7 May 2024 21:08:58 +0200 Subject: [PATCH 21/91] Update OC to the latest preview. --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index 5d2932b..951c0b7 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -36,18 +36,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From 0f74d1a852a20a5057ecc6e006715f8b42bad750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 8 May 2024 23:27:52 +0200 Subject: [PATCH 22/91] Rename variable. --- .../CodeGeneration/CodeGenerationDisplayDriver.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs b/Lombiq.HelpfulExtensions/Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs index 9a9c433..65d85d9 100644 --- a/Lombiq.HelpfulExtensions/Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs +++ b/Lombiq.HelpfulExtensions/Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs @@ -167,11 +167,11 @@ private string ConvertJsonArray(JsonArray jArray, int indentationDepth) return stringArrayCodeBuilder.ToString(); } - private string ConvertJsonObject(JsonObject jObject, int indentationDepth) + private string ConvertJsonObject(JsonObject jsonObject, int indentationDepth) { var braceIndentation = new string(' ', indentationDepth); var propertyIndentation = new string(' ', indentationDepth + IndentationDepth); - if (jObject["name"] is { } name && jObject["value"] is { } value) + if (jsonObject["name"] is { } name && jsonObject["value"] is { } value) { var objectCodeBuilder = new StringBuilder(); objectCodeBuilder.AppendLine(CultureInfo.InvariantCulture, $"{braceIndentation}new ListValueOption"); @@ -184,7 +184,7 @@ private string ConvertJsonObject(JsonObject jObject, int indentationDepth) } // Using a quoted string so it doesn't mess up the syntax highlighting of the rest of the code. - return T["\"FIX ME! Couldn't determine the actual type to instantiate.\" {0}", jObject.ToString()]; + return T["\"FIX ME! Couldn't determine the actual type to instantiate.\" {0}", jsonObject.ToString()]; } private void AddSettingsWithout(StringBuilder codeBuilder, JsonObject settings, int indentationDepth = IndentationDepth) From b3e7616e0f42ca5f2c0aa44b8c5697ff087e6a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Fri, 10 May 2024 11:53:32 +0200 Subject: [PATCH 23/91] Replace strange leftover `var` with `const`. --- .../Views/StrictSecuritySetting.Edit.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.HelpfulExtensions/Views/StrictSecuritySetting.Edit.cshtml b/Lombiq.HelpfulExtensions/Views/StrictSecuritySetting.Edit.cshtml index d590018..d6effe0 100644 --- a/Lombiq.HelpfulExtensions/Views/StrictSecuritySetting.Edit.cshtml +++ b/Lombiq.HelpfulExtensions/Views/StrictSecuritySetting.Edit.cshtml @@ -14,7 +14,7 @@ + +} From 32e8beeef7bf98e4b3d166d889cb6316f8364a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 7 Aug 2024 01:55:31 +0200 Subject: [PATCH 56/91] Update OC preview version. --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index 1f42243..646e8f5 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -35,18 +35,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From a7e1f245cc2a6a732bd2f59d84ac4397a0d09135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 7 Aug 2024 12:21:39 +0200 Subject: [PATCH 57/91] Post-merge fixups. --- .../CodeGenerationDisplayDriver.cs | 3 +- .../Drivers/AdditionalStylingPartDisplay.cs | 10 ++--- .../StrictSecuritySettingsDisplayDriver.cs | 6 +-- .../Widgets/Drivers/ConditionDisplayDriver.cs | 4 +- .../Drivers/MvcConditionDisplayDriver.cs | 37 +++++++++---------- ...rateResetPasswordTokenTaskDisplayDriver.cs | 19 ++++------ 6 files changed, 38 insertions(+), 41 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs b/Lombiq.HelpfulExtensions/Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs index 65d85d9..1ce63c5 100644 --- a/Lombiq.HelpfulExtensions/Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs +++ b/Lombiq.HelpfulExtensions/Extensions/CodeGeneration/CodeGenerationDisplayDriver.cs @@ -2,6 +2,7 @@ using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.ContentTypes.Editors; +using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.Views; using System; using System.Collections.Generic; @@ -22,7 +23,7 @@ public class CodeGenerationDisplayDriver : ContentTypeDefinitionDisplayDriver public CodeGenerationDisplayDriver(IStringLocalizer stringLocalizer) => T = stringLocalizer; - public override IDisplayResult Edit(ContentTypeDefinition model) => + public override IDisplayResult Edit(ContentTypeDefinition model, BuildEditorContext context) => Initialize( "ContentTypeMigrations_Edit", viewModel => viewModel.MigrationCodeLazy = new Lazy(() => diff --git a/Lombiq.HelpfulExtensions/Extensions/Flows/Drivers/AdditionalStylingPartDisplay.cs b/Lombiq.HelpfulExtensions/Extensions/Flows/Drivers/AdditionalStylingPartDisplay.cs index f53d18f..e6b1ad3 100644 --- a/Lombiq.HelpfulExtensions/Extensions/Flows/Drivers/AdditionalStylingPartDisplay.cs +++ b/Lombiq.HelpfulExtensions/Extensions/Flows/Drivers/AdditionalStylingPartDisplay.cs @@ -1,7 +1,7 @@ using Lombiq.HelpfulExtensions.Extensions.Flows.Models; using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Display.ContentDisplay; -using OrchardCore.DisplayManagement.ModelBinding; +using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.Views; using System.Threading.Tasks; @@ -9,13 +9,13 @@ namespace Lombiq.HelpfulExtensions.Extensions.Flows.Drivers; public class AdditionalStylingPartDisplay : ContentDisplayDriver { - public override IDisplayResult Edit(ContentItem model, IUpdateModel updater) => + public override IDisplayResult Edit(ContentItem model, BuildEditorContext context) => Initialize( $"{nameof(AdditionalStylingPart)}_Edit", viewModel => PopulateViewModel(model, viewModel)) .PlaceInZone("Footer", 3); - public override async Task UpdateAsync(ContentItem model, IUpdateModel updater) + public override async Task UpdateAsync(ContentItem model, UpdateEditorContext context) { var additionalStylingPart = model.As(); @@ -24,9 +24,9 @@ public override async Task UpdateAsync(ContentItem model, IUpdat return null; } - await model.AlterAsync(model => updater.TryUpdateModelAsync(model, Prefix)); + await model.AlterAsync(model => context.Updater.TryUpdateModelAsync(model, Prefix)); - return await EditAsync(model, updater); + return await EditAsync(model, context); } private static void PopulateViewModel(ContentItem model, AdditionalStylingPart viewModel) diff --git a/Lombiq.HelpfulExtensions/Extensions/Security/Driver/StrictSecuritySettingsDisplayDriver.cs b/Lombiq.HelpfulExtensions/Extensions/Security/Driver/StrictSecuritySettingsDisplayDriver.cs index 2cb7164..b6b328c 100644 --- a/Lombiq.HelpfulExtensions/Extensions/Security/Driver/StrictSecuritySettingsDisplayDriver.cs +++ b/Lombiq.HelpfulExtensions/Extensions/Security/Driver/StrictSecuritySettingsDisplayDriver.cs @@ -11,7 +11,7 @@ namespace Lombiq.HelpfulExtensions.Extensions.Security.Driver; public class StrictSecuritySettingsDisplayDriver : ContentTypeDefinitionDisplayDriver { - public override IDisplayResult Edit(ContentTypeDefinition model) => + public override IDisplayResult Edit(ContentTypeDefinition model, BuildEditorContext context) => Initialize("StrictSecuritySetting_Edit", viewModel => { var settings = model.GetSettings(); @@ -21,13 +21,13 @@ public override IDisplayResult Edit(ContentTypeDefinition model) => public override async Task UpdateAsync(ContentTypeDefinition model, UpdateTypeEditorContext context) { - var viewModel = await context.CreateModelMaybeAsync(Prefix); + var viewModel = await context.CreateModelAsync(Prefix); // Securable must be enabled for Strict Securable to make sense. Also checked on the client side too. if (model.GetSettings()?.Securable != true) viewModel.Enabled = false; context.Builder.MergeSettings(settings => settings.Enabled = viewModel.Enabled); - return Edit(model); + return await EditAsync(model, context); } } diff --git a/Lombiq.HelpfulExtensions/Extensions/Widgets/Drivers/ConditionDisplayDriver.cs b/Lombiq.HelpfulExtensions/Extensions/Widgets/Drivers/ConditionDisplayDriver.cs index 2143a52..2408be6 100644 --- a/Lombiq.HelpfulExtensions/Extensions/Widgets/Drivers/ConditionDisplayDriver.cs +++ b/Lombiq.HelpfulExtensions/Extensions/Widgets/Drivers/ConditionDisplayDriver.cs @@ -10,12 +10,12 @@ namespace Lombiq.HelpfulExtensions.Extensions.Widgets.Drivers; public abstract class ConditionDisplayDriver : DisplayDriver where TCondition : Condition { - public override IDisplayResult Display(TCondition model) => + public override IDisplayResult Display(TCondition model, BuildDisplayContext context) => Combine( InitializeDisplayType(CommonContentDisplayTypes.Summary, model), InitializeDisplayType(CommonContentDisplayTypes.Thumbnail, model)); - public override IDisplayResult Edit(TCondition model) => + public override IDisplayResult Edit(TCondition model, BuildEditorContext context) => Combine( InitializeDisplayType(CommonContentDisplayTypes.Detail, model, "Title"), GetEditor(model)); diff --git a/Lombiq.HelpfulExtensions/Extensions/Widgets/Drivers/MvcConditionDisplayDriver.cs b/Lombiq.HelpfulExtensions/Extensions/Widgets/Drivers/MvcConditionDisplayDriver.cs index d8e6785..f99a735 100644 --- a/Lombiq.HelpfulExtensions/Extensions/Widgets/Drivers/MvcConditionDisplayDriver.cs +++ b/Lombiq.HelpfulExtensions/Extensions/Widgets/Drivers/MvcConditionDisplayDriver.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Html; using Microsoft.AspNetCore.Mvc.Localization; using Microsoft.Extensions.Localization; -using OrchardCore.DisplayManagement.ModelBinding; +using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.Views; using System.Linq; using System.Text.Json; @@ -15,6 +15,7 @@ public class MvcConditionDisplayDriver : ConditionDisplayDriver { private readonly IHtmlLocalizer H; private readonly IStringLocalizer T; + public MvcConditionDisplayDriver( IHtmlLocalizer htmlLocalizer, IStringLocalizer stringLocalizer) @@ -37,30 +38,28 @@ protected override IDisplayResult GetEditor(MvcCondition model) => } }).PlaceInContent(); - public override async Task UpdateAsync(MvcCondition model, IUpdateModel updater) + public override async Task UpdateAsync(MvcCondition model, UpdateEditorContext context) { - var viewModel = new MvcConditionViewModel(); - if (await updater.TryUpdateModelAsync(viewModel, Prefix)) + var viewModel = await context.CreateModelAsync(Prefix); + + if (viewModel.OtherRouteNames.Count != viewModel.OtherRouteValues.Count) { - if (viewModel.OtherRouteNames.Count != viewModel.OtherRouteValues.Count) - { - updater.ModelState.AddModelError( - nameof(viewModel.OtherRouteNames), - T["The count of other route value names didn't match the count of other route values."]); - } + context.Updater.ModelState.AddModelError( + nameof(viewModel.OtherRouteNames), + T["The count of other route value names didn't match the count of other route values."]); + } - model.Area = viewModel.Area; - model.Controller = viewModel.Controller; - model.Action = viewModel.Action; + model.Area = viewModel.Area; + model.Controller = viewModel.Controller; + model.Action = viewModel.Action; - model.OtherRouteValues.Clear(); - for (var i = 0; i < viewModel.OtherRouteNames.Count; i++) - { - model.OtherRouteValues[viewModel.OtherRouteNames[i]] = viewModel.OtherRouteValues[i]; - } + model.OtherRouteValues.Clear(); + for (var i = 0; i < viewModel.OtherRouteNames.Count; i++) + { + model.OtherRouteValues[viewModel.OtherRouteNames[i]] = viewModel.OtherRouteValues[i]; } - return Edit(model); + return await EditAsync(model, context); } protected override ConditionViewModel GetConditionViewModel(MvcCondition condition) diff --git a/Lombiq.HelpfulExtensions/Extensions/Workflows/Drivers/GenerateResetPasswordTokenTaskDisplayDriver.cs b/Lombiq.HelpfulExtensions/Extensions/Workflows/Drivers/GenerateResetPasswordTokenTaskDisplayDriver.cs index 32be3ce..40095ee 100644 --- a/Lombiq.HelpfulExtensions/Extensions/Workflows/Drivers/GenerateResetPasswordTokenTaskDisplayDriver.cs +++ b/Lombiq.HelpfulExtensions/Extensions/Workflows/Drivers/GenerateResetPasswordTokenTaskDisplayDriver.cs @@ -1,11 +1,9 @@ using Lombiq.HelpfulExtensions.Extensions.Workflows.Activities; using Lombiq.HelpfulExtensions.Extensions.Workflows.ViewModels; using Microsoft.Extensions.Localization; -using OrchardCore.DisplayManagement.ModelBinding; +using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.Views; -using OrchardCore.Users.Models; using OrchardCore.Workflows.Display; -using OrchardCore.Workflows.Models; using System.Threading.Tasks; namespace Lombiq.HelpfulExtensions.Extensions.Workflows.Drivers; @@ -26,16 +24,15 @@ protected override void EditActivity(GenerateResetPasswordTokenTask activity, Ge model.ResetPasswordUrlPropertyKey = activity.ResetPasswordUrlPropertyKey; } - public override async Task UpdateAsync(GenerateResetPasswordTokenTask model, IUpdateModel updater) + public override async Task UpdateAsync(GenerateResetPasswordTokenTask activity, UpdateEditorContext context) { var viewModel = new GenerateResetPasswordTokenTaskViewModel(); - if (await updater.TryUpdateModelAsync(viewModel, Prefix)) - { - model.User = new WorkflowExpression(viewModel.UserExpression); - model.ResetPasswordTokenPropertyKey = viewModel.ResetPasswordTokenPropertyKey; - model.ResetPasswordUrlPropertyKey = viewModel.ResetPasswordUrlPropertyKey; - } + await context.Updater.TryUpdateModelAsync(viewModel, Prefix); - return Edit(model); + activity.User = new(viewModel.UserExpression); + activity.ResetPasswordTokenPropertyKey = viewModel.ResetPasswordTokenPropertyKey; + activity.ResetPasswordUrlPropertyKey = viewModel.ResetPasswordUrlPropertyKey; + + return await EditAsync(activity, context); } } From 166a53036f5a333fdab7b31d9db35c2673cb3f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 7 Aug 2024 13:00:47 +0200 Subject: [PATCH 58/91] Use CreateModelAsync where applicable. --- .../Drivers/ContentSetPartDisplayDriver.cs | 18 ++++++++---------- ...erateResetPasswordTokenTaskDisplayDriver.cs | 3 +-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Extensions/ContentSets/Drivers/ContentSetPartDisplayDriver.cs b/Lombiq.HelpfulExtensions/Extensions/ContentSets/Drivers/ContentSetPartDisplayDriver.cs index 9b7f7cf..53e9aeb 100644 --- a/Lombiq.HelpfulExtensions/Extensions/ContentSets/Drivers/ContentSetPartDisplayDriver.cs +++ b/Lombiq.HelpfulExtensions/Extensions/ContentSets/Drivers/ContentSetPartDisplayDriver.cs @@ -6,6 +6,7 @@ using Microsoft.Extensions.Localization; using OrchardCore.ContentManagement.Display.ContentDisplay; using OrchardCore.ContentManagement.Display.Models; +using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.ModelBinding; using OrchardCore.DisplayManagement.Views; using OrchardCore.Entities; @@ -69,18 +70,15 @@ public override async Task UpdateAsync( IUpdateModel updater, UpdatePartEditorContext context) { - var viewModel = new ContentSetPartViewModel(); + var viewModel = await context.CreateModelAsync(Prefix); - if (await updater.TryUpdateModelAsync(viewModel, Prefix)) - { - part.Key = viewModel.Key; + part.Key = viewModel.Key; - // Need to do this here to support displaying the message to save before adding when the - // item has not been saved yet. - if (string.IsNullOrEmpty(part.ContentSet)) - { - part.ContentSet = _idGenerator.GenerateUniqueId(); - } + // Need to do this here to support displaying the message to save before adding when the item has not been saved + // yet. + if (string.IsNullOrEmpty(part.ContentSet)) + { + part.ContentSet = _idGenerator.GenerateUniqueId(); } return await EditAsync(part, context); diff --git a/Lombiq.HelpfulExtensions/Extensions/Workflows/Drivers/GenerateResetPasswordTokenTaskDisplayDriver.cs b/Lombiq.HelpfulExtensions/Extensions/Workflows/Drivers/GenerateResetPasswordTokenTaskDisplayDriver.cs index 40095ee..cbc408f 100644 --- a/Lombiq.HelpfulExtensions/Extensions/Workflows/Drivers/GenerateResetPasswordTokenTaskDisplayDriver.cs +++ b/Lombiq.HelpfulExtensions/Extensions/Workflows/Drivers/GenerateResetPasswordTokenTaskDisplayDriver.cs @@ -26,8 +26,7 @@ protected override void EditActivity(GenerateResetPasswordTokenTask activity, Ge public override async Task UpdateAsync(GenerateResetPasswordTokenTask activity, UpdateEditorContext context) { - var viewModel = new GenerateResetPasswordTokenTaskViewModel(); - await context.Updater.TryUpdateModelAsync(viewModel, Prefix); + var viewModel = await context.CreateModelAsync(Prefix); activity.User = new(viewModel.UserExpression); activity.ResetPasswordTokenPropertyKey = viewModel.ResetPasswordTokenPropertyKey; From 5bb8abd46a5c82a6c2f24ef341045a1ffbd8b229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 7 Aug 2024 13:53:57 +0200 Subject: [PATCH 59/91] Update HL alpha version. --- Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index 646e8f5..0276d3c 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -56,7 +56,7 @@ - + From 6462de8a1308bbf586d2244e227c12bcac63ab71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 7 Aug 2024 14:49:04 +0200 Subject: [PATCH 60/91] Update UITT alpha version. --- .../Lombiq.HelpfulExtensions.Tests.UI.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.HelpfulExtensions.Tests.UI/Lombiq.HelpfulExtensions.Tests.UI.csproj b/Lombiq.HelpfulExtensions.Tests.UI/Lombiq.HelpfulExtensions.Tests.UI.csproj index 7f0b9f4..ff5f8d5 100644 --- a/Lombiq.HelpfulExtensions.Tests.UI/Lombiq.HelpfulExtensions.Tests.UI.csproj +++ b/Lombiq.HelpfulExtensions.Tests.UI/Lombiq.HelpfulExtensions.Tests.UI.csproj @@ -36,7 +36,7 @@ - + From ae783c18e7aa4c216e0fc78b6a2a0996a61882a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 7 Aug 2024 17:38:12 +0200 Subject: [PATCH 61/91] Update OC preview version. --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index 0276d3c..7362b0d 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -35,18 +35,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From b165ab3396eae3a68700b67e14943778401e9af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Thu, 8 Aug 2024 23:15:41 +0200 Subject: [PATCH 62/91] Update OC preview. --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index 7362b0d..6be8157 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -35,18 +35,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From b3575d61f364d482cb13176c683a738b6d1460ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Thu, 8 Aug 2024 23:23:53 +0200 Subject: [PATCH 63/91] Update new breaking changes. --- .../ContentSets/Drivers/ContentSetPartDisplayDriver.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Extensions/ContentSets/Drivers/ContentSetPartDisplayDriver.cs b/Lombiq.HelpfulExtensions/Extensions/ContentSets/Drivers/ContentSetPartDisplayDriver.cs index 53e9aeb..15668ea 100644 --- a/Lombiq.HelpfulExtensions/Extensions/ContentSets/Drivers/ContentSetPartDisplayDriver.cs +++ b/Lombiq.HelpfulExtensions/Extensions/ContentSets/Drivers/ContentSetPartDisplayDriver.cs @@ -7,7 +7,6 @@ using OrchardCore.ContentManagement.Display.ContentDisplay; using OrchardCore.ContentManagement.Display.Models; using OrchardCore.DisplayManagement.Handlers; -using OrchardCore.DisplayManagement.ModelBinding; using OrchardCore.DisplayManagement.Views; using OrchardCore.Entities; using System.Collections.Generic; @@ -65,10 +64,7 @@ public override IDisplayResult Edit(ContentSetPart part, BuildPartEditorContext context.IsNew)) .Location($"Parts:0%{context.TypePartDefinition.Name};0"); - public override async Task UpdateAsync( - ContentSetPart part, - IUpdateModel updater, - UpdatePartEditorContext context) + public override async Task UpdateAsync(ContentSetPart part, UpdatePartEditorContext context) { var viewModel = await context.CreateModelAsync(Prefix); From 7ba77b0a9f84dd0ef1b322e9d44febe7e3f6d2f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Fri, 9 Aug 2024 14:30:24 +0200 Subject: [PATCH 64/91] Update HL alpha version. --- Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index 6be8157..d7daed7 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -56,7 +56,7 @@ - + From 36795387bae76ee7116af7244654111d4d94b85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Fri, 9 Aug 2024 14:54:14 +0200 Subject: [PATCH 65/91] Update UITT alpha version. --- .../Lombiq.HelpfulExtensions.Tests.UI.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.HelpfulExtensions.Tests.UI/Lombiq.HelpfulExtensions.Tests.UI.csproj b/Lombiq.HelpfulExtensions.Tests.UI/Lombiq.HelpfulExtensions.Tests.UI.csproj index ff5f8d5..92935dd 100644 --- a/Lombiq.HelpfulExtensions.Tests.UI/Lombiq.HelpfulExtensions.Tests.UI.csproj +++ b/Lombiq.HelpfulExtensions.Tests.UI/Lombiq.HelpfulExtensions.Tests.UI.csproj @@ -36,7 +36,7 @@ - + From ebbdc4262f0ad71f48f2ce2ee60c072f72131c24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 13 Aug 2024 11:27:18 +0200 Subject: [PATCH 66/91] Update OC previews. --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index 945f7bd..be8b6ae 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -35,18 +35,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From 1d44a13901ef14c7b06b1f96b326f62e7b81c14a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sun, 18 Aug 2024 01:38:43 +0200 Subject: [PATCH 67/91] Update OC preview version. --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index f96fb68..f977e3c 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -35,18 +35,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From df635443db658eff9f4ff0f194dd3e81c22b1190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sun, 18 Aug 2024 01:56:45 +0200 Subject: [PATCH 68/91] Post OC update fixup. --- Lombiq.HelpfulExtensions/Views/ContentSetPart.MemberLink.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.HelpfulExtensions/Views/ContentSetPart.MemberLink.cshtml b/Lombiq.HelpfulExtensions/Views/ContentSetPart.MemberLink.cshtml index 7fc338b..aa371ff 100644 --- a/Lombiq.HelpfulExtensions/Views/ContentSetPart.MemberLink.cshtml +++ b/Lombiq.HelpfulExtensions/Views/ContentSetPart.MemberLink.cshtml @@ -13,7 +13,7 @@
  • @if (!string.IsNullOrEmpty(link.ContentItemId)) { - var url = Orchard.Action(controller => controller.Edit(link.ContentItemId, null)); + var url = Orchard.Action(controller => controller.Edit(link.ContentItemId)); @link.DisplayText From 8c395bb9271bef59126e4bf164220a60053a550e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 20 Aug 2024 12:32:18 +0200 Subject: [PATCH 69/91] Update OC preview version. --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index f977e3c..f288362 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -35,18 +35,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From 05acbfac65a3b64ecd6fb10a119bb384abdd6a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 20 Aug 2024 18:13:58 +0200 Subject: [PATCH 70/91] Update OC preview version. --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index d7daed7..c1c19ae 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -35,18 +35,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From 4cde7e2e3e91c36309b9ed64048981b77147f21c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 20 Aug 2024 19:22:32 +0200 Subject: [PATCH 71/91] Update after breaking change. --- Lombiq.HelpfulExtensions/Views/ContentSetPart.MemberLink.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.HelpfulExtensions/Views/ContentSetPart.MemberLink.cshtml b/Lombiq.HelpfulExtensions/Views/ContentSetPart.MemberLink.cshtml index 7fc338b..aa371ff 100644 --- a/Lombiq.HelpfulExtensions/Views/ContentSetPart.MemberLink.cshtml +++ b/Lombiq.HelpfulExtensions/Views/ContentSetPart.MemberLink.cshtml @@ -13,7 +13,7 @@
  • @if (!string.IsNullOrEmpty(link.ContentItemId)) { - var url = Orchard.Action(controller => controller.Edit(link.ContentItemId, null)); + var url = Orchard.Action(controller => controller.Edit(link.ContentItemId)); @link.DisplayText From 02726cf1853625f0c18779f382886ef9f2408413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 21 Aug 2024 00:47:48 +0200 Subject: [PATCH 72/91] Add Google Tag note in the readme. --- Readme.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Readme.md b/Readme.md index 66a3992..28b35c4 100644 --- a/Readme.md +++ b/Readme.md @@ -222,6 +222,12 @@ builder.WhenContentTypeEditor("BlogPost").RegisterFootScript(Lombiq.HelpfulExten builder.WhenContentTypeEditor("BlogPost").RegisterStylesheet(Lombiq.HelpfulExtensions.Constants.ResourceNames.TrumbowygHighlight); ``` +### Google Tag + +Adds a shape along with Razor and Liquid tag helpers for Google Analytics, using . + +You can use `` Razor tag helper in cshtml files or the `{% google_tag property_id: "...", cookie_domain: "auto" %}` parser tag in Liquid. + ## Contributing and support Bug reports, feature requests, comments, questions, code contributions and love letters are warmly welcome. You can send them to us via GitHub issues and pull requests. Please adhere to our [open-source guidelines](https://lombiq.com/open-source-guidelines) while doing so. From b303f772feee760ea9ab692a0a1ebd9f0b4558a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Wed, 21 Aug 2024 17:30:38 +0200 Subject: [PATCH 73/91] Grammar, formatting --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 28b35c4..625fe56 100644 --- a/Readme.md +++ b/Readme.md @@ -226,7 +226,7 @@ builder.WhenContentTypeEditor("BlogPost").RegisterStylesheet(Lombiq.HelpfulExten Adds a shape along with Razor and Liquid tag helpers for Google Analytics, using . -You can use `` Razor tag helper in cshtml files or the `{% google_tag property_id: "...", cookie_domain: "auto" %}` parser tag in Liquid. +You can use the `` Razor tag helper in _cshtml_ files or the `{% google_tag property_id: "...", cookie_domain: "auto" %}` parser tag in Liquid. ## Contributing and support From 28e4095c63e6a3f52ba1464879b1de0b0acf3c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Wed, 21 Aug 2024 17:49:35 +0200 Subject: [PATCH 74/91] MD formatting --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 625fe56..979ace5 100644 --- a/Readme.md +++ b/Readme.md @@ -226,7 +226,7 @@ builder.WhenContentTypeEditor("BlogPost").RegisterStylesheet(Lombiq.HelpfulExten Adds a shape along with Razor and Liquid tag helpers for Google Analytics, using . -You can use the `` Razor tag helper in _cshtml_ files or the `{% google_tag property_id: "...", cookie_domain: "auto" %}` parser tag in Liquid. +You can use the `` Razor tag helper in _cshtml_ files or the `{% google_tag property_id: "...", cookie_domain: "auto" %}` parser tag in Liquid. ## Contributing and support From 3088aef84a8569d24c74f1f17317b9ce6bb59093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 21 Aug 2024 17:57:59 +0200 Subject: [PATCH 75/91] Update OC preview version. --- .../Lombiq.HelpfulExtensions.csproj | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj index f288362..538347f 100644 --- a/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj +++ b/Lombiq.HelpfulExtensions/Lombiq.HelpfulExtensions.csproj @@ -35,18 +35,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From e13a2c2a4d740203c6a70065cd7a1de26594bf0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 21 Aug 2024 22:22:35 +0200 Subject: [PATCH 76/91] Simplify condition. --- Lombiq.HelpfulExtensions/Views/GoogleTag.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.HelpfulExtensions/Views/GoogleTag.cshtml b/Lombiq.HelpfulExtensions/Views/GoogleTag.cshtml index 684c69d..92ba245 100644 --- a/Lombiq.HelpfulExtensions/Views/GoogleTag.cshtml +++ b/Lombiq.HelpfulExtensions/Views/GoogleTag.cshtml @@ -11,7 +11,7 @@ var trackingConsentFeature = ViewContext.HttpContext.Features.Get(); } -@if (HostEnvironment.IsProduction() && (trackingConsentFeature is null || trackingConsentFeature.CanTrack)) +@if (HostEnvironment.IsProduction() && trackingConsentFeature is not { CanTrack: false }) { GoogleAnalyticsContentSecurityPolicyProvider.EnableForCurrentRequest(Context); From a3a68e6ff2e22a1ef7e0665f06315142a5c4e7e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 21 Aug 2024 23:20:17 +0200 Subject: [PATCH 77/91] Remove the at="Head" from GoogleTag. --- Lombiq.HelpfulExtensions/Views/GoogleTag.cshtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lombiq.HelpfulExtensions/Views/GoogleTag.cshtml b/Lombiq.HelpfulExtensions/Views/GoogleTag.cshtml index 92ba245..2d59261 100644 --- a/Lombiq.HelpfulExtensions/Views/GoogleTag.cshtml +++ b/Lombiq.HelpfulExtensions/Views/GoogleTag.cshtml @@ -27,8 +27,8 @@ cookieDomain = $", {{'cookie_domain': '{viewModel.CookieDomain}' }}"; } - - +