From 27a3ac8d1c592f178d48994bb31a74258c0c7c2b Mon Sep 17 00:00:00 2001 From: Pavel Vesely Date: Mon, 1 Jun 2020 08:24:20 +0200 Subject: [PATCH 1/2] OqtaneIgnore implementation fix --- Oqtane.Client/Themes/ContainerBase.cs | 2 +- Oqtane.Client/Themes/LayoutBase.cs | 2 +- Oqtane.Client/Themes/ThemeBase.cs | 2 +- Oqtane.Client/Themes/ThemeControlBase.cs | 2 +- Oqtane.Server/Repository/ModuleDefinitionRepository.cs | 6 +----- Oqtane.Server/Repository/ThemeRepository.cs | 5 +---- Oqtane.Shared/Extensions/AssemblyExtensions.cs | 7 ++++++- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Oqtane.Client/Themes/ContainerBase.cs b/Oqtane.Client/Themes/ContainerBase.cs index af4ff355..8c4b9a15 100644 --- a/Oqtane.Client/Themes/ContainerBase.cs +++ b/Oqtane.Client/Themes/ContainerBase.cs @@ -6,7 +6,7 @@ using Oqtane.UI; namespace Oqtane.Themes { - public class ContainerBase : ComponentBase, IContainerControl + public abstract class ContainerBase : ComponentBase, IContainerControl { [Inject] protected IJSRuntime JSRuntime { get; set; } diff --git a/Oqtane.Client/Themes/LayoutBase.cs b/Oqtane.Client/Themes/LayoutBase.cs index cd8d92e4..b60ad414 100644 --- a/Oqtane.Client/Themes/LayoutBase.cs +++ b/Oqtane.Client/Themes/LayoutBase.cs @@ -4,7 +4,7 @@ using Oqtane.UI; namespace Oqtane.Themes { - public class LayoutBase : ComponentBase, ILayoutControl + public abstract class LayoutBase : ComponentBase, ILayoutControl { [CascadingParameter] protected PageState PageState { get; set; } diff --git a/Oqtane.Client/Themes/ThemeBase.cs b/Oqtane.Client/Themes/ThemeBase.cs index af05f94a..be481976 100644 --- a/Oqtane.Client/Themes/ThemeBase.cs +++ b/Oqtane.Client/Themes/ThemeBase.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace Oqtane.Themes { - public class ThemeBase : ComponentBase, IThemeControl + public abstract class ThemeBase : ComponentBase, IThemeControl { [Inject] protected IJSRuntime JSRuntime { get; set; } diff --git a/Oqtane.Client/Themes/ThemeControlBase.cs b/Oqtane.Client/Themes/ThemeControlBase.cs index b3a2314a..62d3ef13 100644 --- a/Oqtane.Client/Themes/ThemeControlBase.cs +++ b/Oqtane.Client/Themes/ThemeControlBase.cs @@ -4,7 +4,7 @@ using Oqtane.UI; namespace Oqtane.Themes { - public class ThemeControlBase : ComponentBase + public abstract class ThemeControlBase : ComponentBase { [CascadingParameter] protected PageState PageState { get; set; } diff --git a/Oqtane.Server/Repository/ModuleDefinitionRepository.cs b/Oqtane.Server/Repository/ModuleDefinitionRepository.cs index 7521b9f3..b2bfc71d 100644 --- a/Oqtane.Server/Repository/ModuleDefinitionRepository.cs +++ b/Oqtane.Server/Repository/ModuleDefinitionRepository.cs @@ -193,11 +193,7 @@ namespace Oqtane.Repository foreach (Type modulecontroltype in modulecontroltypes) { // Check if type should be ignored - if (modulecontroltype.Name == "ModuleBase" - || modulecontroltype.IsGenericType - || modulecontroltype.IsAbstract - || modulecontroltype.IsOqtaneIgnore() - ) continue; + if (modulecontroltype.IsOqtaneIgnore()) continue; // create namespace root typename string qualifiedModuleType = modulecontroltype.Namespace + ", " + modulecontroltype.Assembly.GetName().Name; diff --git a/Oqtane.Server/Repository/ThemeRepository.cs b/Oqtane.Server/Repository/ThemeRepository.cs index bc14de74..c346b1bd 100644 --- a/Oqtane.Server/Repository/ThemeRepository.cs +++ b/Oqtane.Server/Repository/ThemeRepository.cs @@ -50,10 +50,7 @@ namespace Oqtane.Repository foreach (Type themeControlType in themeControlTypes) { // Check if type should be ignored - if (themeControlType.Name == "ThemeBase" - || themeControlType.IsGenericType - || themeControlType.IsAbstract - || themeControlType.IsOqtaneIgnore() + if (themeControlType.IsOqtaneIgnore() ) continue; // create namespace root typename diff --git a/Oqtane.Shared/Extensions/AssemblyExtensions.cs b/Oqtane.Shared/Extensions/AssemblyExtensions.cs index d02053f4..5b68bc76 100644 --- a/Oqtane.Shared/Extensions/AssemblyExtensions.cs +++ b/Oqtane.Shared/Extensions/AssemblyExtensions.cs @@ -80,9 +80,14 @@ namespace System.Reflection .Where(a => Utilities.GetFullTypeName(a.GetName().Name) != "Oqtane.Client"); } + /// + /// Checks if type should be ignored by oqtane dynamic loader + /// + /// Checked type + /// public static bool IsOqtaneIgnore(this Type type) { - return Attribute.IsDefined(type, typeof(OqtaneIgnoreAttribute)); + return Attribute.IsDefined(type, typeof(OqtaneIgnoreAttribute)) || type.IsAbstract || type.IsGenericType; } } } From 4144be5323a4303ddbceae27a9fc6717a03afa6f Mon Sep 17 00:00:00 2001 From: Pavel Vesely Date: Mon, 1 Jun 2020 09:30:55 +0200 Subject: [PATCH 2/2] Control panel Pane persistence & default selection fix. --- .../Themes/Controls/ControlPanel.razor | 84 +++++++++---------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/Oqtane.Client/Themes/Controls/ControlPanel.razor b/Oqtane.Client/Themes/Controls/ControlPanel.razor index 8fa031d5..b6fb64c8 100644 --- a/Oqtane.Client/Themes/Controls/ControlPanel.razor +++ b/Oqtane.Client/Themes/Controls/ControlPanel.razor @@ -145,18 +145,20 @@ -
-
- - + @if (_pane.Length > 1) + { +
+
+ + +
-
+ }
@@ -244,47 +246,41 @@ } } + protected string Pane + { + get => _pane; + private set + { + if (_pane != value) + { + _pane = value; + _ = UpdateSettingsAsync(); + } + } + } + + protected string Description { get; private set; } = ""; - protected string Pane { get; private set; } = ""; + protected string Title { get; private set; } = ""; protected string ContainerType { get; private set; } = ""; protected string Message { get; private set; } = ""; [Parameter] - public string ButtonClass { get; set; } + public string ButtonClass { get; set; } = "btn-outline-secondary"; [Parameter] - public string CardClass { get; set; } + public string CardClass { get; set; } = "card border-secondary mb-3"; [Parameter] - public string HeaderClass { get; set; } + public string HeaderClass { get; set; } = "card-header"; [Parameter] - public string BodyClass { get; set; } + public string BodyClass { get; set; } = "card-body"; protected override async Task OnInitializedAsync() { - if (string.IsNullOrEmpty(ButtonClass)) - { - ButtonClass = "btn-outline-secondary"; - } - - if (string.IsNullOrEmpty(CardClass)) - { - CardClass = "card border-secondary mb-3"; - } - - if (string.IsNullOrEmpty(HeaderClass)) - { - HeaderClass = "card-header"; - } - - if (string.IsNullOrEmpty(BodyClass)) - { - BodyClass = "card-body"; - } - if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.Permissions)) { _pages?.Clear(); @@ -298,15 +294,11 @@ } await LoadSettingsAsync(); - var panes = PageState.Page.Panes; - Pane = panes.Count() == 1 ? panes.SingleOrDefault() : ""; var themes = await ThemeService.GetThemesAsync(); _containers = ThemeService.GetContainerTypes(themes, PageState.Page.ThemeType); ContainerType = PageState.Site.DefaultContainerType; - _allModuleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId); _moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories.Contains(Category)).ToList(); - _categories = _allModuleDefinitions.SelectMany(m => m.Categories.Split(',')).Distinct().ToList(); } } @@ -526,18 +518,24 @@ } } - private string settingName = "CP-category"; + private string settingCategory = "CP-category"; + private string settingPane = "CP-pane"; + private string _pane = ""; private async Task LoadSettingsAsync() { Dictionary settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId); - _category = SettingService.GetSetting(settings, settingName, "Common"); + _category = SettingService.GetSetting(settings, settingCategory, "Common"); + var pane = SettingService.GetSetting(settings, settingPane, ""); + _pane = PageState.Page.Panes.Contains(pane) ? pane : PageState.Page.Panes.FirstOrDefault(); } private async Task UpdateSettingsAsync() { Dictionary settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId); - SettingService.SetSetting(settings, settingName, _category); + SettingService.SetSetting(settings, settingCategory, _category); + SettingService.SetSetting(settings, settingPane, _pane); await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId); } + }