Replace noob button in wallet send by an advanced settings accordion

This commit is contained in:
nicolas.dorier
2019-05-08 12:34:33 +09:00
parent d049da696c
commit 2a145f4350
3 changed files with 23 additions and 27 deletions

View File

@@ -146,7 +146,7 @@ namespace BTCPayServer.Controllers
[Route("{walletId}/send")] [Route("{walletId}/send")]
public async Task<IActionResult> WalletSend( public async Task<IActionResult> WalletSend(
[ModelBinder(typeof(WalletIdModelBinder))] [ModelBinder(typeof(WalletIdModelBinder))]
WalletId walletId, string defaultDestination = null, string defaultAmount = null, bool advancedMode = false) WalletId walletId, string defaultDestination = null, string defaultAmount = null)
{ {
if (walletId?.StoreId == null) if (walletId?.StoreId == null)
return NotFound(); return NotFound();
@@ -195,7 +195,6 @@ namespace BTCPayServer.Controllers
} }
catch (Exception ex) { model.RateError = ex.Message; } catch (Exception ex) { model.RateError = ex.Message; }
} }
model.AdvancedMode = advancedMode;
return View(model); return View(model);
} }
@@ -203,7 +202,7 @@ namespace BTCPayServer.Controllers
[Route("{walletId}/send")] [Route("{walletId}/send")]
public async Task<IActionResult> WalletSend( public async Task<IActionResult> WalletSend(
[ModelBinder(typeof(WalletIdModelBinder))] [ModelBinder(typeof(WalletIdModelBinder))]
WalletId walletId, WalletSendModel vm, string command = null) WalletId walletId, WalletSendModel vm)
{ {
if (walletId?.StoreId == null) if (walletId?.StoreId == null)
return NotFound(); return NotFound();
@@ -214,13 +213,6 @@ namespace BTCPayServer.Controllers
if (network == null) if (network == null)
return NotFound(); return NotFound();
if (command == "noob" || command == "expert")
{
ModelState.Clear();
vm.AdvancedMode = command == "expert";
return View(vm);
}
var destination = ParseDestination(vm.Destination, network.NBitcoinNetwork); var destination = ParseDestination(vm.Destination, network.NBitcoinNetwork);
if (destination == null) if (destination == null)
ModelState.AddModelError(nameof(vm.Destination), "Invalid address"); ModelState.AddModelError(nameof(vm.Destination), "Invalid address");

View File

@@ -31,7 +31,6 @@ namespace BTCPayServer.Models.WalletViewModels
[Display(Name = "Make sure no change UTXO is created")] [Display(Name = "Make sure no change UTXO is created")]
public bool NoChange { get; set; } public bool NoChange { get; set; }
public bool AdvancedMode { get; set; }
public decimal? Rate { get; set; } public decimal? Rate { get; set; }
public int Divisibility { get; set; } public int Divisibility { get; set; }
public string Fiat { get; set; } public string Fiat { get; set; }

View File

@@ -55,23 +55,28 @@
<label asp-for="SubstractFees"></label> <label asp-for="SubstractFees"></label>
<input asp-for="SubstractFees" class="form-check" /> <input asp-for="SubstractFees" class="form-check" />
</div> </div>
@if (Model.AdvancedMode)
{ <div class="card">
<div class="form-group"> <div class="card-header" id="accordian-dev-info-notification-header">
<label asp-for="NoChange"></label> <h2 class="mb-0">
<a href="https://docs.btcpayserver.org/features/wallet#make-sure-no-change-utxo-is-created-expert-mode" target="_blank"><span class="fa fa-question-circle-o" title="More information..."></span></a> <button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#accordian-advanced" aria-expanded="false" aria-controls="accordian-advanced">
<input asp-for="NoChange" class="form-check" /> Advanced settings
</button>
</h2>
</div>
<div id="accordian-advanced" class="collapse" aria-labelledby="accordian-advanced-header" data-parent="#accordian-advanced">
<div class="card-body">
<div class="form-group">
<label asp-for="NoChange"></label>
<a href="https://docs.btcpayserver.org/features/wallet#make-sure-no-change-utxo-is-created-expert-mode" target="_blank"><span class="fa fa-question-circle-o" title="More information..."></span></a>
<input asp-for="NoChange" class="form-check" />
</div>
</div>
</div>
</div>
<div class="form-group">
<button name="command" type="submit" class="btn btn-primary" style="margin-top:16px;">Confirm</button>
</div> </div>
}
<button name="command" type="submit" class="btn btn-primary">Confirm</button>
@if (Model.AdvancedMode)
{
<button name="command" type="submit" value="noob" class="btn btn-secondary">Use noob mode</button>
}
else
{
<button name="command" type="submit" value="expert" class="btn btn-secondary">Use expert mode</button>
}
</form> </form>
</div> </div>
</div> </div>