mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 22:44:29 +01:00
Improve UX for uninstalling disabled plugins
This commit is contained in:
@@ -59,6 +59,16 @@ namespace BTCPayServer.Controllers
|
||||
public Dictionary<string, AvailablePlugin> DownloadedPluginsByIdentifier { get; set; } = new Dictionary<string, AvailablePlugin>();
|
||||
}
|
||||
|
||||
[HttpPost("server/plugins/uninstall-all")]
|
||||
public IActionResult UnInstallAllDisabledPlugin(
|
||||
[FromServices] PluginService pluginService, string plugin)
|
||||
{
|
||||
var disabled = pluginService.GetDisabledPlugins();
|
||||
foreach (var d in disabled)
|
||||
pluginService.UninstallPlugin(d.Key);
|
||||
return RedirectToAction(nameof(ListPlugins));
|
||||
}
|
||||
|
||||
[HttpPost("server/plugins/uninstall")]
|
||||
public IActionResult UnInstallPlugin(
|
||||
[FromServices] PluginService pluginService, string plugin)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
@@ -17,8 +18,8 @@ namespace BTCPayServer.HostedServices
|
||||
|
||||
public EventAggregator EventAggregator => _EventAggregator;
|
||||
|
||||
private List<IEventAggregatorSubscription> _Subscriptions;
|
||||
private CancellationTokenSource _Cts;
|
||||
private List<IEventAggregatorSubscription> _Subscriptions = new List<IEventAggregatorSubscription>();
|
||||
private CancellationTokenSource _Cts = new CancellationTokenSource();
|
||||
public CancellationToken CancellationToken => _Cts.Token;
|
||||
public EventHostedServiceBase(EventAggregator eventAggregator, Logs logs)
|
||||
{
|
||||
@@ -78,9 +79,7 @@ namespace BTCPayServer.HostedServices
|
||||
|
||||
public virtual Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_Subscriptions = new List<IEventAggregatorSubscription>();
|
||||
SubscribeToEvents();
|
||||
_Cts = new CancellationTokenSource();
|
||||
_ProcessingEvents = ProcessEvents(_Cts.Token);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
@@ -88,8 +87,8 @@ namespace BTCPayServer.HostedServices
|
||||
|
||||
public virtual async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_Subscriptions?.ForEach(subscription => subscription.Dispose());
|
||||
_Cts?.Cancel();
|
||||
_Subscriptions.ForEach(subscription => subscription.Dispose());
|
||||
_Cts.Cancel();
|
||||
try
|
||||
{
|
||||
await _ProcessingEvents;
|
||||
|
||||
@@ -68,10 +68,25 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (Model.Commands.Any())
|
||||
{
|
||||
<div class="alert alert-info mb-4 d-flex align-items-center justify-content-between">
|
||||
You need to restart BTCPay Server in order to update your active plugins.
|
||||
@if (Model.CanShowRestart)
|
||||
{
|
||||
<form method="post" asp-action="Maintenance" class="mt-2">
|
||||
<button type="submit" name="command" value="soft-restart" class="btn btn-info" asp-action="Maintenance">Restart now</button>
|
||||
</form>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@if (Model.Disabled.Any())
|
||||
{
|
||||
<div class="alert alert-danger mb-4 d-flex align-items-center justify-content-between">
|
||||
Some plugins were disabled due to fatal errors. They may be incompatible with this version of BTCPay Server.
|
||||
<form asp-action="UnInstallAllDisabledPlugin" class="mt-2">
|
||||
<button type="submit" name="command" value="soft-restart" class="btn btn-danger">Uninstall all disabled plugins</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="mb-5">
|
||||
<h3 class="mb-4">Disabled Plugins</h3>
|
||||
@@ -87,8 +102,18 @@
|
||||
<span>(@version)</span>
|
||||
}
|
||||
</span>
|
||||
@{
|
||||
var uninstalled = Model.Commands.Any(c => c.plugin == plugin && c.command == "delete");
|
||||
}
|
||||
<form asp-action="UnInstallPlugin" asp-route-plugin="@plugin">
|
||||
@if (uninstalled)
|
||||
{
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger" disabled>Marked for deletion</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger">Uninstall</button>
|
||||
}
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
@@ -97,19 +122,6 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (Model.Commands.Any())
|
||||
{
|
||||
<div class="alert alert-info mb-4 d-flex align-items-center justify-content-between">
|
||||
You need to restart BTCPay Server in order to update your active plugins.
|
||||
@if (Model.CanShowRestart)
|
||||
{
|
||||
<form method="post" asp-action="Maintenance" class="mt-2">
|
||||
<button type="submit" name="command" value="soft-restart" class="btn btn-info" asp-action="Maintenance">Restart now</button>
|
||||
</form>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (Model.Installed.Any())
|
||||
{
|
||||
<h3 class="mb-4">Installed Plugins</h3>
|
||||
|
||||
Reference in New Issue
Block a user