Don't show "Set up a Lightning node" when LN is not supported (#3935)

See discussion here: https://github.com/btcpayserver/btcpayserver/discussions/3868
This commit is contained in:
Umar Bolatov 2022-07-06 18:38:51 -07:00 committed by GitHub
parent 09462e6877
commit efe1686c05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 18 deletions

View file

@ -24,13 +24,15 @@ namespace BTCPayServer.Controllers
var walletEnabled = derivationSchemes.Any(scheme => !string.IsNullOrEmpty(scheme.Value) && scheme.Enabled); var walletEnabled = derivationSchemes.Any(scheme => !string.IsNullOrEmpty(scheme.Value) && scheme.Enabled);
var lightningEnabled = lightningNodes.Any(ln => !string.IsNullOrEmpty(ln.Address) && ln.Enabled); var lightningEnabled = lightningNodes.Any(ln => !string.IsNullOrEmpty(ln.Address) && ln.Enabled);
var cryptoCode = _NetworkProvider.DefaultNetwork.CryptoCode;
var vm = new StoreDashboardViewModel var vm = new StoreDashboardViewModel
{ {
WalletEnabled = walletEnabled, WalletEnabled = walletEnabled,
LightningEnabled = lightningEnabled, LightningEnabled = lightningEnabled,
LightningSupported = _NetworkProvider.GetNetwork<BTCPayNetwork>(cryptoCode).SupportLightning,
StoreId = CurrentStore.Id, StoreId = CurrentStore.Id,
StoreName = CurrentStore.StoreName, StoreName = CurrentStore.StoreName,
CryptoCode = _NetworkProvider.DefaultNetwork.CryptoCode, CryptoCode = cryptoCode,
IsSetUp = walletEnabled || lightningEnabled IsSetUp = walletEnabled || lightningEnabled
}; };

View file

@ -10,6 +10,7 @@ public class StoreDashboardViewModel
public string StoreName { get; set; } public string StoreName { get; set; }
public bool WalletEnabled { get; set; } public bool WalletEnabled { get; set; }
public bool LightningEnabled { get; set; } public bool LightningEnabled { get; set; }
public bool LightningSupported { get; set; }
public bool IsSetUp { get; set; } public bool IsSetUp { get; set; }
public List<AppData> Apps { get; set; } = new(); public List<AppData> Apps { get; set; } = new();
} }

View file

@ -9,7 +9,10 @@
isLightningEnabled && isLightningEnabled &&
isLNUrlEnabled && isLNUrlEnabled &&
store.GetSupportedPaymentMethods(BTCPayNetworkProvider).OfType<LNURLPaySupportedPaymentMethod>().Any(type => type.CryptoCode == cryptoCode); store.GetSupportedPaymentMethods(BTCPayNetworkProvider).OfType<LNURLPaySupportedPaymentMethod>().Any(type => type.CryptoCode == cryptoCode);
var network = BTCPayNetworkProvider.GetNetwork<BTCPayNetwork>(cryptoCode);
} }
@if (network.SupportLightning) {
<li class="list-group-item bg-tile" id="lightning-address-option"> <li class="list-group-item bg-tile" id="lightning-address-option">
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<span class="d-flex flex-wrap flex-fill flex-column flex-sm-row"> <span class="d-flex flex-wrap flex-fill flex-column flex-sm-row">
@ -48,3 +51,5 @@
</span> </span>
</div> </div>
</li> </li>
}

View file

@ -162,24 +162,26 @@ else
</div> </div>
</div> </div>
} }
@if (!Model.LightningEnabled) @if (Model.LightningSupported) {
{ if (!Model.LightningEnabled)
<a asp-controller="UIStores" asp-action="SetupLightningNode" asp-route-storeId="@Model.StoreId" asp-route-cryptoCode="@Model.CryptoCode" id="SetupGuide-Lightning" class="list-group-item list-group-item-action d-flex align-items-center order-1"> {
<vc:icon symbol="new-wallet"/> <a asp-controller="UIStores" asp-action="SetupLightningNode" asp-route-storeId="@Model.StoreId" asp-route-cryptoCode="@Model.CryptoCode" id="SetupGuide-Lightning" class="list-group-item list-group-item-action d-flex align-items-center order-1">
<div class="content"> <vc:icon symbol="new-wallet"/>
<h5 class="mb-0">Set up a Lightning node</h5> <div class="content">
<h5 class="mb-0">Set up a Lightning node</h5>
</div>
<vc:icon symbol="caret-right"/>
</a>
}
else
{
<div class="list-group-item d-flex align-items-center" id="SetupGuide-LightningDone">
<vc:icon symbol="done"/>
<div class="content">
<h5 class="mb-0 text-success">Set up a Lightning node</h5>
</div>
</div> </div>
<vc:icon symbol="caret-right"/> }
</a>
}
else
{
<div class="list-group-item d-flex align-items-center" id="SetupGuide-LightningDone">
<vc:icon symbol="done"/>
<div class="content">
<h5 class="mb-0 text-success">Set up a Lightning node</h5>
</div>
</div>
} }
</div> </div>
} }