Plugin info - Implemented property changed

Plugins - Improved enable failure detection
Plugins UI - Show an indicator on plugins that failed to enable
Plugins UI - Show a progress indicator on plugins that are enabling
UI - Added reusable Snackbar (not the Dutch kind with kroketten)
This commit is contained in:
Robert committed 2020-06-25 13:25:15 +02:00
1 parent 3e937f6256
commit 8215440fac
18 files changed
+399 -179

No files matched your search

@@ -1,4 +1,6 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
@@ -13,9 +15,11 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
{
private readonly IDialogService _dialogService;
private readonly IPluginService _pluginService;
private readonly ISnackbarMessageQueue _snackbarMessageQueue;
private readonly IWindowManager _windowManager;
public PluginSettingsViewModel(Plugin plugin, IWindowManager windowManager, IDialogService dialogService, IPluginService pluginService)
public PluginSettingsViewModel(Plugin plugin, IWindowManager windowManager, IDialogService dialogService, IPluginService pluginService,
ISnackbarMessageQueue snackbarMessageQueue)
{
Plugin = plugin;
PluginInfo = plugin.PluginInfo;
@@ -23,6 +27,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
_windowManager = windowManager;
_dialogService = dialogService;
_pluginService = pluginService;
_snackbarMessageQueue = snackbarMessageQueue;
}
public Plugin Plugin { get; set; }
@@ -40,6 +45,8 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
public bool CanOpenSettings => IsEnabled && Plugin.HasConfigurationViewModel;
public bool Enabling { get; set; }
public async Task OpenSettings()
{
try
@@ -55,6 +62,18 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
}
}
public async Task ShowLogsFolder()
{
try
{
Process.Start(Environment.GetEnvironmentVariable("WINDIR") + @"\explorer.exe", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs"));
}
catch (Exception e)
{
await _dialogService.ShowExceptionDialog("Welp, we couldn\'t open the logs folder for you", e);
}
}
private PackIconKind GetIconKind()
{
if (PluginInfo.Icon != null)
@@ -105,7 +124,23 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
}
if (enable)
_pluginService.EnablePlugin(Plugin);
{
Enabling = true;
try
{
_pluginService.EnablePlugin(Plugin);
_snackbarMessageQueue.Enqueue($"Enabled plugin {PluginInfo.Name}");
}
catch (Exception)
{
_snackbarMessageQueue.Enqueue($"Failed to enable plugin {PluginInfo.Name}", "VIEW LOGS", async () => await ShowLogsFolder());
}
finally
{
Enabling = false;
NotifyOfPropertyChange(() => IsEnabled);
}
}
else
_pluginService.DisablePlugin(Plugin);