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

Settings Fix #1021

Merged
merged 1 commit into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 10 additions & 8 deletions Oqtane.Client/Modules/Admin/Modules/Settings.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@namespace Oqtane.Modules.Admin.Modules
@using Oqtane.Interfaces
@inherits ModuleBase
@inject NavigationManager NavigationManager
@inject IThemeService ThemeService
Expand Down Expand Up @@ -137,7 +138,7 @@
builder.AddComponentReferenceCapture(1, inst => { _settings = Convert.ChangeType(inst, _settingsModuleType); });
builder.CloseComponent();
};
}
}
}

private async Task SaveModule()
Expand All @@ -162,15 +163,16 @@
module.Permissions = _permissionGrid.GetPermissions();
await ModuleService.UpdateModuleAsync(module);

if (_settingsModuleType != null)

if (_settings is ISettingsControl control)
{
var moduleType = Type.GetType(ModuleState.ModuleType);
if (moduleType != null)
{
moduleType.GetMethod("UpdateSettings")?.Invoke(_settings, null); // method must be public in settings component
}
await control.UpdateSettings();
}
else
{
// Compatibility 2.0 fallback
_settings?.GetType().GetMethod("UpdateSettings")?.Invoke(_settings, null); // method must be public in settings component
}

NavigationManager.NavigateTo(NavigateUrl());
}

Expand Down
9 changes: 9 additions & 0 deletions Oqtane.Shared/Interfaces/ISettingsControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Threading.Tasks;

namespace Oqtane.Interfaces
{
public interface ISettingsControl
{
Task UpdateSettings();
}
}