mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Use a help page URL instead of doing things in-app
This commit is contained in:
1 parent
949106e470
commit
2b15657f8d
17 files changed
+46
-367
No files matched your search
@@ -44,31 +44,9 @@ public class ArtemisPluginException : Exception
|
||||
public ArtemisPluginException(string message, Exception inner) : base(message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="ArtemisPluginException" /> class
|
||||
/// </summary>
|
||||
public ArtemisPluginException(string message, string helpPageId) : base(message)
|
||||
{
|
||||
HelpPageId = helpPageId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="ArtemisPluginException" /> class
|
||||
/// </summary>
|
||||
public ArtemisPluginException(string message, Exception inner, string helpPageId) : base(message, inner)
|
||||
{
|
||||
HelpPageId = helpPageId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin the error is related to
|
||||
/// </summary>
|
||||
public Plugin? Plugin { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ID of the help page to display for this exception.
|
||||
/// </summary>
|
||||
public string? HelpPageId { get; }
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a plugin related help page
|
||||
/// </summary>
|
||||
public interface IPluginHelpPage
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the plugin the help page belongs to.
|
||||
/// </summary>
|
||||
Plugin Plugin { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title of the help page.
|
||||
/// </summary>
|
||||
public string Title { get; }
|
||||
|
||||
/// <summary>
|
||||
/// An ID used to quickly lead users to the help page in case of an error.
|
||||
/// </summary>
|
||||
public string Id { get; }
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a plugin related help page
|
||||
/// </summary>
|
||||
public class MarkdownPluginHelpPage : IPluginHelpPage
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MarkdownPluginHelpPage" /> class.
|
||||
/// </summary>
|
||||
/// <param name="plugin">The plugin to display the markdown for.</param>
|
||||
/// <param name="markdownFile">A file path relative to the plugin or absolute, pointing to the markdown to display</param>
|
||||
/// <param name="id">The ID of the help page, used to quickly lead users to it in case of errors.</param>
|
||||
/// <exception cref="FileNotFoundException"></exception>
|
||||
public MarkdownPluginHelpPage(Plugin plugin, string title, string id, string markdownFile)
|
||||
{
|
||||
Plugin = plugin;
|
||||
Title = title;
|
||||
Id = id;
|
||||
MarkdownFile = Path.IsPathRooted(markdownFile) ? markdownFile : Plugin.ResolveRelativePath(markdownFile);
|
||||
|
||||
if (!File.Exists(MarkdownFile))
|
||||
throw new FileNotFoundException($"Could not find markdown file at \"{MarkdownFile}\"");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Plugin Plugin { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Title { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the absolute path to the markdown that is to be displayed.
|
||||
/// </summary>
|
||||
public string MarkdownFile { get; }
|
||||
}
|
||||
@@ -36,7 +36,6 @@ public class Plugin : CorePropertyChanged, IDisposable
|
||||
|
||||
Features = new ReadOnlyCollection<PluginFeatureInfo>(_features);
|
||||
Profilers = new ReadOnlyCollection<Profiler>(_profilers);
|
||||
HelpPages = new List<IPluginHelpPage>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -58,9 +57,7 @@ public class Plugin : CorePropertyChanged, IDisposable
|
||||
/// Gets or sets a configuration dialog for this plugin that is accessible in the UI under Settings > Plugins
|
||||
/// </summary>
|
||||
public IPluginConfigurationDialog? ConfigurationDialog { get; set; }
|
||||
|
||||
public List<IPluginHelpPage> HelpPages { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the user enabled the plugin or not
|
||||
/// </summary>
|
||||
|
||||
@@ -27,6 +27,7 @@ public class PluginInfo : CorePropertyChanged, IPrerequisitesSubject
|
||||
private bool _requiresAdmin;
|
||||
private string _version = null!;
|
||||
private Uri? _website;
|
||||
private Uri? _helpPage;
|
||||
|
||||
internal PluginInfo()
|
||||
{
|
||||
@@ -91,6 +92,16 @@ public class PluginInfo : CorePropertyChanged, IPrerequisitesSubject
|
||||
get => _repository;
|
||||
set => SetAndNotify(ref _repository, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the help page of this plugin
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public Uri? HelpPage
|
||||
{
|
||||
get => _helpPage;
|
||||
set => SetAndNotify(ref _helpPage, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The plugins display icon that's shown in the settings see <see href="https://materialdesignicons.com" /> for
|
||||
@@ -188,9 +199,6 @@ public class PluginInfo : CorePropertyChanged, IPrerequisitesSubject
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty]
|
||||
internal List<PluginInfoHelpPage> HelpPages { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean indicating whether this plugin is compatible with the current operating system and API version
|
||||
/// </summary>
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents basic info about a plugin and contains a reference to the instance of said plugin
|
||||
/// </summary>
|
||||
internal class PluginInfoHelpPage
|
||||
{
|
||||
[JsonConstructor]
|
||||
public PluginInfoHelpPage(string title, string markdownFile, string id)
|
||||
{
|
||||
Title = title;
|
||||
MarkdownFile = markdownFile;
|
||||
Id = id;
|
||||
}
|
||||
|
||||
[JsonProperty(Required = Required.Always)]
|
||||
public string Title { get; }
|
||||
|
||||
[JsonProperty(Required = Required.Always)]
|
||||
public string MarkdownFile { get; }
|
||||
|
||||
[JsonProperty(Required = Required.Always)]
|
||||
public string Id { get; }
|
||||
}
|
||||
@@ -350,9 +350,6 @@ internal class PluginManagementService : IPluginManagementService
|
||||
|
||||
// Load the entity and fall back on creating a new one
|
||||
Plugin plugin = new(pluginInfo, directory, _pluginRepository.GetPluginByGuid(pluginInfo.Guid));
|
||||
foreach (PluginInfoHelpPage pluginInfoHelpPage in pluginInfo.HelpPages)
|
||||
plugin.HelpPages.Add(new MarkdownPluginHelpPage(plugin, pluginInfoHelpPage.Title, pluginInfoHelpPage.Id, pluginInfoHelpPage.MarkdownFile));
|
||||
|
||||
OnPluginLoading(new PluginEventArgs(plugin));
|
||||
|
||||
// Locate the main assembly entry
|
||||
|
||||
Reference in new issue
Block a user