Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-818: Upgrade to Orchard Core 2.0 #169

Merged
merged 105 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 98 commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
6e60e2e
Update NuGet versions to pre-release.
sarahelsaig Feb 22, 2024
8d251dc
Merge remote-tracking branch 'origin/dev' into issue/OSOE-795
sarahelsaig Feb 22, 2024
fc8bb6b
Remove "using Newtonsoft.Json"
sarahelsaig Feb 24, 2024
0e0d7c6
Use naming strategy.
sarahelsaig Feb 24, 2024
83afa77
Fix compilation errors.
sarahelsaig Feb 24, 2024
23f1f79
Replace JsonConvert.SerializeObject.
sarahelsaig Feb 24, 2024
dd79c82
Clarify SuppressMessage Justification.
sarahelsaig Feb 25, 2024
9f271ff
Fix OrderByColumn.
sarahelsaig Feb 25, 2024
f260ace
Simplify OrderByColumn.Selector.
sarahelsaig Feb 25, 2024
865e77f
Clean up unit test.
sarahelsaig Feb 25, 2024
b5c4d19
Make result mismatches clearer by only comparing the final matrix.
sarahelsaig Feb 25, 2024
3b7ff13
Sort numbers numerically.
sarahelsaig Feb 25, 2024
5d45583
More cleanup.
sarahelsaig Feb 25, 2024
53445f5
Fix newly introduced mistake.
sarahelsaig Feb 25, 2024
bcb0ebd
Add HasTypeProperty extension method.
sarahelsaig Feb 25, 2024
371f76e
Fix broken DateTime conversion during tests and broken mixed type num…
sarahelsaig Feb 25, 2024
0109937
Fix warnings
sarahelsaig Feb 25, 2024
7e6019c
unusing
sarahelsaig Feb 25, 2024
b8f1cf6
Fix data table request serialization.
sarahelsaig Feb 26, 2024
9126e1f
Fix JsonExtensionData related problems.
sarahelsaig Feb 26, 2024
2bdcdc5
Code cleanup in Lombiq.DataTable.cshtml
sarahelsaig Feb 26, 2024
9a7ce3a
View bug fix.
sarahelsaig Feb 26, 2024
3ca9a63
Unusing.
sarahelsaig Feb 26, 2024
1c1f758
Code cleanup.
sarahelsaig Feb 26, 2024
c6006d4
Add missing using.
sarahelsaig Feb 26, 2024
b8967e1
Update OC to latest (because of bug fix for WorkflowTypeStep)
sarahelsaig Mar 3, 2024
3a53d30
Update OC preview version.
sarahelsaig Mar 7, 2024
5f58178
Update OC package
sarahelsaig Mar 13, 2024
06a84d2
Replace AdminRouteAttribute with AdminAttribute.
sarahelsaig Mar 18, 2024
da4fa13
Use JObject.FromObject instead of JsonSerializer.SerializeToNode wher…
sarahelsaig Apr 2, 2024
013408f
Update OC preview version.
sarahelsaig Apr 23, 2024
ecbad33
Update OC package version.
sarahelsaig Apr 27, 2024
9c42051
Update OC versions
sarahelsaig May 4, 2024
6f68666
Update OC to the latest preview.
sarahelsaig May 7, 2024
5a47856
Update Lombiq.DataTables/Models/VueModel.cs
sarahelsaig May 12, 2024
18aef9f
Update Lombiq.DataTables/Tests/Lombiq.DataTables.Tests/MockDataProvid…
sarahelsaig May 12, 2024
0d0ec50
Update Lombiq.DataTables/Extensions/JsonNodeExtensions.cs
sarahelsaig May 12, 2024
80e1773
Rename HasTypeProperty to HasMatchingTypeProperty
sarahelsaig May 12, 2024
9384469
Get rid of `[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonK…
sarahelsaig May 12, 2024
32f9db9
Merge pull request #159 from Lombiq/issue/OSOE-795
dministro May 15, 2024
fa9706c
merge
sarahelsaig May 16, 2024
efbd9a8
Fix consolidation.
sarahelsaig May 16, 2024
5e13d50
Merge pull request #161 from Lombiq/issue/OSOE-795
dministro May 16, 2024
bc80c3e
Merge remote-tracking branch 'origin/dev' into task/system-text-json-…
sarahelsaig May 28, 2024
dcff71f
Update OC preview version.
sarahelsaig May 28, 2024
36f1a55
Fix NotSupportedException saying "CFF2 Fonts are not currently suppor…
sarahelsaig May 28, 2024
21b2b04
Update OC preview version.
sarahelsaig May 30, 2024
c2e6aeb
Fix new "Obsolete" warnings.
sarahelsaig May 30, 2024
a91c9e0
Remove redundant attribute.
sarahelsaig May 31, 2024
5be21fe
Remove unused private field.
sarahelsaig May 31, 2024
d4824c7
Update OC preview version.
sarahelsaig Jun 5, 2024
322de4c
Merge remote-tracking branch 'origin/dev' into task/system-text-json-…
sarahelsaig Jun 14, 2024
ec39081
Merge branch 'task/system-text-json-migration' into issue/OCC-245
sarahelsaig Jun 14, 2024
49dae53
Fix error S6964.
sarahelsaig Jun 17, 2024
ebc9a31
Update OC version.
sarahelsaig Jun 18, 2024
22acd4f
Update OC version.
sarahelsaig Jun 19, 2024
4a1a2bd
Update OC preview version.
sarahelsaig Jun 21, 2024
685dfd0
Update OC preview version.
sarahelsaig Jul 11, 2024
f0556e5
Fix package consolidation.
sarahelsaig Jul 11, 2024
bb1c0aa
Update HL version.
sarahelsaig Jul 13, 2024
b3bb526
Update UITT version.
sarahelsaig Jul 13, 2024
ceb11bd
Update HL nuget version.
sarahelsaig Jul 16, 2024
9afcc49
Update all UITT Nuget versions.
sarahelsaig Jul 16, 2024
20c1ade
Update package version.
sarahelsaig Jul 16, 2024
6245483
Update OC preview versions.
sarahelsaig Jul 24, 2024
7d259dc
Merge remote-tracking branch 'origin/dev' into task/system-text-json-…
sarahelsaig Jul 24, 2024
04dbb26
Add *.orig to gitignore.
sarahelsaig Jul 24, 2024
fa7c86d
Merge branch 'task/system-text-json-migration' into issue/OCC-245
sarahelsaig Jul 24, 2024
6965145
Update HL preview version.
sarahelsaig Jul 26, 2024
e8c9064
Update UITT preview version.
sarahelsaig Jul 26, 2024
4416082
Update HL preview.
sarahelsaig Jul 27, 2024
71b8e73
Update UITT version.
sarahelsaig Jul 27, 2024
075be2c
Update UITT preview version.
sarahelsaig Jul 27, 2024
a51f18c
NuGet.config
sarahelsaig Jul 27, 2024
4cab9a0
wat
sarahelsaig Jul 27, 2024
90d9763
Revert "wat"
sarahelsaig Jul 27, 2024
06e9c74
Update HL nuget version.
sarahelsaig Jul 27, 2024
8ed428b
Update HL.
sarahelsaig Jul 27, 2024
4afb955
Merge pull request #165 from Lombiq/issue/OCC-245
Piedone Jul 28, 2024
e2f3e25
Update OC preview version.
sarahelsaig Jul 29, 2024
5fb53c6
Update OC preview versions.
sarahelsaig Jul 30, 2024
18cec95
Update OC preview version.
sarahelsaig Aug 6, 2024
dd7ecd5
Update HL alpha version.
sarahelsaig Aug 7, 2024
cf230e4
Update UITT alpha version.
sarahelsaig Aug 7, 2024
ad5c92d
wut
sarahelsaig Aug 7, 2024
0c36a80
Revert "wut"
sarahelsaig Aug 7, 2024
8ab5821
Update OC preview version.
sarahelsaig Aug 7, 2024
82d0f44
Update OC preview.
sarahelsaig Aug 8, 2024
a6c2aa7
Update HL alpha version.
sarahelsaig Aug 9, 2024
596aace
Update UITT alpha version.
sarahelsaig Aug 9, 2024
c1b0df6
Update OC preview version.
sarahelsaig Aug 20, 2024
107951e
Update OC
sarahelsaig Aug 21, 2024
2ff45e8
Update OC preview version.
sarahelsaig Aug 23, 2024
9bb62ae
Use OC release version.
sarahelsaig Sep 22, 2024
2199962
Update HL preview.
sarahelsaig Sep 23, 2024
a820b5c
Update HL.
sarahelsaig Sep 23, 2024
63b00cc
Temp commit.
sarahelsaig Sep 23, 2024
227b172
Revert "Temp commit."
sarahelsaig Sep 23, 2024
07fb499
Use AddNavigationProvider everywhere.
sarahelsaig Sep 24, 2024
713938b
Make migrations and background tasks sealed.
sarahelsaig Sep 24, 2024
4ac4faf
Seal INavigationProvider, IAsyncResultFilter, IPermissionProvider, St…
sarahelsaig Sep 24, 2024
36e4397
Update HL NuGet version.
sarahelsaig Sep 25, 2024
ea9d13a
Update UITT version.
sarahelsaig Sep 25, 2024
192fb06
why
sarahelsaig Sep 25, 2024
56266ce
Revert "why"
sarahelsaig Sep 25, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ wwwroot/
node_modules/
*.user
.pnpm-debug.log
*.orig
4 changes: 2 additions & 2 deletions Lombiq.DataTables.Samples/Lombiq.DataTables.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.ContentFields" Version="1.8.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.8.0" />
<PackageReference Include="OrchardCore.ContentFields" Version="2.0.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 5 additions & 7 deletions Lombiq.DataTables/Controllers/Api/RowsController.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Lombiq.DataTables.Models;
using Lombiq.DataTables.Services;
using Lombiq.HelpfulLibraries.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Localization;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -32,7 +32,7 @@ public RowsController(
/// <summary>
/// Gets the current table view's rows.
/// </summary>
/// <param name="requestJson">The request to fulfill serialized as JSON.</param>
/// <param name="request">The request to fulfill serialized as JSON.</param>
/// <returns>The response for this API call.</returns>
/// <remarks>
/// <list type="bullet">
Expand All @@ -53,12 +53,11 @@ public RowsController(
/// </remarks>
[IgnoreAntiforgeryToken]
[HttpGet]
public async Task<ActionResult<DataTableDataResponse>> Get(string requestJson)
public async Task<ActionResult<DataTableDataResponse>> Get([FromJsonQueryString(Name = "requestJson")] DataTableDataRequest request)
{
if (string.IsNullOrEmpty(requestJson)) ModelState.AddModelError(nameof(requestJson), "Controller parameter is missing.");
if (request == null) return BadRequest();
if (!ModelState.IsValid) return BadRequest(ModelState);

var request = JsonConvert.DeserializeObject<DataTableDataRequest>(requestJson);
var dataProvider = _dataTableDataProviderAccessor.GetDataProvider(request.DataProvider);
if (dataProvider == null)
{
Expand Down Expand Up @@ -87,13 +86,12 @@ public async Task<ActionResult<DataTableDataResponse>> Get(string requestJson)
}

public async Task<ActionResult<DataTableDataResponse>> Export(
string requestJson,
[FromJsonQueryString(Name = "requestJson")] DataTableDataRequest request,
string name = null,
bool exportAll = true)
{
if (!ModelState.IsValid) return BadRequest(ModelState);

var request = JsonConvert.DeserializeObject<DataTableDataRequest>(requestJson);
if (exportAll)
{
request.Start = 0;
Expand Down
10 changes: 5 additions & 5 deletions Lombiq.DataTables/Controllers/TableController.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
using Lombiq.DataTables.Services;
using Lombiq.DataTables.ViewModels;
using Lombiq.HelpfulLibraries.OrchardCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using OrchardCore.Admin;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Nodes;
using System.Threading.Tasks;

namespace Lombiq.DataTables.Controllers;

[Admin]
public class TableController : Controller
{
private readonly IEnumerable<IDataTableDataProvider> _dataTableDataProviders;

public TableController(IEnumerable<IDataTableDataProvider> dataTableDataProviders) =>
_dataTableDataProviders = dataTableDataProviders;

[AdminRoute("DataTable/{providerName}/{queryId?}")]
[Admin("DataTable/{providerName}/{queryId?}")]
public async Task<IActionResult> Get(string providerName, string queryId = null, bool paging = true, bool viewAction = false)
{
if (!ModelState.IsValid) return BadRequest(ModelState);

var provider = _dataTableDataProviders.Single(provider => provider.Name == providerName);
if (string.IsNullOrEmpty(queryId)) queryId = providerName;
var definition = new DataTableDefinitionViewModel(JObject.FromObject(new { paging, viewAction }))

var additionalDatatableOptions = JObject.FromObject(new { paging, viewAction })!.AsObject();
var definition = new DataTableDefinitionViewModel(additionalDatatableOptions)
{
DataProvider = providerName,
QueryId = queryId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Localization;
using Newtonsoft.Json;
using OrchardCore.Mvc.Core.Utilities;
using OrchardCore.Security.Permissions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text.Json;
using System.Threading.Tasks;
using static Lombiq.DataTables.Constants.SortingDirection;

Expand Down Expand Up @@ -167,7 +167,7 @@ public static string GetCustomActionsJson(
IHttpContextAccessor hca,
LinkGenerator linkGenerator,
IStringLocalizer<ActionsDescriptor> actionsStringLocalizer) =>
JsonConvert.SerializeObject(GetCustomActions(
JsonSerializer.Serialize(GetCustomActions(
dataProvider,
contentItemId,
canDelete,
Expand Down
11 changes: 11 additions & 0 deletions Lombiq.DataTables/Extensions/JsonNodeExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace System.Text.Json.Nodes;

public static class JsonNodeExtensions
{
/// <summary>
/// Checks if the provided <paramref name="node"/> is object and has a <c>Type</c> property, and if its value
/// matches <typeparamref name="T"/>.
/// </summary>
public static bool HasMatchingTypeProperty<T>(this JsonNode node) =>
node is JsonObject jsonObject && jsonObject["Type"]?.ToString() == typeof(T).Name;
}
4 changes: 2 additions & 2 deletions Lombiq.DataTables/Liquid/ActionsLiquidFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Localization;
using Newtonsoft.Json.Linq;
using OrchardCore.ContentManagement;
using OrchardCore.DisplayManagement;
using OrchardCore.Liquid;
using System;
using System.IO;
using System.Text.Encodings.Web;
using System.Text.Json.Nodes;
using System.Threading.Tasks;

namespace Lombiq.DataTables.Liquid;
Expand Down Expand Up @@ -71,7 +71,7 @@ public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments argu
FluidValues.Object => input!.ToObjectValue() switch
{
ActionsDescriptor model => FromObjectAsync(model, title, returnUrl),
JToken jToken => FromObjectAsync(jToken.ToObject<ActionsDescriptor>(), title, returnUrl),
JsonNode jsonNode => FromObjectAsync(jsonNode.ToObject<ActionsDescriptor>(), title, returnUrl),
{ } unknown => throw GetException(unknown),
_ => throw new ArgumentNullException(nameof(input)),
},
Expand Down
11 changes: 5 additions & 6 deletions Lombiq.DataTables/Lombiq.DataTables.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@

<ItemGroup>
<PackageReference Include="ClosedXML" Version="0.102.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Nito.AsyncEx.Tasks" Version="5.1.2" />
<PackageReference Include="OrchardCore.Contents" Version="1.8.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.8.0" />
<PackageReference Include="OrchardCore.Search.Lucene" Version="1.8.0" />
<PackageReference Include="OrchardCore.Contents" Version="2.0.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="2.0.0" />
<PackageReference Include="OrchardCore.Search.Lucene" Version="2.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' != 'true'">
Expand All @@ -52,8 +51,8 @@
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="10.0.0" />
<PackageReference Include="Lombiq.HelpfulLibraries.LinqToDb" Version="10.0.0" />
<PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="10.0.1-alpha.8.osoe-818" />
<PackageReference Include="Lombiq.HelpfulLibraries.LinqToDb" Version="10.0.1-alpha.8.osoe-818" />
<PackageReference Include="Lombiq.NodeJs.Extensions" Version="2.1.0" />
</ItemGroup>

Expand Down
7 changes: 4 additions & 3 deletions Lombiq.DataTables/Models/DataTableChildRowResponse.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Text.Json.Serialization;

namespace Lombiq.DataTables.Models;

[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class DataTableChildRowResponse
{
[JsonPropertyName("error")]
public string Error { get; set; }

[JsonPropertyName("content")]
public string Content { get; set; }

public static DataTableChildRowResponse ErrorResult(string errorText) => new() { Error = errorText };
Expand Down
13 changes: 10 additions & 3 deletions Lombiq.DataTables/Models/DataTableColumn.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Text.Json.Serialization;

namespace Lombiq.DataTables.Models;

[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class DataTableColumn
{
[JsonPropertyName("data")]
public string Data { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("searchable")]
public bool Searchable { get; set; }

[JsonPropertyName("orderable")]
public bool Orderable { get; set; }

[JsonPropertyName("search")]
public DataTableSearchParameters Search { get; set; }
}
14 changes: 11 additions & 3 deletions Lombiq.DataTables/Models/DataTableDataRequest.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;

namespace Lombiq.DataTables.Models;

[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class DataTableDataRequest
{
public string QueryId { get; set; }

public string DataProvider { get; set; }

[JsonRequired]
public int Draw { get; set; }

[JsonRequired]
public int Start { get; set; }

[JsonRequired]
public int Length { get; set; }

public IEnumerable<DataTableColumn> ColumnFilters { get; set; }

public DataTableSearchParameters Search { get; set; }

public IEnumerable<DataTableOrder> Order { get; set; }

public bool HasSearch => !string.IsNullOrWhiteSpace(Search?.Value);
Expand Down
11 changes: 7 additions & 4 deletions Lombiq.DataTables/Models/DataTableDataResponse.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace Lombiq.DataTables.Models;

[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class DataTableDataResponse
{
/// <summary>
Expand All @@ -14,28 +12,33 @@ public class DataTableDataResponse
/// <remarks>
/// <para>For internal use only. It's overwritten during normal use.</para>
/// </remarks>
[JsonProperty]
[JsonPropertyName("draw")]
[JsonInclude]
internal int Draw { get; set; }

/// <summary>
/// Gets or sets the extra informational field that shows the actual total if filtering (such as keyword
/// search) is used. When not filtering it must be the same as <see cref="RecordsFiltered"/>.
/// </summary>
[JsonPropertyName("recordsTotal")]
public int RecordsTotal { get; set; }

/// <summary>
/// Gets or sets the total number of results; used for paging.
/// </summary>
[JsonPropertyName("recordsFiltered")]
public int RecordsFiltered { get; set; }

/// <summary>
/// Gets or sets the table contents of the current page.
/// </summary>
[JsonPropertyName("data")]
public IEnumerable<DataTableRow> Data { get; set; }

/// <summary>
/// Gets or sets the user-facing error message in case something went wrong.
/// </summary>
[JsonPropertyName("error")]
public string Error { get; set; }

/// <summary>
Expand Down
16 changes: 13 additions & 3 deletions Lombiq.DataTables/Models/DataTableOrder.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
using Lombiq.DataTables.Constants;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;

namespace Lombiq.DataTables.Models;

[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class DataTableOrder
{
public string Column { get; set; }

[JsonIgnore]
public SortingDirection Direction { get; set; }

[JsonPropertyName("direction")]
[JsonInclude]
[SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "It's used for JSON conversion.")]
private string DirectionString
{
get => IsAscending ? "ascending" : "descending";
set => Direction = value == "descending" ? SortingDirection.Descending : SortingDirection.Ascending;
}

[JsonIgnore]
public bool IsAscending => Direction == SortingDirection.Ascending;
}
Loading