Issue 6918 re enable plugin (#6930)

* Added the enable button on disabled plugins

* Added the disable function and button for installed plugins

* Changes based on the coderabbitai comments

* Removed markers and added the disable in the same if block as the unistall

* Hide the uninstall button when plugin is queued for enabling

* Removed the duplicate enale function

* Removed the disable button for installed plugins

* Removed the disableplugin functions as they are no longer needed

* Trigger CI pipeline after dotnet restore

* reverted the git ignore
This commit is contained in:
monicamuyama
2025-11-21 14:23:12 +03:00
committed by GitHub
parent 0a518320ea
commit 5a487985f4
5 changed files with 47 additions and 10 deletions

View File

@@ -86,6 +86,20 @@ namespace BTCPayServer.Controllers
return RedirectToAction("ListPlugins");
}
[HttpPost("server/plugins/enable")]
public IActionResult EnablePlugin(
[FromServices] PluginService pluginService, string plugin)
{
pluginService.EnablePlugin(plugin);
TempData.SetStatusMessageModel(new StatusMessageModel
{
Message = StringLocalizer["Plugin scheduled to be enabled."].Value,
Severity = StatusMessageModel.StatusSeverity.Success
});
return RedirectToAction("ListPlugins");
}
[HttpPost("server/plugins/cancel")]
public IActionResult CancelPluginCommands(
[FromServices] PluginService pluginService, string plugin)

View File

@@ -491,6 +491,7 @@ namespace BTCPayServer.Plugins
QueueCommands(pluginDir, ("disable", plugin));
}
// Loads the list of disabled plugins from the file
private static HashSet<string> GetDisabledPluginIdentifiers(string pluginsFolder)
{

View File

@@ -188,6 +188,10 @@ namespace BTCPayServer.Plugins
PluginManager.QueueCommands(dest, ("delete", plugin));
}
public void EnablePlugin(string plugin){
PluginManager.QueueCommands(_dataDirectories.Value.PluginDir, ("enable", plugin));
}
public class AvailablePlugin
{
public string Identifier { get; set; }

View File

@@ -904,6 +904,7 @@ namespace BTCPayServer.Services
"Mark as seen": "",
"Mark as settled": "",
"Marked for deletion": "",
"Marked for enabling": "",
"Master fingerprint": "",
"Max": "",
"Max sats": "",
@@ -1143,6 +1144,7 @@ namespace BTCPayServer.Services
"Please, confirm on the device first...": "",
"Please, enter the passphrase on the device.": "",
"Plugin action cancelled.": "",
"Plugin scheduled to be enabled.": "",
"Plugin scheduled to be installed.": "",
"Plugin scheduled to be uninstalled.": "",
"Plugin server": "",

View File

@@ -103,17 +103,31 @@
</span>
@{
var uninstalled = Model.Commands.Any(c => c.plugin == plugin && c.command == "delete");
var enabled = Model.Commands.Any(c => c.plugin == plugin && c.command == "enable");
}
<form asp-action="UnInstallPlugin" asp-route-plugin="@plugin">
@if (uninstalled)
{
<button type="submit" class="btn btn-sm btn-outline-danger" disabled text-translate="true">Marked for deletion</button>
}
else
{
<button type="submit" class="btn btn-sm btn-outline-danger" text-translate="true">Uninstall</button>
}
</form>
<div class="d-flex gap-2">
<form asp-action="EnablePlugin" asp-route-plugin="@plugin">
@if (enabled)
{
<button type="submit" class="btn btn-sm btn-outline-primary" disabled text-translate="true">Marked for enabling</button>
}
else if (!uninstalled)
{
<button type="submit" class="btn btn-sm btn-outline-primary" text-translate="true">Enable</button>
}
</form>
<form asp-action="UnInstallPlugin" asp-route-plugin="@plugin">
@if (uninstalled)
{
<button type="submit" class="btn btn-sm btn-outline-danger" disabled text-translate="true">Marked for deletion</button>
}
else if (!enabled)
{
<button type="submit" class="btn btn-sm btn-outline-danger" text-translate="true">Uninstall</button>
}
</form>
</div>
</div>
</li>
}
@@ -287,6 +301,8 @@
</form>
}
}
@if (DependentOn(plugin.Identifier))
{
<button type="button" class="btn btn-outline-danger d-flex align-items-center gap-3" data-bs-toggle="tooltip" title="This plugin cannot be uninstalled as it is depended on by other plugins.">