Merge pull request #5010 from BaronGreenback/Remove_IPluginConfigurationPage

Removal of IPluginConfigurationPage
This commit is contained in:
dkanada 2021-02-05 11:38:44 +09:00 committed by GitHub
commit 86859a3926
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 124 deletions

View File

@ -51,7 +51,6 @@ namespace Jellyfin.Api.Controllers
/// Gets the configuration pages. /// Gets the configuration pages.
/// </summary> /// </summary>
/// <param name="enableInMainMenu">Whether to enable in the main menu.</param> /// <param name="enableInMainMenu">Whether to enable in the main menu.</param>
/// <param name="pageType">The <see cref="ConfigurationPageInfo"/>.</param>
/// <response code="200">ConfigurationPages returned.</response> /// <response code="200">ConfigurationPages returned.</response>
/// <response code="404">Server still loading.</response> /// <response code="404">Server still loading.</response>
/// <returns>An <see cref="IEnumerable{ConfigurationPageInfo}"/> with infos about the plugins.</returns> /// <returns>An <see cref="IEnumerable{ConfigurationPageInfo}"/> with infos about the plugins.</returns>
@ -59,40 +58,9 @@ namespace Jellyfin.Api.Controllers
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult<IEnumerable<ConfigurationPageInfo?>> GetConfigurationPages( public ActionResult<IEnumerable<ConfigurationPageInfo?>> GetConfigurationPages(
[FromQuery] bool? enableInMainMenu, [FromQuery] bool? enableInMainMenu)
[FromQuery] ConfigurationPageType? pageType)
{ {
const string unavailableMessage = "The server is still loading. Please try again momentarily."; var configPages = _pluginManager.Plugins.SelectMany(GetConfigPages).ToList();
var pages = _appHost.GetExports<IPluginConfigurationPage>().ToList();
if (pages == null)
{
return NotFound(unavailableMessage);
}
// Don't allow a failing plugin to fail them all
var configPages = pages.Select(p =>
{
try
{
return new ConfigurationPageInfo(p);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error getting plugin information from {Plugin}", p.GetType().Name);
return null;
}
})
.Where(i => i != null)
.ToList();
configPages.AddRange(_pluginManager.Plugins.SelectMany(GetConfigPages));
if (pageType.HasValue)
{
configPages = configPages.Where(p => p!.ConfigurationPageType == pageType).ToList();
}
if (enableInMainMenu.HasValue) if (enableInMainMenu.HasValue)
{ {
@ -121,15 +89,6 @@ namespace Jellyfin.Api.Controllers
var isJs = false; var isJs = false;
var isTemplate = false; var isTemplate = false;
var page = _appHost.GetExports<IPluginConfigurationPage>().FirstOrDefault(p => string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase));
if (page != null)
{
plugin = page.Plugin;
stream = page.GetHtmlStream();
}
if (plugin == null)
{
var altPage = GetPluginPages().FirstOrDefault(p => string.Equals(p.Item1.Name, name, StringComparison.OrdinalIgnoreCase)); var altPage = GetPluginPages().FirstOrDefault(p => string.Equals(p.Item1.Name, name, StringComparison.OrdinalIgnoreCase));
if (altPage != null) if (altPage != null)
{ {
@ -139,7 +98,6 @@ namespace Jellyfin.Api.Controllers
isJs = string.Equals(Path.GetExtension(altPage.Item1.EmbeddedResourcePath), ".js", StringComparison.OrdinalIgnoreCase); isJs = string.Equals(Path.GetExtension(altPage.Item1.EmbeddedResourcePath), ".js", StringComparison.OrdinalIgnoreCase);
isTemplate = altPage.Item1.EmbeddedResourcePath.EndsWith(".template.html", StringComparison.Ordinal); isTemplate = altPage.Item1.EmbeddedResourcePath.EndsWith(".template.html", StringComparison.Ordinal);
} }
}
if (plugin != null && stream != null) if (plugin != null && stream != null)
{ {

View File

@ -10,23 +10,6 @@ namespace Jellyfin.Api.Models
/// </summary> /// </summary>
public class ConfigurationPageInfo public class ConfigurationPageInfo
{ {
/// <summary>
/// Initializes a new instance of the <see cref="ConfigurationPageInfo"/> class.
/// </summary>
/// <param name="page">Instance of <see cref="IPluginConfigurationPage"/> interface.</param>
public ConfigurationPageInfo(IPluginConfigurationPage page)
{
Name = page.Name;
ConfigurationPageType = page.ConfigurationPageType;
if (page.Plugin != null)
{
DisplayName = page.Plugin.Name;
PluginId = page.Plugin.Id;
}
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ConfigurationPageInfo"/> class. /// Initializes a new instance of the <see cref="ConfigurationPageInfo"/> class.
/// </summary> /// </summary>
@ -68,12 +51,6 @@ namespace Jellyfin.Api.Models
/// </summary> /// </summary>
public string? DisplayName { get; set; } public string? DisplayName { get; set; }
/// <summary>
/// Gets or sets the type of the configuration page.
/// </summary>
/// <value>The type of the configuration page.</value>
public ConfigurationPageType ConfigurationPageType { get; set; }
/// <summary> /// <summary>
/// Gets or sets the plugin id. /// Gets or sets the plugin id.
/// </summary> /// </summary>

View File

@ -1,51 +0,0 @@
using System.IO;
using MediaBrowser.Common.Plugins;
namespace MediaBrowser.Controller.Plugins
{
/// <summary>
/// Interface IConfigurationPage.
/// </summary>
public interface IPluginConfigurationPage
{
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
string Name { get; }
/// <summary>
/// Gets the type of the configuration page.
/// </summary>
/// <value>The type of the configuration page.</value>
ConfigurationPageType ConfigurationPageType { get; }
/// <summary>
/// Gets the plugin.
/// </summary>
/// <value>The plugin.</value>
IPlugin Plugin { get; }
/// <summary>
/// Gets the HTML stream.
/// </summary>
/// <returns>Stream.</returns>
Stream GetHtmlStream();
}
/// <summary>
/// Enum ConfigurationPageType.
/// </summary>
public enum ConfigurationPageType
{
/// <summary>
/// The plugin configuration.
/// </summary>
PluginConfiguration,
/// <summary>
/// The none.
/// </summary>
None
}
}