Skip to content

Commit

Permalink
Move CTAs to top right
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisreimann committed May 8, 2024
1 parent 086f72a commit ea066c7
Show file tree
Hide file tree
Showing 54 changed files with 898 additions and 916 deletions.
11 changes: 7 additions & 4 deletions BTCPayServer.Tests/AltcoinTests/AltcoinTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,17 @@ public async Task CanSetupWallet()
var controller = user.GetController<UIStoresController>();
var lightningVm = (LightningNodeViewModel)Assert.IsType<ViewResult>(controller.SetupLightningNode(user.StoreId, cryptoCode)).Model;
Assert.True(lightningVm.Enabled);
var response = await controller.SetLightningNodeEnabled(user.StoreId, cryptoCode, false);
Assert.IsType<RedirectToActionResult>(response);

// Get enabled state from settings
LightningSettingsViewModel lnSettingsModel;
var response = controller.LightningSettings(user.StoreId, cryptoCode);
var lnSettingsModel = (LightningSettingsViewModel)Assert.IsType<ViewResult>(response).Model;
Assert.NotNull(lnSettingsModel?.ConnectionString);
Assert.True(lnSettingsModel.Enabled);
lnSettingsModel.Enabled = false;
response = await controller.LightningSettings(lnSettingsModel);
Assert.IsType<RedirectToActionResult>(response);
response = controller.LightningSettings(user.StoreId, cryptoCode);
lnSettingsModel = (LightningSettingsViewModel)Assert.IsType<ViewResult>(response).Model;
Assert.NotNull(lnSettingsModel?.ConnectionString);
Assert.False(lnSettingsModel.Enabled);

// Setup wallet
Expand Down
5 changes: 3 additions & 2 deletions BTCPayServer.Tests/SeleniumTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,11 @@ public void AddLightningNode(string connectionType = null, bool test = true)
Assert.Contains($"{cryptoCode} Lightning node updated.", FindAlertMessage().Text);

var enabled = Driver.FindElement(By.Id($"{cryptoCode}LightningEnabled"));
if (enabled.Text == "Enable")
if (enabled.Selected == false)
{
enabled.Click();
Assert.Contains($"{cryptoCode} Lightning payments are now enabled for this store.", FindAlertMessage().Text);
Driver.FindElement(By.Id("save")).Click();
Assert.Contains($"{cryptoCode} Lightning settings successfully updated", FindAlertMessage().Text);
}
}

Expand Down
2 changes: 1 addition & 1 deletion BTCPayServer/Components/WalletNav/Default.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@model BTCPayServer.Components.WalletNav.WalletNavViewModel

<a asp-controller="UIWallets" asp-action="WalletTransactions" asp-route-walletId="@Model.WalletId" class="unobtrusive-link">
<h2 class="mb-2 mb-lg-3">@Model.Label</h2>
<h2 class="mt-lg-1">@Model.Label</h2>
<div class="text-muted fw-semibold" data-sensitive>
@DisplayFormatter.Currency(Model.Balance, Model.Network.CryptoCode)
@if (!string.IsNullOrEmpty(Model.BalanceDefaultCurrency))
Expand Down
1 change: 1 addition & 0 deletions BTCPayServer/Controllers/UIServerController.Roles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public async Task<IActionResult> CreateOrEditRole(string role)
Role = roleData.Role
});
}

[HttpPost("server/roles/{role}")]
public async Task<IActionResult> CreateOrEditRole([FromRoute] string role, UpdateRoleViewModel viewModel)
{
Expand Down
47 changes: 14 additions & 33 deletions BTCPayServer/Controllers/UIStoresController.LightningLike.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,27 @@ public async Task<IActionResult> LightningSettings(LightningSettingsViewModel vm
}

var network = _explorerProvider.GetNetwork(vm.CryptoCode);
var lnId = PaymentTypes.LN.GetPaymentMethodId(network.CryptoCode);
var lnurlId = PaymentTypes.LNURL.GetPaymentMethodId(network.CryptoCode);

var lightning = GetConfig<LightningPaymentMethodConfig>(lnId, store);
if (lightning == null)
return NotFound();

var needUpdate = false;
var blob = store.GetStoreBlob();
blob.LightningDescriptionTemplate = vm.LightningDescriptionTemplate ?? string.Empty;
blob.LightningAmountInSatoshi = vm.LightningAmountInSatoshi;
blob.LightningPrivateRouteHints = vm.LightningPrivateRouteHints;
blob.OnChainWithLnInvoiceFallback = vm.OnChainWithLnInvoiceFallback;
var lnurlId = PaymentTypes.LNURL.GetPaymentMethodId(vm.CryptoCode);
blob.SetExcluded(lnurlId, !vm.LNURLEnabled);

// Lightning
blob.SetExcluded(lnId, !vm.Enabled);

// LNURL
blob.SetExcluded(lnurlId, !vm.LNURLEnabled || !vm.Enabled);

var lnurl = GetConfig<LNURLPaymentMethodConfig>(PaymentTypes.LNURL.GetPaymentMethodId(vm.CryptoCode), store);
var lnurl = GetConfig<LNURLPaymentMethodConfig>(lnurlId, store);
if (lnurl is null || (
lnurl.UseBech32Scheme != vm.LNURLBech32Mode ||
lnurl.LUD12Enabled != vm.LUD12Enabled))
Expand Down Expand Up @@ -284,36 +295,6 @@ public async Task<IActionResult> LightningSettings(LightningSettingsViewModel vm
return RedirectToAction(nameof(LightningSettings), new { vm.StoreId, vm.CryptoCode });
}

[HttpPost("{storeId}/lightning/{cryptoCode}/status")]
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Cookie)]
public async Task<IActionResult> SetLightningNodeEnabled(string storeId, string cryptoCode, bool enabled)
{
var store = HttpContext.GetStoreData();
if (store == null)
return NotFound();

var network = _explorerProvider.GetNetwork(cryptoCode);
if (network == null)
return NotFound();

var lightning = GetConfig<LightningPaymentMethodConfig>(PaymentTypes.LN.GetPaymentMethodId(cryptoCode), store);
if (lightning == null)
return NotFound();

var paymentMethodId = PaymentTypes.LN.GetPaymentMethodId(network.CryptoCode);
var storeBlob = store.GetStoreBlob();
storeBlob.SetExcluded(paymentMethodId, !enabled);
if (!enabled)
{
storeBlob.SetExcluded(PaymentTypes.LNURL.GetPaymentMethodId(network.CryptoCode), true);
}
store.SetStoreBlob(storeBlob);
await _storeRepo.UpdateStore(store);
TempData[WellKnownTempData.SuccessMessage] = $"{network.CryptoCode} Lightning payments are now {(enabled ? "enabled" : "disabled")} for this store.";

return RedirectToAction(nameof(LightningSettings), new { storeId, cryptoCode });
}

private bool CanUseInternalLightning(string cryptoCode)
{
return _lightningNetworkOptions.InternalLightningByCryptoCode.ContainsKey(cryptoCode.ToUpperInvariant()) && (User.IsInRole(Roles.ServerAdmin) || _policiesSettings.AllowLightningInternalNodeForAll);
Expand Down
38 changes: 19 additions & 19 deletions BTCPayServer/Views/Shared/CreateOrEditRole.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,35 @@
var storeId = Context.GetRouteValue("storeId") as string;
if (storeId is null)
ViewData.SetActivePage(ServerNavPages.Roles, role is null ? "Create role" : "Update role");

else
{
ViewData.SetActivePage(StoreNavPages.Roles, role is null ? "Create role" : "Update role");
}
var storePolicies = Policies.AllPolicies.Where(Policies.IsStorePolicy).ToArray();

}

<h3 class="mb-4">@ViewData["Title"]</h3>
<form method="post">
<div class="sticky-header">
<h2>@ViewData["Title"]</h2>
<button id="Save" type="submit" class="btn btn-primary" name="command" value="Save">Save</button>
</div>

<div class="row">
<div class="col-xxl-constrain">
<form method="post">
<div class="row">
<div class="col-xxl-constrain">
<div asp-validation-summary="ModelOnly"></div>

<div class="form-group" style="max-width:320px">
<label asp-for="Role" class="form-label"></label>
@if (role == null)
{
<input asp-for="Role" required="required" class="form-control" />
}
else
{
<input type="hidden" asp-for="Role"/>
<input required="required" class="form-control" disabled value="@Model.Role" />
}
<span asp-validation-for="Role" class="text-danger"></span>
@if (role == null)
{
<input asp-for="Role" required="required" class="form-control" />
}
else
{
<input type="hidden" asp-for="Role" />
<input required="required" class="form-control" disabled value="@Model.Role" />
}
<span asp-validation-for="Role" class="text-danger"></span>
</div>

<h4 class="mt-4 mb-3">Permissions</h4>
Expand All @@ -62,10 +63,9 @@
}
</div>
<span asp-validation-for="Policies" class="text-danger"></span>
<button id="Save" type="submit" class="btn btn-primary" name="command" value="Save">Save</button>
</form>
</div>
</div>
</div>
</form>

@{
void RenderTree(KeyValuePair<string, HashSet<string>> policy, KeyValuePair<string, HashSet<string>>[] storePolicyMap, bool isChecked)
Expand Down
6 changes: 3 additions & 3 deletions BTCPayServer/Views/Shared/Crowdfund/UpdateCrowdfund.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
}

<form method="post" permissioned="@Policies.CanModifyStoreSettings">
<div class="sticky-header d-sm-flex align-items-center justify-content-between">
<h2 class="mb-0">@ViewData["Title"]</h2>
<div class="d-flex gap-3 mt-3 mt-sm-0">
<div class="sticky-header">
<h2>@ViewData["Title"]</h2>
<div>
<button type="submit" class="btn btn-primary order-sm-1" id="SaveSettings">Save</button>
@if (Model.Archived)
{
Expand Down
1 change: 0 additions & 1 deletion BTCPayServer/Views/Shared/EmailsBody.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
</div>
</div>
</div>
<button type="submit" class="btn btn-primary mt-2" name="command" value="Save" id="Save">Save</button>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion BTCPayServer/Views/Shared/EmailsTest.cshtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@model BTCPayServer.Models.EmailsViewModel

<h3 class="mt-5 mb-3">Testing</h3>
<h3 class="my-3">Testing</h3>
<div class="row">
<div class="col-xl-10 col-xxl-constrain">
<div class="form-group">
Expand Down
6 changes: 3 additions & 3 deletions BTCPayServer/Views/Shared/ListRoles.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
var showInUseColumn = !Model.Roles.Any(r => r.IsUsed is null);
}

<div class="d-flex align-items-center justify-content-between mt-n1 mb-2 mb-lg-3">
<h3 class="mb-0">@ViewData["Title"]</h3>
<div class="sticky-header">
<h2>@ViewData["Title"]</h2>
<a class="btn btn-primary" role="button" id="CreateRole" asp-controller="@controller" asp-action="CreateOrEditRole" asp-route-role="create" asp-route-storeId="@storeId" permission="@permission">Add Role</a>
</div>
<partial name="_StatusMessage" />
Expand All @@ -56,7 +56,7 @@
<th>Permissions</th>
@if (showInUseColumn)
{
<th class="text-center">In use</th>
<th class="text-center w-75px">In use</th>
}
<th class="actions-col" permission="@permission">Actions</th>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
}

<form method="post" permissioned="@Policies.CanModifyStoreSettings">
<div class="sticky-header d-sm-flex align-items-center justify-content-between">
<h2 class="mb-0">@ViewData["Title"]</h2>
<div class="d-flex gap-3 mt-3 mt-sm-0">
<div class="sticky-header">
<h2>@ViewData["Title"]</h2>
<div>
<button type="submit" class="btn btn-primary order-sm-1" id="SaveSettings">Save</button>
@if (Model.Archived)
{
Expand Down
21 changes: 10 additions & 11 deletions BTCPayServer/Views/UIApps/CreateApp.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
<partial name="_ValidationScriptsPartial" />
}

<partial name="_StatusMessage" />

<h2 class="mt-1 mb-4">@ViewData["Title"]</h2>
<form asp-action="CreateApp" asp-route-appType="@Model.AppType">
<div class="sticky-header">
<h2>@ViewData["Title"]</h2>
<input type="submit" value="Create" class="btn btn-primary" id="Create" />
</div>
<partial name="_StatusMessage" />

<div class="row">
<div class="col-xl-8 col-xxl-constrain">
<form asp-action="CreateApp" asp-route-appType="@Model.AppType">
<div class="row">
<div class="col-xl-8 col-xxl-constrain">
<div asp-validation-summary="ModelOnly"></div>
@if (string.IsNullOrEmpty(Model.AppType))
{
Expand All @@ -27,9 +29,6 @@
<input asp-for="AppName" class="form-control" required />
<span asp-validation-for="AppName" class="text-danger"></span>
</div>
<div class="form-group mt-4">
<input type="submit" value="Create" class="btn btn-primary" id="Create" />
</div>
</form>
</div>
</div>
</div>
</form>

0 comments on commit ea066c7

Please sign in to comment.