added PackageName property to IModule and ITheme interfaces to allow creators to specify the Nuget package name associated to a specific module/theme. This is necessary for packages which contain multiple extensions.
This commit is contained in:
parent
41ed069072
commit
5c21ab37ee
|
@ -61,7 +61,7 @@
|
|||
|
||||
foreach (Package package in _packages.ToArray())
|
||||
{
|
||||
if (moduledefinitions.Exists(item => Utilities.GetTypeName(item.ModuleDefinitionName) == package.PackageId))
|
||||
if (moduledefinitions.Exists(item => item.PackageName == package.PackageId))
|
||||
{
|
||||
_packages.Remove(package);
|
||||
}
|
||||
|
|
|
@ -34,9 +34,9 @@ else
|
|||
<td>@context.Name</td>
|
||||
<td>@context.Version</td>
|
||||
<td>
|
||||
@if (UpgradeAvailable(context.ModuleDefinitionName, context.Version))
|
||||
@if (UpgradeAvailable(context.PackageName, context.Version))
|
||||
{
|
||||
<button type="button" class="btn btn-success" @onclick=@(async () => await DownloadModule(context.ModuleDefinitionName, context.Version))>@Localizer["Upgrade"]</button>
|
||||
<button type="button" class="btn btn-success" @onclick=@(async () => await DownloadModule(context.PackageName, context.Version))>@Localizer["Upgrade"]</button>
|
||||
}
|
||||
</td>
|
||||
</Row>
|
||||
|
@ -66,12 +66,12 @@ else
|
|||
}
|
||||
}
|
||||
|
||||
private bool UpgradeAvailable(string moduledefinitionname, string version)
|
||||
private bool UpgradeAvailable(string packagename, string version)
|
||||
{
|
||||
var upgradeavailable = false;
|
||||
if (_packages != null)
|
||||
{
|
||||
var package = _packages.Where(item => item.PackageId == Utilities.GetTypeName(moduledefinitionname)).FirstOrDefault();
|
||||
var package = _packages.Where(item => item.PackageId == packagename).FirstOrDefault();
|
||||
if (package != null)
|
||||
{
|
||||
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0);
|
||||
|
@ -81,18 +81,18 @@ else
|
|||
return upgradeavailable;
|
||||
}
|
||||
|
||||
private async Task DownloadModule(string moduledefinitionname, string version)
|
||||
private async Task DownloadModule(string packagename, string version)
|
||||
{
|
||||
try
|
||||
{
|
||||
await PackageService.DownloadPackageAsync(moduledefinitionname, version, "Modules");
|
||||
await logger.LogInformation("Module Downloaded {ModuleDefinitionName} {Version}", moduledefinitionname, version);
|
||||
await PackageService.DownloadPackageAsync(packagename, version, "Modules");
|
||||
await logger.LogInformation("Module Downloaded {ModuleDefinitionName} {Version}", packagename, version);
|
||||
await ModuleDefinitionService.InstallModuleDefinitionsAsync();
|
||||
AddModuleMessage(Localizer["Module Installed Successfully. You Must <a href=\"{0}\">Restart</a> Your Application To Apply These Changes.", NavigateUrl("admin/system")], MessageType.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Downloading Module {ModuleDefinitionName} {Version} {Error}", moduledefinitionname, version, ex.Message);
|
||||
await logger.LogError(ex, "Error Downloading Module {ModuleDefinitionName} {Version} {Error}", packagename, version, ex.Message);
|
||||
AddModuleMessage(Localizer["Error Downloading Module"], MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
|
||||
foreach (Package package in _packages.ToArray())
|
||||
{
|
||||
if (themes.Exists(item => Utilities.GetTypeName(item.ThemeName) == package.PackageId))
|
||||
if (themes.Exists(item => item.PackageName == package.PackageId))
|
||||
{
|
||||
_packages.Remove(package);
|
||||
}
|
||||
|
|
|
@ -35,9 +35,9 @@ else
|
|||
<td>@context.Name</td>
|
||||
<td>@context.Version</td>
|
||||
<td>
|
||||
@if (UpgradeAvailable(context.ThemeName, context.Version))
|
||||
@if (UpgradeAvailable(context.PackageName, context.Version))
|
||||
{
|
||||
<button type="button" class="btn btn-success" @onclick=@(async () => await DownloadTheme(context.ThemeName, context.Version))>@Localizer["Upgrade"]</button>
|
||||
<button type="button" class="btn btn-success" @onclick=@(async () => await DownloadTheme(context.PackageName, context.Version))>@Localizer["Upgrade"]</button>
|
||||
}
|
||||
</td>
|
||||
<td></td>
|
||||
|
@ -68,12 +68,12 @@ else
|
|||
}
|
||||
}
|
||||
|
||||
private bool UpgradeAvailable(string themename, string version)
|
||||
private bool UpgradeAvailable(string packagename, string version)
|
||||
{
|
||||
var upgradeavailable = false;
|
||||
if (_packages != null)
|
||||
{
|
||||
var package = _packages.Where(item => item.PackageId == Utilities.GetTypeName(themename)).FirstOrDefault();
|
||||
var package = _packages.Where(item => item.PackageId == packagename).FirstOrDefault();
|
||||
if (package != null)
|
||||
{
|
||||
upgradeavailable = (Version.Parse(package.Version).CompareTo(Version.Parse(version)) > 0);
|
||||
|
@ -82,18 +82,18 @@ else
|
|||
return upgradeavailable;
|
||||
}
|
||||
|
||||
private async Task DownloadTheme(string themename, string version)
|
||||
private async Task DownloadTheme(string packagename, string version)
|
||||
{
|
||||
try
|
||||
{
|
||||
await PackageService.DownloadPackageAsync(themename, version, "Themes");
|
||||
await logger.LogInformation("Theme Downloaded {ThemeName} {Version}", themename, version);
|
||||
await PackageService.DownloadPackageAsync(packagename, version, "Themes");
|
||||
await logger.LogInformation("Theme Downloaded {ThemeName} {Version}", packagename, version);
|
||||
await ThemeService.InstallThemesAsync();
|
||||
AddModuleMessage(Localizer["Theme Installed Successfully. You Must <a href=\"{0}\">Restart</a> Your Application To Apply These Changes.", NavigateUrl("admin/system")], MessageType.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Downloading Theme {ThemeName} {Version} {Error}", themename, version, ex.Message);
|
||||
await logger.LogError(ex, "Error Downloading Theme {ThemeName} {Version} {Error}", packagename, version, ex.Message);
|
||||
AddModuleMessage(Localizer["Error Downloading Theme"], MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,6 +231,10 @@ namespace Oqtane.Repository
|
|||
moduledefinition.Version = ""; // will be populated from database
|
||||
moduledefinition.ControlTypeTemplate = modulecontroltype.Namespace + "." + Constants.ActionToken + ", " + modulecontroltype.Assembly.GetName().Name;
|
||||
moduledefinition.AssemblyName = assembly.GetName().Name;
|
||||
if (string.IsNullOrEmpty(moduledefinition.PackageName))
|
||||
{
|
||||
moduledefinition.PackageName = Utilities.GetTypeName(moduledefinition.ModuleDefinitionName);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(moduledefinition.Categories))
|
||||
{
|
||||
|
|
|
@ -100,6 +100,10 @@ namespace Oqtane.Repository
|
|||
theme.Themes = new List<ThemeControl>();
|
||||
theme.Containers = new List<ThemeControl>();
|
||||
theme.AssemblyName = assembly.FullName.Split(",")[0];
|
||||
if (string.IsNullOrEmpty(theme.PackageName))
|
||||
{
|
||||
theme.PackageName = Utilities.GetTypeName(theme.ThemeName);
|
||||
}
|
||||
themes.Add(theme);
|
||||
index = themes.FindIndex(item => item.ThemeName == qualifiedThemeType);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace Oqtane.Models
|
|||
ReleaseVersions = "";
|
||||
DefaultAction = "";
|
||||
SettingsType = "";
|
||||
PackageName = "";
|
||||
Runtimes = "";
|
||||
Template = "";
|
||||
}
|
||||
|
@ -92,6 +93,8 @@ namespace Oqtane.Models
|
|||
public string DefaultAction { get; set; }
|
||||
[NotMapped]
|
||||
public string SettingsType { get; set; } // added in 2.0.2
|
||||
[NotMapped]
|
||||
public string PackageName { get; set; } // added in 2.1.0
|
||||
|
||||
// internal properties
|
||||
[NotMapped]
|
||||
|
|
|
@ -15,6 +15,9 @@ namespace Oqtane.Models
|
|||
License = "";
|
||||
Dependencies = "";
|
||||
Template = "";
|
||||
ThemeSettingsType = "";
|
||||
ContainerSettingsType = "";
|
||||
PackageName = "";
|
||||
}
|
||||
|
||||
public string ThemeName { get; set; }
|
||||
|
@ -25,8 +28,9 @@ namespace Oqtane.Models
|
|||
public string Contact { get; set; }
|
||||
public string License { get; set; }
|
||||
public string Dependencies { get; set; }
|
||||
public string ThemeSettingsType { get; set; }
|
||||
public string ContainerSettingsType { get; set; }
|
||||
public string ThemeSettingsType { get; set; } // added in 2.0.2
|
||||
public string ContainerSettingsType { get; set; } // added in 2.0.2
|
||||
public string PackageName { get; set; } // added in 2.1.0
|
||||
|
||||
// internal properties
|
||||
public string AssemblyName { get; set; }
|
||||
|
|
Loading…
Reference in New Issue
Block a user