mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-25 10:59:18 +08:00
Aligning package update page to gallery. Moving the update feature to the packaging module as a feature.
--HG-- branch : dev
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using Orchard.Environment.Extensions;
|
||||
using System.Linq;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Packaging.Services;
|
||||
using Orchard.UI.Navigation;
|
||||
using Orchard.Security;
|
||||
|
||||
@@ -9,6 +12,14 @@ namespace Orchard.Packaging {
|
||||
public Localizer T { get; set; }
|
||||
public string MenuName { get { return "admin"; } }
|
||||
|
||||
private readonly IBackgroundPackageUpdateStatus _backgroundPackageUpdateStatus;
|
||||
|
||||
public AdminMenu(IBackgroundPackageUpdateStatus backgroundPackageUpdateStatus) {
|
||||
_backgroundPackageUpdateStatus = backgroundPackageUpdateStatus;
|
||||
}
|
||||
|
||||
public AdminMenu() {}
|
||||
|
||||
public void GetNavigation(NavigationBuilder builder) {
|
||||
builder.Add(T("Themes"), "25", menu => menu
|
||||
.Add(T("Available"), "1", item => item.Action("Themes", "Gallery", new { area = "Orchard.Packaging" })
|
||||
@@ -21,6 +32,37 @@ namespace Orchard.Packaging {
|
||||
builder.Add(T("Configuration"), "50", menu => menu
|
||||
.Add(T("Feeds"), "25", item => item.Action("Sources", "Gallery", new { area = "Orchard.Packaging" })
|
||||
.Permission(StandardPermissions.SiteOwner)));
|
||||
|
||||
if (_backgroundPackageUpdateStatus != null) {
|
||||
// Only available if feature is enabled
|
||||
|
||||
int modulesUpdateCount = GetUpdateCount(DefaultExtensionTypes.Module);
|
||||
LocalizedString modulesCaption = (modulesUpdateCount == 0 ? T("Updates") : T("Updates ({0})", modulesUpdateCount));
|
||||
|
||||
int themesUpdateCount = GetUpdateCount(DefaultExtensionTypes.Theme);
|
||||
LocalizedString themesCaption = (themesUpdateCount == 0 ? T("Updates") : T("Updates ({0})", themesUpdateCount));
|
||||
|
||||
builder.Add(T("Modules"), "20", menu => menu
|
||||
.Add(modulesCaption, "30.0", item => item.Action("ModulesUpdates", "GalleryUpdates", new { area = "Orchard.Packaging" })
|
||||
.Permission(StandardPermissions.SiteOwner).LocalNav()));
|
||||
|
||||
builder.Add(T("Themes"), "25", menu => menu
|
||||
.Add(themesCaption, "30.0", item => item.Action("ThemesUpdates", "GalleryUpdates", new { area = "Orchard.Packaging" })
|
||||
.Permission(StandardPermissions.SiteOwner).LocalNav()));
|
||||
}
|
||||
}
|
||||
|
||||
private int GetUpdateCount(string extensionType) {
|
||||
try {
|
||||
// Admin menu should never block, so simply return the result from the background task
|
||||
return _backgroundPackageUpdateStatus.Value == null ?
|
||||
0 :
|
||||
_backgroundPackageUpdateStatus.Value.Entries.Where(updatePackageEntry =>
|
||||
updatePackageEntry.NewVersionToInstall != null &&
|
||||
updatePackageEntry.ExtensionsDescriptor.ExtensionType.Equals(extensionType)).Count();
|
||||
} catch {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user