Merge pull request #5697 from sbwalker/dev
allow site templates to support shared modules
This commit is contained in:
@@ -7,15 +7,11 @@ using Oqtane.Infrastructure.SiteTemplates;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.UI;
|
||||
using Org.BouncyCastle.Pqc.Crypto.Lms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Oqtane.Infrastructure
|
||||
{
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace Oqtane.Repository
|
||||
var attribute = (SiteMigrationAttribute)Attribute.GetCustomAttribute(type, typeof(SiteMigrationAttribute));
|
||||
if (attribute.AliasName == "*" || attribute.AliasName == alias.Name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(site.Version) || Version.Parse(attribute.Version) > Version.Parse(site.Version))
|
||||
if (string.IsNullOrEmpty(site.Version) || attribute.Version == "*" || Version.Parse(attribute.Version) > Version.Parse(site.Version))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -176,14 +176,14 @@ namespace Oqtane.Repository
|
||||
if (obj != null)
|
||||
{
|
||||
obj.Up(site, alias);
|
||||
_logger.Log(LogLevel.Information, "Site Migration", LogFunction.Other, "Site Migrated Successfully To Version {version} For {Alias}", version, alias.Name);
|
||||
_logger.Log(LogLevel.Information, "Site Migration", LogFunction.Other, "Site Migrated Successfully For {Alias} And Version {version}", alias.Name, attribute.Version);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Log(LogLevel.Error, "Site Migration", LogFunction.Other, ex, "An Error Occurred Executing Site Migration {Type} For {Alias} And Version {Version}", type, alias.Name, version);
|
||||
_logger.Log(LogLevel.Error, "Site Migration", LogFunction.Other, ex, "An Error Occurred Executing Site Migration {Type} For {Alias} And Version {Version}", type, alias.Name, attribute.Version);
|
||||
}
|
||||
if (string.IsNullOrEmpty(version) || Version.Parse(attribute.Version) > Version.Parse(version))
|
||||
if (attribute.Version != "*" && (string.IsNullOrEmpty(version) || Version.Parse(attribute.Version) > Version.Parse(version)))
|
||||
{
|
||||
version = attribute.Version;
|
||||
}
|
||||
@@ -490,7 +490,27 @@ namespace Oqtane.Repository
|
||||
}
|
||||
else
|
||||
{
|
||||
var module = _moduleRepository.AddModule(pageModule.Module);
|
||||
Module module = null;
|
||||
if (pageTemplateModule.FromPagePath != "")
|
||||
{
|
||||
// used for modules shared across pages
|
||||
var pagePath = pageTemplateModule.FromPagePath;
|
||||
pagePath = (pagePath.ToLower() == "home") ? "" : pagePath;
|
||||
pagePath = (pagePath == "/") ? "" : pagePath;
|
||||
if (pages.Any(item => item.Path.ToLower() == pagePath.ToLower()))
|
||||
{
|
||||
var pageId = pages.First(item => item.Path.ToLower() == pagePath.ToLower()).PageId;
|
||||
if (pageModules.Any(item => item.PageId == pageId && item.Module.ModuleDefinitionName == pageTemplateModule.ModuleDefinitionName && item.Title.ToLower() == pageTemplateModule.Title.ToLower()))
|
||||
{
|
||||
module = pageModules.FirstOrDefault(item => item.PageId == pageId && item.Module.ModuleDefinitionName == pageTemplateModule.ModuleDefinitionName && item.Title.ToLower() == pageTemplateModule.Title.ToLower()).Module;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (module == null)
|
||||
{
|
||||
module = _moduleRepository.AddModule(pageModule.Module);
|
||||
}
|
||||
|
||||
pageModule.ModuleId = module.ModuleId;
|
||||
pageModule.Module = null; // remove tracking
|
||||
_pageModuleRepository.AddPageModule(pageModule);
|
||||
|
||||
@@ -105,6 +105,7 @@ namespace Oqtane.Models
|
||||
};
|
||||
Settings = new List<Setting>();
|
||||
Content = "";
|
||||
FromPagePath = "";
|
||||
}
|
||||
|
||||
public string ModuleDefinitionName { get; set; }
|
||||
@@ -118,6 +119,7 @@ namespace Oqtane.Models
|
||||
public List<Permission> PermissionList { get; set; }
|
||||
public List<Setting> Settings { get; set; }
|
||||
public string Content { get; set; }
|
||||
public string FromPagePath { get; set; } // for modules shared across pages
|
||||
|
||||
[Obsolete("The ModulePermissions property is deprecated. Use PermissionList instead", false)]
|
||||
public string ModulePermissions
|
||||
|
||||
Reference in New Issue
Block a user