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

OCC-245: Update OC preview version and fix breaking changes #265

Merged
merged 66 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
ee33953
Update OC preview version.
sarahelsaig May 28, 2024
32a76f5
Fix breaking changes.
sarahelsaig May 28, 2024
ca1bf51
Gut obsolete class.
sarahelsaig May 30, 2024
e1520e9
Update OC preview version.
sarahelsaig May 30, 2024
598d327
Remove extension method because now OrchardCore.Abstractions has the …
sarahelsaig May 30, 2024
17d2374
Add NuGet.Config.
sarahelsaig Jun 3, 2024
5021758
Revert "Add NuGet.Config."
sarahelsaig Jun 3, 2024
e626beb
Update OC preview version.
sarahelsaig Jun 5, 2024
31bcc5e
Update after API change.
sarahelsaig Jun 5, 2024
655dbd7
Merge branch 'task/system-text-json-migration' into issue/OCC-245
sarahelsaig Jun 6, 2024
98c6f06
Merge branch 'task/system-text-json-migration' into issue/OCC-245
sarahelsaig Jun 6, 2024
db22445
Copy NuGet.config.
sarahelsaig Jun 6, 2024
ad32829
Tyy adding package source mapping too.
sarahelsaig Jun 6, 2024
43319a1
diagnostics
sarahelsaig Jun 6, 2024
324cf80
diagnostics
sarahelsaig Jun 6, 2024
1782b5b
also restore
sarahelsaig Jun 6, 2024
e58446d
more testing
sarahelsaig Jun 6, 2024
b985722
Revert nuget.config chages.
sarahelsaig Jun 6, 2024
b327d1a
Merge branch 'task/system-text-json-migration' into issue/OCC-245
sarahelsaig Jun 14, 2024
66ce87d
Copy NuGet.config from NEST.
sarahelsaig Jun 17, 2024
50d1347
Update OC version.
sarahelsaig Jun 18, 2024
d225f86
Update class after interface change.
sarahelsaig Jun 18, 2024
40eb6c7
Update OC version.
sarahelsaig Jun 19, 2024
f86de9a
LocalizedHtmlStringConverter is not needed.
sarahelsaig Jun 19, 2024
c1bfc94
Update OC preview version.
sarahelsaig Jun 20, 2024
0699806
Update OC preview version.
sarahelsaig Jun 21, 2024
a81eb67
Merge remote-tracking branch 'origin/issue/OCC-245' into issue/OCC-245
sarahelsaig Jun 21, 2024
f26e618
Remove LocalizedHtmlStringConverter reference.
sarahelsaig Jun 21, 2024
398a98a
spelling
sarahelsaig Jun 21, 2024
7140386
Remove unneeded test.
sarahelsaig Jun 24, 2024
ae1c83d
Switch publish action branch.
sarahelsaig Jun 24, 2024
71e7bb2
Disable add-source-link-package because it breaks dotnet restore.
sarahelsaig Jun 24, 2024
4d79620
Merge branch 'task/system-text-json-migration' into issue/OCC-245
sarahelsaig Jun 24, 2024
fd27f14
Update OC NuGet versions.
sarahelsaig Jun 24, 2024
b26be2a
Update to latest OC preview version.
sarahelsaig Jul 2, 2024
c0ee56a
Update OC preview version.
sarahelsaig Jul 11, 2024
f24bdc5
Merge remote-tracking branch 'origin/dev' into issue/OCC-245
sarahelsaig Jul 11, 2024
4458bec
Merge remote-tracking branch 'origin/task/system-text-json-migration'…
sarahelsaig Jul 12, 2024
a941653
Updating Refit to 7.1.2
Piedone Jul 13, 2024
4ef75ce
Merge remote-tracking branch 'origin/issue/OCC-245' into issue/OCORE-191
Piedone Jul 13, 2024
616a1ce
Update CreateModelMaybeAsync to return the viewmodel even if the TryU…
sarahelsaig Jul 14, 2024
69087bd
Use CreateModelMaybeAsync.
sarahelsaig Jul 14, 2024
e1ffcf2
Merge remote-tracking branch 'origin/issue/OCC-245' into issue/OCORE-191
Piedone Jul 14, 2024
e9e7da3
Merge pull request #275 from Lombiq/issue/OCORE-191
Piedone Jul 14, 2024
e296600
Add ConfigureAsync support to InlineStartup.
sarahelsaig Jul 16, 2024
f7436a6
Merge remote-tracking branch 'origin/issue/OCC-245' into issue/OCC-245
sarahelsaig Jul 16, 2024
ef2b6ba
Make them nullable.
sarahelsaig Jul 16, 2024
da2f829
Add PrepareShapeTable.
sarahelsaig Jul 16, 2024
6462b48
Add Cloudsmith badge
sarahelsaig Jul 16, 2024
97661f1
This is not actually helpful.
sarahelsaig Jul 16, 2024
f304eb9
Update Readme.md
sarahelsaig Jul 16, 2024
67adcf7
Update OC preview versions.
sarahelsaig Jul 24, 2024
d71255b
Merge branch 'task/system-text-json-migration' into issue/OCC-245
sarahelsaig Jul 24, 2024
c5899d3
Mark ConfigureSmtpSettings obsolete.
sarahelsaig Jul 26, 2024
9c78566
Add tags-ignore.
sarahelsaig Jul 27, 2024
080b03f
Try a different way.
sarahelsaig Jul 27, 2024
131b5fb
Use if condition instead.
sarahelsaig Jul 27, 2024
c8881a8
Use issue branch in publish-nuget.yml too.
sarahelsaig Jul 27, 2024
d23b078
Update UITT version.
sarahelsaig Jul 27, 2024
8ab13ea
NuGet.config
sarahelsaig Jul 27, 2024
7de5784
Obsolete CreateAdHocShape.
sarahelsaig Jul 27, 2024
b341fc1
Try fixing it for real.
sarahelsaig Jul 27, 2024
039f062
Fix ScriptModuleResourceFilter finally.
sarahelsaig Jul 27, 2024
5359efa
Add HttpRequestInfo.
sarahelsaig Jul 28, 2024
923d3f0
Update .github/workflows/publish-nuget.yml
sarahelsaig Jul 28, 2024
b7e6247
Make ShapeTables created by PerTenantShapeTableManager frozen
sarahelsaig Jul 28, 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 .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

jobs:
publish-nuget:
if: ${{ !contains(github.ref_name, '-preview.') }}
uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@dev
secrets:
API_KEY: ${{ secrets.DEFAULT_NUGET_PUBLISH_API_KEY }}

This file was deleted.

37 changes: 37 additions & 0 deletions Lombiq.HelpfulLibraries.AspNetCore/Mvc/HttpRequestInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#nullable enable

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
using System.Collections.Generic;
using System.Text.Json;

namespace Lombiq.HelpfulLibraries.AspNetCore.Mvc;

/// <summary>
/// A simplified intermediate type that can be used to debug <see cref="HttpRequest"/>.
/// </summary>
public record HttpRequestInfo(
string Url,
string? ContentType,
IHeaderDictionary Headers,
IDictionary<string, string> Form,
IRequestCookieCollection Cookies)
{
public HttpRequestInfo(HttpRequest request)
: this(
request.GetDisplayUrl(),
request.ContentType,
request.Headers,
request.HasFormContentType ?
request.Form.ToDictionaryIgnoreCase(pair => pair.Key, pair => pair.Value.ToString()) :
new Dictionary<string, string>(),
request.Cookies)
{
}

public override string ToString() => $"HTTP Request at \"{Url}\"";

public string ToJson() => JsonSerializer.Serialize(this);

public static string? ToJson(HttpRequest? request) => request == null ? null : new HttpRequestInfo(request).ToJson();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

<ItemGroup>
<PackageReference Include="linq2db" Version="5.4.0" />
<PackageReference Include="OrchardCore.Data.YesSql" Version="2.0.0-preview-18200" />
<PackageReference Include="OrchardCore.Data.YesSql" Version="2.0.0-preview-18282" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
using System;
using OrchardCore.DisplayManagement.Entities;
using System;
using System.Threading.Tasks;

namespace OrchardCore.DisplayManagement.Handlers;

public static class BuildEditorContextExtensions
{
public static async Task<T> CreateModelMaybeAsync<T>(
/// <summary>
/// Creates a new instance of <typeparamref name="TViewModel"/> and tries to populate it from the <paramref
/// name="context"/> with the <paramref name="prefix"/>.
/// </summary>
/// <param name="context">The editor context of the current update request.</param>
/// <param name="prefix">The name prefix of the fields being edited.</param>
/// <param name="groupId">
/// If not <see langword="null"/>, it's needed to check the group (e.g. in <see
/// cref="SectionDisplayDriver{TModel,TSection}"/>. The value is checked against the <see
/// cref="BuildShapeContext.GroupId"/> and if they don't match <see langword="null"/> is returned.
/// </param>
/// <param name="authorizeAsync">
/// If not <see langword="null"/> and the awaited result is <see langword="false"/>, then <see langword="null"/> is
/// returned.
/// </param>
/// <typeparam name="TViewModel">The expected view-model type.</typeparam>
/// <returns>
/// A new instance of <typeparamref name="TViewModel"/>, populated with data from <paramref name="context"/>. Unless
/// at least one of <paramref name="groupId"/> and <paramref name="authorizeAsync"/> are provided and the checks
/// failed, at which case <see langword="null"/> is returned.
/// </returns>
public static async Task<TViewModel> CreateModelMaybeAsync<TViewModel>(
this BuildEditorContext context,
string prefix,
string groupId = null,
Func<Task<bool>> authorizeAsync = null)
where T : class, new()
where TViewModel : class, new()
{
if (!string.IsNullOrEmpty(groupId) && context.GroupId != groupId) return null;

Expand All @@ -19,9 +41,8 @@ public static async Task<T> CreateModelMaybeAsync<T>(
return null;
}

var viewModel = new T();
return await context.Updater.TryUpdateModelAsync(viewModel, prefix)
? viewModel
: null;
var viewModel = new TViewModel();
await context.Updater.TryUpdateModelAsync(viewModel, prefix);
return viewModel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static Task<ContentItem> GetContentItemOrPreviewAsync(

if (httpContext.Request.Method == "POST")
{
var previewContentItemId = httpContext.Request.Form["PreviewContentItemId"];
var previewContentItemId = httpContext.Request.Form["PreviewContentItemId"].ToString();
if (!string.IsNullOrEmpty(previewContentItemId))
{
return httpContext.RequestServices.GetService<IContentManager>().GetAsync(previewContentItemId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ await AuthorizeAsync()

public override async Task<IDisplayResult> UpdateAsync(TSection section, UpdateEditorContext context)
{
var viewModel = new JsonViewModel<TAdditionalData>();

if (context.GroupId == GroupId &&
await AuthorizeAsync() &&
await context.Updater.TryUpdateModelAsync(viewModel, Prefix) &&
if (await context.CreateModelMaybeAsync<JsonViewModel<TAdditionalData>>(Prefix, GroupId, AuthorizeAsync) is { } viewModel &&
TryParseJson(viewModel.Json, out var result))
{
await UpdateAsync(section, context, result);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using Microsoft.AspNetCore.Builder;
#nullable enable

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Modules;
using System;
using System.Threading.Tasks;

namespace Lombiq.HelpfulLibraries.OrchardCore.DependencyInjection;

Expand All @@ -11,33 +14,39 @@ namespace Lombiq.HelpfulLibraries.OrchardCore.DependencyInjection;
/// </summary>
public class InlineStartup : StartupBase
{
private readonly Action<IServiceCollection> _configureServices;
private readonly Action<IApplicationBuilder, IEndpointRouteBuilder, IServiceProvider> _configure;
private readonly int _order;
private readonly Action<IServiceCollection>? _configureServices;
private readonly Action<IApplicationBuilder, IEndpointRouteBuilder, IServiceProvider>? _configure;
private readonly Func<IApplicationBuilder, IEndpointRouteBuilder, IServiceProvider, ValueTask>? _configureAsync;

public override int Order => _order;
public override int Order { get; }

public InlineStartup(
Action<IServiceCollection> configureServices,
Action<IServiceCollection>? configureServices,
Action<IApplicationBuilder> configure,
Func<IApplicationBuilder, IEndpointRouteBuilder, IServiceProvider, ValueTask>? configureAsync = null,
int order = 0)
: this(configureServices, (app, _, _) => configure(app), order)
: this(configureServices, (app, _, _) => configure(app), configureAsync, order)
{
}

public InlineStartup(
Action<IServiceCollection> configureServices,
Action<IApplicationBuilder, IEndpointRouteBuilder, IServiceProvider> configure = null,
Action<IServiceCollection>? configureServices = null,
Action<IApplicationBuilder, IEndpointRouteBuilder, IServiceProvider>? configure = null,
Func<IApplicationBuilder, IEndpointRouteBuilder, IServiceProvider, ValueTask>? configureAsync = null,
int order = 0)
{
_configureServices = configureServices;
_configure = configure;
_order = order;
_configureAsync = configureAsync;
Order = order;
}

public override void ConfigureServices(IServiceCollection services) =>
_configureServices?.Invoke(services);

public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider) =>
_configure?.Invoke(app, routes, serviceProvider);

public override ValueTask ConfigureAsync(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider) =>
_configureAsync?.Invoke(app, routes, serviceProvider) ?? ValueTask.CompletedTask;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#nullable enable

using Lombiq.HelpfulLibraries.Common.DependencyInjection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using OrchardCore.Modules;
using System;
using System.Threading.Tasks;

namespace Lombiq.HelpfulLibraries.OrchardCore.DependencyInjection;

Expand All @@ -26,19 +29,21 @@ public static void AddOrchardServices(this IServiceCollection services)
/// </summary>
public static IServiceCollection AddInlineStartup(
this IServiceCollection services,
Action<IServiceCollection> configureServices,
Action<IApplicationBuilder, IEndpointRouteBuilder, IServiceProvider> configure,
Action<IServiceCollection>? configureServices = null,
Action<IApplicationBuilder, IEndpointRouteBuilder, IServiceProvider>? configure = null,
Func<IApplicationBuilder, IEndpointRouteBuilder, IServiceProvider, ValueTask>? configureAsync = null,
int order = 0) =>
services.AddSingleton<IStartup>(new InlineStartup(configureServices, configure, order));
services.AddSingleton<IStartup>(new InlineStartup(configureServices, configure, configureAsync, order));

/// <summary>
/// Creates a new <see cref="InlineStartup"/> instance using the provided parameters, and adds it to the service
/// collection.
/// </summary>
public static IServiceCollection AddInlineStartup(
this IServiceCollection services,
Action<IServiceCollection> configureServices,
Action<IServiceCollection>? configureServices,
Action<IApplicationBuilder> configure,
Func<IApplicationBuilder, IEndpointRouteBuilder, IServiceProvider, ValueTask>? configureAsync = null,
int order = 0) =>
services.AddSingleton<IStartup>(new InlineStartup(configureServices, configure, order));
services.AddSingleton<IStartup>(new InlineStartup(configureServices, configure, configureAsync, order));
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using OrchardCore.Email;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.ResourceManagement;
using System;

namespace Microsoft.Extensions.DependencyInjection;

Expand Down Expand Up @@ -29,6 +30,7 @@ public static OrchardCoreBuilder AddDatabaseShellsConfigurationIfAvailable(
/// If set to <see langword="true"/> the settings coming from the configuration provider will override the ones set
/// up from the admin UI.
/// </param>
[Obsolete("The email configuration has changed in OC 2.0, see https://docs.orchardcore.net/en/latest/releases/2.0.0/#email-module.")]
public static OrchardCoreBuilder ConfigureSmtpSettings(
this OrchardCoreBuilder builder,
bool overrideAdminSettings = true)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using OrchardCore.ContentManagement.GraphQL.Queries;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using YesSql.Indexes;

namespace Lombiq.HelpfulLibraries.OrchardCore.GraphQL;
Expand All @@ -13,7 +14,7 @@ namespace Lombiq.HelpfulLibraries.OrchardCore.GraphQL;
public class PartIndexAliasProvider<TIndex> : IIndexAliasProvider
where TIndex : class, IIndex
{
private static readonly IndexAlias[] _aliases =
private static readonly IEnumerable<IndexAlias> _aliases =
[
new()
{
Expand All @@ -29,5 +30,5 @@ public class PartIndexAliasProvider<TIndex> : IIndexAliasProvider
/// <summary>
/// Gets indexes with a name ending in <c>PartIndex</c>.
/// </summary>
public IEnumerable<IndexAlias> GetAliases() => _aliases;
public ValueTask<IEnumerable<IndexAlias>> GetAliasesAsync() => ValueTask.FromResult(_aliases);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public TotalOfContentTypeBuilder(IStringLocalizer<TotalOfContentTypeBuilder> str
/// <param name="contentItemType">
/// The content item type to be extended with the <c>totalOfContentType</c> integer field.
/// </param>
public void Build(FieldType contentQuery, ContentTypeDefinition contentTypeDefinition, ContentItemType contentItemType)
public void Build(ISchema schema, FieldType contentQuery, ContentTypeDefinition contentTypeDefinition, ContentItemType contentItemType)
{
var name = contentTypeDefinition.Name;

Expand Down
Loading