aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-09-15 02:31:28 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-09-15 02:31:28 -0400
commitce26d502a4095c995150a53e5a17b89b59885308 (patch)
tree2b435c77559956c5d60f028abb16bced82556f7b
parent4a9550e58486873a487684994a68109830501a69 (diff)
allow plugins to inject menus
-rw-r--r--MediaBrowser.WebDashboard/Api/ConfigurationPageInfo.cs14
-rw-r--r--MediaBrowser.WebDashboard/Api/DashboardService.cs22
2 files changed, 26 insertions, 10 deletions
diff --git a/MediaBrowser.WebDashboard/Api/ConfigurationPageInfo.cs b/MediaBrowser.WebDashboard/Api/ConfigurationPageInfo.cs
index 33289e76c..b69c14fee 100644
--- a/MediaBrowser.WebDashboard/Api/ConfigurationPageInfo.cs
+++ b/MediaBrowser.WebDashboard/Api/ConfigurationPageInfo.cs
@@ -11,6 +11,9 @@ namespace MediaBrowser.WebDashboard.Api
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
+ public bool EnableInMainMenu { get; set; }
+
+ public string DisplayName { get; set; }
/// <summary>
/// Gets the type of the configuration page.
@@ -27,15 +30,22 @@ namespace MediaBrowser.WebDashboard.Api
public ConfigurationPageInfo(IPluginConfigurationPage page)
{
Name = page.Name;
+
ConfigurationPageType = page.ConfigurationPageType;
- // Don't use "N" because it needs to match Plugin.Id
- PluginId = page.Plugin.Id.ToString();
+ if (page.Plugin != null)
+ {
+ DisplayName = page.Plugin.Name;
+ // Don't use "N" because it needs to match Plugin.Id
+ PluginId = page.Plugin.Id.ToString();
+ }
}
public ConfigurationPageInfo(IPlugin plugin, PluginPageInfo page)
{
Name = page.Name;
+ EnableInMainMenu = page.EnableInMainMenu;
+ DisplayName = string.IsNullOrWhiteSpace(page.DisplayName) ? plugin.Name : page.DisplayName;
// Don't use "N" because it needs to match Plugin.Id
PluginId = plugin.Id.ToString();
diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs
index d4d0e281e..47662b509 100644
--- a/MediaBrowser.WebDashboard/Api/DashboardService.cs
+++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs
@@ -32,6 +32,7 @@ namespace MediaBrowser.WebDashboard.Api
/// </summary>
/// <value>The type of the page.</value>
public ConfigurationPageType? PageType { get; set; }
+ public bool? EnableInMainMenu { get; set; }
}
/// <summary>
@@ -221,25 +222,20 @@ namespace MediaBrowser.WebDashboard.Api
/// <returns>System.Object.</returns>
public object Get(GetDashboardConfigurationPages request)
{
- const string unavilableMessage = "The server is still loading. Please try again momentarily.";
+ const string unavailableMessage = "The server is still loading. Please try again momentarily.";
var instance = ServerEntryPoint.Instance;
if (instance == null)
{
- throw new InvalidOperationException(unavilableMessage);
+ throw new InvalidOperationException(unavailableMessage);
}
var pages = instance.PluginConfigurationPages;
if (pages == null)
{
- throw new InvalidOperationException(unavilableMessage);
- }
-
- if (request.PageType.HasValue)
- {
- pages = pages.Where(p => p.ConfigurationPageType == request.PageType.Value).ToList();
+ throw new InvalidOperationException(unavailableMessage);
}
// Don't allow a failing plugin to fail them all
@@ -261,6 +257,16 @@ namespace MediaBrowser.WebDashboard.Api
configPages.AddRange(_appHost.Plugins.SelectMany(GetConfigPages));
+ if (request.PageType.HasValue)
+ {
+ configPages = configPages.Where(p => p.ConfigurationPageType == request.PageType.Value).ToList();
+ }
+
+ if (request.EnableInMainMenu.HasValue)
+ {
+ configPages = configPages.Where(p => p.EnableInMainMenu == request.EnableInMainMenu.Value).ToList();
+ }
+
return _resultFactory.GetOptimizedResult(Request, configPages);
}