mirror of
https://github.com/oqtane/oqtane.framework.git
synced 2025-05-19 02:54:22 +00:00
fix #2900 - theme deletion and fallback
This commit is contained in:
parent
e3233fd19f
commit
3849f59126
@ -318,31 +318,29 @@
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
page.Panes = new List<string>();
|
||||||
|
page.Resources = new List<Resource>();
|
||||||
|
|
||||||
|
// validate theme
|
||||||
if (string.IsNullOrEmpty(page.ThemeType))
|
if (string.IsNullOrEmpty(page.ThemeType))
|
||||||
{
|
{
|
||||||
page.ThemeType = site.DefaultThemeType;
|
page.ThemeType = site.DefaultThemeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
page.Panes = new List<string>();
|
|
||||||
page.Resources = new List<Resource>();
|
|
||||||
|
|
||||||
// get theme resources
|
|
||||||
var theme = site.Themes.FirstOrDefault(item => item.Themes.Any(item => item.TypeName == page.ThemeType));
|
var theme = site.Themes.FirstOrDefault(item => item.Themes.Any(item => item.TypeName == page.ThemeType));
|
||||||
if (theme != null)
|
|
||||||
{
|
|
||||||
page.Resources = ManagePageResources(page.Resources, theme.Resources, ResourceLevel.Page, alias, "Themes", Utilities.GetTypeName(theme.ThemeName));
|
|
||||||
}
|
|
||||||
|
|
||||||
string panes = "";
|
|
||||||
Type themetype = Type.GetType(page.ThemeType);
|
Type themetype = Type.GetType(page.ThemeType);
|
||||||
if (themetype == null)
|
if (themetype == null || theme == null)
|
||||||
{
|
{
|
||||||
// fallback
|
// fallback to default Oqtane theme
|
||||||
page.ThemeType = Constants.DefaultTheme;
|
page.ThemeType = Constants.DefaultTheme;
|
||||||
themetype = Type.GetType(Constants.DefaultTheme);
|
themetype = Type.GetType(Constants.DefaultTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string panes = "";
|
||||||
if (themetype != null)
|
if (themetype != null)
|
||||||
{
|
{
|
||||||
|
// get resources for theme (ITheme)
|
||||||
|
page.Resources = ManagePageResources(page.Resources, theme.Resources, ResourceLevel.Page, alias, "Themes", Utilities.GetTypeName(theme.ThemeName));
|
||||||
|
|
||||||
var themeobject = Activator.CreateInstance(themetype) as IThemeControl;
|
var themeobject = Activator.CreateInstance(themetype) as IThemeControl;
|
||||||
if (themeobject != null)
|
if (themeobject != null)
|
||||||
{
|
{
|
||||||
@ -350,9 +348,11 @@
|
|||||||
{
|
{
|
||||||
panes = themeobject.Panes;
|
panes = themeobject.Panes;
|
||||||
}
|
}
|
||||||
|
// get resources for theme control
|
||||||
page.Resources = ManagePageResources(page.Resources, themeobject.Resources, ResourceLevel.Page, alias, "Themes", themetype.Namespace);
|
page.Resources = ManagePageResources(page.Resources, themeobject.Resources, ResourceLevel.Page, alias, "Themes", themetype.Namespace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(panes))
|
if (!string.IsNullOrEmpty(panes))
|
||||||
{
|
{
|
||||||
page.Panes = panes.Replace(";", ",").Split(',', StringSplitOptions.RemoveEmptyEntries).ToList();
|
page.Panes = panes.Replace(";", ",").Split(',', StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||||
|
@ -258,6 +258,7 @@ namespace Oqtane.Controllers
|
|||||||
// remove module definition
|
// remove module definition
|
||||||
_moduleDefinitions.DeleteModuleDefinition(id);
|
_moduleDefinitions.DeleteModuleDefinition(id);
|
||||||
_syncManager.AddSyncEvent(_alias.TenantId, EntityNames.ModuleDefinition, moduledefinition.ModuleDefinitionId, SyncEventActions.Delete);
|
_syncManager.AddSyncEvent(_alias.TenantId, EntityNames.ModuleDefinition, moduledefinition.ModuleDefinitionId, SyncEventActions.Delete);
|
||||||
|
_syncManager.AddSyncEvent(_alias.TenantId, EntityNames.Site, moduledefinition.SiteId, SyncEventActions.Refresh);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Definition {ModuleDefinitionName} Deleted", moduledefinition.Name);
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Definition {ModuleDefinitionName} Deleted", moduledefinition.Name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -117,7 +117,9 @@ namespace Oqtane.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remove theme
|
// remove theme
|
||||||
//_themes.DeleteTheme(theme.ThemeName);
|
_themes.DeleteTheme(theme.ThemeId);
|
||||||
|
_syncManager.AddSyncEvent(_alias.TenantId, EntityNames.Theme, theme.ThemeId, SyncEventActions.Delete);
|
||||||
|
_syncManager.AddSyncEvent(_alias.TenantId, EntityNames.Site, theme.SiteId, SyncEventActions.Refresh);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Theme Removed For {ThemeName}", theme.ThemeName);
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Theme Removed For {ThemeName}", theme.ThemeName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user