mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-11 01:35:22 +01:00
Merge pull request #6291 from NicolasDorier/markedfordeletion
Improve UX for uninstalling disabled plugins
This commit is contained in:
commit
cbea1d8691
3 changed files with 43 additions and 22 deletions
|
@ -59,6 +59,16 @@ namespace BTCPayServer.Controllers
|
||||||
public Dictionary<string, AvailablePlugin> DownloadedPluginsByIdentifier { get; set; } = new Dictionary<string, AvailablePlugin>();
|
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")]
|
[HttpPost("server/plugins/uninstall")]
|
||||||
public IActionResult UnInstallPlugin(
|
public IActionResult UnInstallPlugin(
|
||||||
[FromServices] PluginService pluginService, string plugin)
|
[FromServices] PluginService pluginService, string plugin)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -17,8 +18,8 @@ namespace BTCPayServer.HostedServices
|
||||||
|
|
||||||
public EventAggregator EventAggregator => _EventAggregator;
|
public EventAggregator EventAggregator => _EventAggregator;
|
||||||
|
|
||||||
private List<IEventAggregatorSubscription> _Subscriptions;
|
private List<IEventAggregatorSubscription> _Subscriptions = new List<IEventAggregatorSubscription>();
|
||||||
private CancellationTokenSource _Cts;
|
private CancellationTokenSource _Cts = new CancellationTokenSource();
|
||||||
public CancellationToken CancellationToken => _Cts.Token;
|
public CancellationToken CancellationToken => _Cts.Token;
|
||||||
public EventHostedServiceBase(EventAggregator eventAggregator, Logs logs)
|
public EventHostedServiceBase(EventAggregator eventAggregator, Logs logs)
|
||||||
{
|
{
|
||||||
|
@ -78,9 +79,7 @@ namespace BTCPayServer.HostedServices
|
||||||
|
|
||||||
public virtual Task StartAsync(CancellationToken cancellationToken)
|
public virtual Task StartAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
_Subscriptions = new List<IEventAggregatorSubscription>();
|
|
||||||
SubscribeToEvents();
|
SubscribeToEvents();
|
||||||
_Cts = new CancellationTokenSource();
|
|
||||||
_ProcessingEvents = ProcessEvents(_Cts.Token);
|
_ProcessingEvents = ProcessEvents(_Cts.Token);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
@ -88,8 +87,8 @@ namespace BTCPayServer.HostedServices
|
||||||
|
|
||||||
public virtual async Task StopAsync(CancellationToken cancellationToken)
|
public virtual async Task StopAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
_Subscriptions?.ForEach(subscription => subscription.Dispose());
|
_Subscriptions.ForEach(subscription => subscription.Dispose());
|
||||||
_Cts?.Cancel();
|
_Cts.Cancel();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _ProcessingEvents;
|
await _ProcessingEvents;
|
||||||
|
|
|
@ -68,10 +68,25 @@
|
||||||
</div>
|
</div>
|
||||||
</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())
|
@if (Model.Disabled.Any())
|
||||||
{
|
{
|
||||||
<div class="alert alert-danger mb-4 d-flex align-items-center justify-content-between">
|
<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.
|
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>
|
||||||
<div class="mb-5">
|
<div class="mb-5">
|
||||||
<h3 class="mb-4">Disabled Plugins</h3>
|
<h3 class="mb-4">Disabled Plugins</h3>
|
||||||
|
@ -87,8 +102,18 @@
|
||||||
<span>(@version)</span>
|
<span>(@version)</span>
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
|
@{
|
||||||
|
var uninstalled = Model.Commands.Any(c => c.plugin == plugin && c.command == "delete");
|
||||||
|
}
|
||||||
<form asp-action="UnInstallPlugin" asp-route-plugin="@plugin">
|
<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>
|
<button type="submit" class="btn btn-sm btn-outline-danger">Uninstall</button>
|
||||||
|
}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -97,19 +122,6 @@
|
||||||
</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.Installed.Any())
|
@if (Model.Installed.Any())
|
||||||
{
|
{
|
||||||
<h3 class="mb-4">Installed Plugins</h3>
|
<h3 class="mb-4">Installed Plugins</h3>
|
||||||
|
|
Loading…
Add table
Reference in a new issue