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

Add a way to queue releasing shell context from setting display drivers #15875

Merged
merged 26 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d2d2668
Add a way to queue releasing shell cotext from dite drivers
MikeAlhayek Apr 25, 2024
49b1ad4
cleanup
MikeAlhayek Apr 25, 2024
11f7cf2
Merge branch 'main' into ma/queue-release-settings
MikeAlhayek Apr 25, 2024
6a99ac9
remove a change
MikeAlhayek Apr 25, 2024
57eb99c
Merge branch 'ma/queue-release-settings' of https://github.com/Orchar…
MikeAlhayek Apr 25, 2024
42250f3
made ShellSettingsReleaseRequest more global
MikeAlhayek Apr 26, 2024
3b155b3
undo some changes
MikeAlhayek Apr 26, 2024
6c3b896
Update src/docs/releases/1.9.0.md
MikeAlhayek Apr 26, 2024
f4fe7ee
update docs
MikeAlhayek Apr 26, 2024
5d77f76
fix conflict
MikeAlhayek Apr 26, 2024
1c947ac
cleanup
MikeAlhayek Apr 26, 2024
c3b5e5e
use IShellContextReleaseService instead of HttpContext
MikeAlhayek Apr 28, 2024
43a7049
Fix service registration
MikeAlhayek Apr 28, 2024
75fcd45
Update src/docs/releases/1.9.0.md
MikeAlhayek Apr 28, 2024
ad8c41b
Merge branch 'main' into ma/queue-release-settings
MikeAlhayek Apr 29, 2024
6ed9918
cleanup
MikeAlhayek Apr 29, 2024
a183650
Merge branch 'main' into ma/queue-release-settings
MikeAlhayek Apr 29, 2024
78b0a0f
Update src/OrchardCore/OrchardCore/Shell/ShellContextReleaseService.cs
MikeAlhayek Apr 29, 2024
32ed4d9
Update src/OrchardCore/OrchardCore/ShellSettingsReleaseFilter.cs
MikeAlhayek Apr 29, 2024
31a509d
Drop the filter and rename IDeferredShellContextReleaseService
MikeAlhayek Apr 29, 2024
c61ea3d
update docs
MikeAlhayek Apr 29, 2024
19fca82
Merge branch 'main' into ma/queue-release-settings
MikeAlhayek Apr 29, 2024
fed8a44
call AddDeferredTask from the service
MikeAlhayek Apr 30, 2024
8790360
update docs
MikeAlhayek Apr 30, 2024
04087a0
Rename IDeferredShellContextReleaseService to IShellReleaseManager
MikeAlhayek Apr 30, 2024
a2b75a5
Merge branch 'main' into ma/queue-release-settings
MikeAlhayek Apr 30, 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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using OrchardCore.Email.Core;
using OrchardCore.Email.Services;
using OrchardCore.Entities;
using OrchardCore.Environment.Shell;
using OrchardCore.Modules;
using OrchardCore.Mvc.ModelBinding;
using OrchardCore.Settings;
Expand All @@ -27,8 +26,6 @@ public class AzureEmailSettingsDisplayDriver : SectionDisplayDriver<ISite, Azure
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IAuthorizationService _authorizationService;
private readonly IDataProtectionProvider _dataProtectionProvider;
private readonly IShellHost _shellHost;
private readonly ShellSettings _shellSettings;
private readonly IEmailAddressValidator _emailValidator;

protected IStringLocalizer S;
Expand All @@ -37,16 +34,12 @@ public AzureEmailSettingsDisplayDriver(
IHttpContextAccessor httpContextAccessor,
IAuthorizationService authorizationService,
IDataProtectionProvider dataProtectionProvider,
IShellHost shellHost,
ShellSettings shellSettings,
IEmailAddressValidator emailValidator,
IStringLocalizer<AzureEmailSettingsDisplayDriver> stringLocalizer)
{
_httpContextAccessor = httpContextAccessor;
_authorizationService = authorizationService;
_dataProtectionProvider = dataProtectionProvider;
_shellHost = shellHost;
_shellSettings = shellSettings;
_emailValidator = emailValidator;
S = stringLocalizer;
}
Expand Down Expand Up @@ -150,8 +143,8 @@ public override async Task<IDisplayResult> UpdateAsync(ISite site, AzureEmailSet

if (hasChanges)
{
// Release the tenant to apply the settings when something changed.
await _shellHost.ReleaseShellContextAsync(_shellSettings);
// Queue reloading shell context when something changed.
site.QueueReleaseShellContext();
MikeAlhayek marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using OrchardCore.Email.Smtp.Services;
using OrchardCore.Email.Smtp.ViewModels;
using OrchardCore.Entities;
using OrchardCore.Environment.Shell;
using OrchardCore.Modules;
using OrchardCore.Mvc.ModelBinding;
using OrchardCore.Settings;
Expand All @@ -26,8 +25,6 @@ public class SmtpSettingsDisplayDriver : SectionDisplayDriver<ISite, SmtpSetting
public const string GroupId = EmailSettings.GroupId;

private readonly IDataProtectionProvider _dataProtectionProvider;
private readonly IShellHost _shellHost;
private readonly ShellSettings _shellSettings;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly SmtpOptions _smtpOptions;
private readonly IAuthorizationService _authorizationService;
Expand All @@ -37,17 +34,13 @@ public class SmtpSettingsDisplayDriver : SectionDisplayDriver<ISite, SmtpSetting

public SmtpSettingsDisplayDriver(
IDataProtectionProvider dataProtectionProvider,
IShellHost shellHost,
ShellSettings shellSettings,
IHttpContextAccessor httpContextAccessor,
IOptions<SmtpOptions> options,
IAuthorizationService authorizationService,
IEmailAddressValidator emailAddressValidator,
IStringLocalizer<SmtpSettingsDisplayDriver> stringLocalizer)
{
_dataProtectionProvider = dataProtectionProvider;
_shellHost = shellHost;
_shellSettings = shellSettings;
_httpContextAccessor = httpContextAccessor;
_smtpOptions = options.Value;
_authorizationService = authorizationService;
Expand Down Expand Up @@ -200,8 +193,8 @@ public override async Task<IDisplayResult> UpdateAsync(ISite site, SmtpSettings

if (hasChanges)
{
// Release the tenant to apply the settings when something changed.
await _shellHost.ReleaseShellContextAsync(_shellSettings);
// Queue reloading shell context when something changed.
site.QueueReleaseShellContext();
MikeAlhayek marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.Extensions.Options;
using OrchardCore.DisplayManagement.Entities;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Email.Core;
using OrchardCore.Email.Core.Services;
Expand Down Expand Up @@ -71,7 +72,7 @@ public override async Task<IDisplayResult> EditAsync(EmailSettings settings, Bui
.OnGroup(EmailSettings.GroupId);
}

public override async Task<IDisplayResult> UpdateAsync(EmailSettings settings, UpdateEditorContext context)
public override async Task<IDisplayResult> UpdateAsync(ISite site, EmailSettings settings, IUpdateModel updater, UpdateEditorContext context)
Piedone marked this conversation as resolved.
Show resolved Hide resolved
{
if (!context.GroupId.EqualsOrdinalIgnoreCase(EmailSettings.GroupId))
{
Expand All @@ -91,7 +92,7 @@ public override async Task<IDisplayResult> UpdateAsync(EmailSettings settings, U
{
settings.DefaultProviderName = model.DefaultProvider;

await _shellHost.ReleaseShellContextAsync(_shellSettings);
site.QueueReleaseShellContext();
}

return await EditAsync(settings, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using Microsoft.Extensions.Logging;
using OrchardCore.DisplayManagement.Entities;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Environment.Shell;
using OrchardCore.Facebook.Settings;
using OrchardCore.Facebook.ViewModels;
using OrchardCore.Settings;
Expand All @@ -19,24 +19,18 @@ public class FacebookSettingsDisplayDriver : SectionDisplayDriver<ISite, Faceboo
private readonly IAuthorizationService _authorizationService;
private readonly IDataProtectionProvider _dataProtectionProvider;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IShellHost _shellHost;
private readonly ShellSettings _shellSettings;
private readonly ILogger _logger;

public FacebookSettingsDisplayDriver(
IAuthorizationService authorizationService,
IDataProtectionProvider dataProtectionProvider,
IHttpContextAccessor httpContextAccessor,
IShellHost shellHost,
ShellSettings shellSettings,
ILogger<FacebookSettingsDisplayDriver> logger
)
{
_authorizationService = authorizationService;
_dataProtectionProvider = dataProtectionProvider;
_httpContextAccessor = httpContextAccessor;
_shellHost = shellHost;
_shellSettings = shellSettings;
_logger = logger;
}

Expand Down Expand Up @@ -73,7 +67,7 @@ public override async Task<IDisplayResult> EditAsync(FacebookSettings settings,
}).Location("Content:0").OnGroup(FacebookConstants.Features.Core);
}

public override async Task<IDisplayResult> UpdateAsync(FacebookSettings settings, UpdateEditorContext context)
public override async Task<IDisplayResult> UpdateAsync(ISite site, FacebookSettings settings, IUpdateModel updater, UpdateEditorContext context)
{
if (context.GroupId == FacebookConstants.Features.Core)
{
Expand All @@ -87,19 +81,23 @@ public override async Task<IDisplayResult> UpdateAsync(FacebookSettings settings
var model = new FacebookSettingsViewModel();
await context.Updater.TryUpdateModelAsync(model, Prefix);

settings.AppId = model.AppId;
settings.FBInit = model.FBInit;
settings.SdkJs = model.SdkJs;
settings.Version = model.Version;

if (!string.IsNullOrWhiteSpace(model.FBInitParams))
{
settings.FBInitParams = model.FBInitParams;
}

Piedone marked this conversation as resolved.
Show resolved Hide resolved
if (context.Updater.ModelState.IsValid)
{
var protector = _dataProtectionProvider.CreateProtector(FacebookConstants.Features.Core);
settings.AppId = model.AppId;
settings.AppSecret = protector.Protect(model.AppSecret);
settings.FBInit = model.FBInit;
settings.SdkJs = model.SdkJs;
if (!string.IsNullOrWhiteSpace(model.FBInitParams))
settings.FBInitParams = model.FBInitParams;
settings.Version = model.Version;

await _shellHost.ReleaseShellContextAsync(_shellSettings);
}

site.QueueReleaseShellContext();
}

return await EditAsync(settings, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using Microsoft.AspNetCore.Http;
using OrchardCore.DisplayManagement.Entities;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Environment.Shell;
using OrchardCore.Facebook.Login.Settings;
using OrchardCore.Facebook.Login.ViewModels;
using OrchardCore.Settings;
Expand All @@ -15,19 +15,13 @@ public class FacebookLoginSettingsDisplayDriver : SectionDisplayDriver<ISite, Fa
{
private readonly IAuthorizationService _authorizationService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IShellHost _shellHost;
private readonly ShellSettings _shellSettings;

public FacebookLoginSettingsDisplayDriver(
IAuthorizationService authorizationService,
IHttpContextAccessor httpContextAccessor,
IShellHost shellHost,
ShellSettings shellSettings)
IHttpContextAccessor httpContextAccessor)
{
_authorizationService = authorizationService;
_httpContextAccessor = httpContextAccessor;
_shellHost = shellHost;
_shellSettings = shellSettings;
}

public override async Task<IDisplayResult> EditAsync(FacebookLoginSettings settings, BuildEditorContext context)
Expand All @@ -45,7 +39,7 @@ public override async Task<IDisplayResult> EditAsync(FacebookLoginSettings setti
}).Location("Content:5").OnGroup(FacebookConstants.Features.Login);
}

public override async Task<IDisplayResult> UpdateAsync(FacebookLoginSettings settings, UpdateEditorContext context)
public override async Task<IDisplayResult> UpdateAsync(ISite site, FacebookLoginSettings settings, IUpdateModel updater, UpdateEditorContext context)
{
if (context.GroupId == FacebookConstants.Features.Login)
{
Expand All @@ -56,15 +50,15 @@ public override async Task<IDisplayResult> UpdateAsync(FacebookLoginSettings set
}

var model = new FacebookLoginSettingsViewModel();

await context.Updater.TryUpdateModelAsync(model, Prefix);

if (context.Updater.ModelState.IsValid)
{
settings.CallbackPath = model.CallbackPath;
settings.SaveTokens = model.SaveTokens;
await _shellHost.ReleaseShellContextAsync(_shellSettings);
}
settings.CallbackPath = model.CallbackPath;
settings.SaveTokens = model.SaveTokens;

site.QueueReleaseShellContext();
}

return await EditAsync(settings, context);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using Microsoft.Extensions.Logging;
using OrchardCore.DisplayManagement.Entities;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Environment.Shell;
using OrchardCore.GitHub.Settings;
using OrchardCore.GitHub.ViewModels;
using OrchardCore.Settings;
Expand All @@ -19,23 +19,17 @@ public class GitHubAuthenticationSettingsDisplayDriver : SectionDisplayDriver<IS
private readonly IAuthorizationService _authorizationService;
private readonly IDataProtectionProvider _dataProtectionProvider;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IShellHost _shellHost;
private readonly ShellSettings _shellSettings;
private readonly ILogger _logger;

public GitHubAuthenticationSettingsDisplayDriver(
IAuthorizationService authorizationService,
IDataProtectionProvider dataProtectionProvider,
IHttpContextAccessor httpContextAccessor,
IShellHost shellHost,
ShellSettings shellSettings,
ILogger<GitHubAuthenticationSettingsDisplayDriver> logger)
{
_authorizationService = authorizationService;
_dataProtectionProvider = dataProtectionProvider;
_httpContextAccessor = httpContextAccessor;
_shellHost = shellHost;
_shellSettings = shellSettings;
_logger = logger;
}

Expand Down Expand Up @@ -76,7 +70,7 @@ public override async Task<IDisplayResult> EditAsync(GitHubAuthenticationSetting
}).Location("Content:5").OnGroup(GitHubConstants.Features.GitHubAuthentication);
}

public override async Task<IDisplayResult> UpdateAsync(GitHubAuthenticationSettings settings, UpdateEditorContext context)
public override async Task<IDisplayResult> UpdateAsync(ISite site, GitHubAuthenticationSettings settings, IUpdateModel updater, UpdateEditorContext context)
{
if (context.GroupId == GitHubConstants.Features.GitHubAuthentication)
{
Expand All @@ -97,9 +91,11 @@ public override async Task<IDisplayResult> UpdateAsync(GitHubAuthenticationSetti
settings.ClientSecret = protector.Protect(model.ClientSecret);
settings.CallbackPath = model.CallbackUrl;
settings.SaveTokens = model.SaveTokens;
await _shellHost.ReleaseShellContextAsync(_shellSettings);

site.QueueReleaseShellContext();
}
}

return await EditAsync(settings, context);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using Microsoft.Extensions.Logging;
using OrchardCore.DisplayManagement.Entities;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Environment.Shell;
using OrchardCore.Google.Authentication.Settings;
using OrchardCore.Google.Authentication.ViewModels;
using OrchardCore.Settings;
Expand All @@ -19,23 +19,17 @@ public class GoogleAuthenticationSettingsDisplayDriver : SectionDisplayDriver<IS
private readonly IAuthorizationService _authorizationService;
private readonly IDataProtectionProvider _dataProtectionProvider;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IShellHost _shellHost;
private readonly ShellSettings _shellSettings;
private readonly ILogger _logger;

public GoogleAuthenticationSettingsDisplayDriver(
IAuthorizationService authorizationService,
IDataProtectionProvider dataProtectionProvider,
IHttpContextAccessor httpContextAccessor,
IShellHost shellHost,
ShellSettings shellSettings,
ILogger<GoogleAuthenticationSettingsDisplayDriver> logger)
{
_authorizationService = authorizationService;
_dataProtectionProvider = dataProtectionProvider;
_httpContextAccessor = httpContextAccessor;
_shellHost = shellHost;
_shellSettings = shellSettings;
_logger = logger;
}

Expand Down Expand Up @@ -76,7 +70,7 @@ public override async Task<IDisplayResult> EditAsync(GoogleAuthenticationSetting
}).Location("Content:5").OnGroup(GoogleConstants.Features.GoogleAuthentication);
}

public override async Task<IDisplayResult> UpdateAsync(GoogleAuthenticationSettings settings, UpdateEditorContext context)
public override async Task<IDisplayResult> UpdateAsync(ISite site, GoogleAuthenticationSettings settings, IUpdateModel updater, UpdateEditorContext context)
{
if (context.GroupId == GoogleConstants.Features.GoogleAuthentication)
{
Expand All @@ -97,9 +91,11 @@ public override async Task<IDisplayResult> UpdateAsync(GoogleAuthenticationSetti
settings.ClientSecret = protector.Protect(model.ClientSecret);
settings.CallbackPath = model.CallbackPath;
settings.SaveTokens = model.SaveTokens;
await _shellHost.ReleaseShellContextAsync(_shellSettings);

site.QueueReleaseShellContext();
}
}

return await EditAsync(settings, context);
}
}
Expand Down
Loading