Remove warning and improve UI of permission selection

This commit is contained in:
nicolas.dorier 2020-03-20 19:39:02 +09:00
parent 53e7c84e73
commit 094307d688
No known key found for this signature in database
GPG Key ID: 6618763EF09186FE
2 changed files with 127 additions and 124 deletions

View File

@ -8,8 +8,8 @@
}
<h4>@ViewData["Title"]</h4>
<partial name="_StatusMessage"/>
<p >
<partial name="_StatusMessage" />
<p>
Generate a new api key to use BTCPay through its API.
</p>
<div class="row">
@ -29,80 +29,81 @@
@for (int i = 0; i < Model.PermissionValues.Count; i++)
{
@if (!Model.PermissionValues[i].Forbidden)
@if (!Model.PermissionValues[i].Forbidden)
{
<div class="list-group-item form-group">
<div class="list-group-item form-group">
<div class="form-check">
<input type="hidden" asp-for="PermissionValues[i].Permission">
<input id="@Model.PermissionValues[i].Permission" type="checkbox" asp-for="PermissionValues[i].Value" class="form-check-inline" />
<label asp-for="PermissionValues[i].Value" class="h5">@Model.PermissionValues[i].Title</label>
<input id="@Model.PermissionValues[i].Permission" type="checkbox" asp-for="PermissionValues[i].Value" class="form-check-input" />
<label for="@Model.PermissionValues[i].Permission" class="h5 form-check-label">@Model.PermissionValues[i].Title</label>
<span asp-validation-for="PermissionValues[i].Value" class="text-danger"></span>
<p>@Model.PermissionValues[i].Description</p>
<span class="form-text text-muted">@Model.PermissionValues[i].Description</span>
</div>
</div>
}
}
@if (Model.StoreMode == ManageController.AddApiKeyViewModel.ApiKeyStoreMode.AllStores)
{
<div class="list-group-item form-group">
<input id="@Model.StoreManagementPermission.Permission" type="checkbox" asp-for="@Model.StoreManagementPermission.Value" class="form-check-inline" />
<label asp-for="StoreManagementPermission" class="h5">@Model.StoreManagementPermission.Title</label>
<span asp-validation-for="StoreManagementPermission" class="text-danger"></span>
<p class="mb-0">@Model.StoreManagementPermission.Description</p>
<button type="submit" class="btn btn-link" name="command" value="change-store-mode">Give permission to specific stores instead</button>
</div>
<div class="list-group-item form-group">
<div class="form-check">
<input id="@Model.StoreManagementPermission.Permission" type="checkbox" asp-for="@Model.StoreManagementPermission.Value" class="form-check-input" />
<label for="@Model.StoreManagementPermission.Permission" class="h5 form-check-label">@Model.StoreManagementPermission.Title</label>
<button type="submit" class="btn btn-link" name="command" value="change-store-mode">select specific stores...</button>
<span asp-validation-for="StoreManagementPermission" class="text-danger"></span>
<span class="form-text text-muted"><span>@Model.StoreManagementPermission.Description</span></span>
</div>
</div>
}
else if (Model.StoreMode == ManageController.AddApiKeyViewModel.ApiKeyStoreMode.Specific)
{
<div class="list-group-item p-0 border-0 mb-2">
<li class="list-group-item ">
<h5 class="mb-1">@Model.StoreManagementSelectivePermission.Title</h5>
<p class="mb-0">@Model.StoreManagementSelectivePermission.Description</p>
<button type="submit" class="btn btn-link" name="command" value="change-store-mode">Give permission to all stores instead</button>
</li>
@if (!Model.Stores.Any())
<li class="list-group-item ">
<h5 class="mb-1">@Model.StoreManagementSelectivePermission.Title</h5>
<span class="form-text text-muted">@Model.StoreManagementSelectivePermission.Description</span>
<button type="submit" class="btn btn-link" name="command" value="change-store-mode">Give permission to all stores instead</button>
</li>
@if (!Model.Stores.Any())
{
<li class="list-group-item alert-warning">
You currently have no stores configured.
</li>
<li class="list-group-item alert-warning">
You currently have no stores configured.
</li>
}
@for (var index = 0; index < Model.SpecificStores.Count; index++)
@for (var index = 0; index < Model.SpecificStores.Count; index++)
{
<div class="list-group-item transaction-output-form p-0 pl-lg-2">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-10 py-2 ">
<div class="form-group my-0">
@if (Model.SpecificStores[index] == null)
<div class="list-group-item transaction-output-form p-0 pl-lg-2">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-10 py-2 ">
<div class="form-group my-0">
@if (Model.SpecificStores[index] == null)
{
<select asp-for="SpecificStores[index]" class="form-control" asp-items="@(new SelectList(Model.Stores.Where(data => !Model.SpecificStores.Contains(data.Id)), nameof(StoreData.Id), nameof(StoreData.StoreName)))"></select>
<select asp-for="SpecificStores[index]" class="form-control" asp-items="@(new SelectList(Model.Stores.Where(data => !Model.SpecificStores.Contains(data.Id)), nameof(StoreData.Id), nameof(StoreData.StoreName)))"></select>
}
else
{
var store = Model.Stores.SingleOrDefault(data => data.Id == Model.SpecificStores[index]);
<select asp-for="SpecificStores[index]" class="form-control" asp-items="@(new SelectList(new[] {store}, nameof(StoreData.Id), nameof(StoreData.StoreName), store.Id))"></select>
<select asp-for="SpecificStores[index]" class="form-control" asp-items="@(new SelectList(new[] {store}, nameof(StoreData.Id), nameof(StoreData.StoreName), store.Id))"></select>
}
<span asp-validation-for="SpecificStores[index]" class="text-danger"></span>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-2 pull-right">
<button type="submit" title="Remove Store Permission" name="command" value="@($"remove-store:{index}")"
class="d-block d-lg-none d-xl-none btn btn-danger mb-2 ml-2">
Remove
</button>
<button type="submit" title="Remove Store Permission" name="command" value="@($"remove-store:{index}")"
class="d-none d-lg-block remove-btn text-decoration-none h-100 align-middle btn text-danger btn-link fa fa-times rounded-0 pull-right">
</button>
</div>
</div>
<span asp-validation-for="SpecificStores[index]" class="text-danger"></span>
</div>
}
@if (Model.SpecificStores.Count < Model.Stores.Length)
{
<div class="list-group-item">
<button type="submit" name="command" value="add-store" class="ml-1 btn btn-secondary">Add another store </button>
</div>
}
</div>
<div class="col-sm-12 col-md-12 col-lg-2 pull-right">
<button type="submit" title="Remove Store Permission" name="command" value="@($"remove-store:{index}")"
class="d-block d-lg-none d-xl-none btn btn-danger mb-2 ml-2">
Remove
</button>
<button type="submit" title="Remove Store Permission" name="command" value="@($"remove-store:{index}")"
class="d-none d-lg-block remove-btn text-decoration-none h-100 align-middle btn text-danger btn-link fa fa-times rounded-0 pull-right">
</button>
</div>
</div>
</div>
}
@if (Model.SpecificStores.Count < Model.Stores.Length)
{
<div class="list-group-item">
<button type="submit" name="command" value="add-store" class="ml-1 btn btn-secondary">Add another store </button>
</div>
}
}
<button type="submit" class="btn btn-primary" id="Generate">Generate API Key</button>
</form>
@ -113,12 +114,13 @@
@await Html.PartialAsync("_ValidationScriptsPartial")
<style>
.remove-btn{
.remove-btn {
font-size: 1.5rem;
border-radius: 0;
}
.remove-btn:hover{
background-color: #CCCCCC;
}
.remove-btn:hover {
background-color: #CCCCCC;
}
</style>
}

View File

@ -10,7 +10,7 @@
var hasStorePermission = permissions.Any(p => p.Policy == Policies.CanModifyStoreSettings);
}
<partial name="_StatusMessage"/>
<partial name="_StatusMessage" />
<form method="post" asp-action="AuthorizeAPIKey">
<input type="hidden" asp-for="Permissions" value="@Model.Permissions" />
<input type="hidden" asp-for="Strict" value="@Model.Strict" />
@ -38,112 +38,113 @@
</div>
@if (!permissions.Any())
{
<div class="list-group-item form-group">
<p>There are no associated permissions to the API key being requested here. The application cannot do anything with your BTCPay account other than validating your account exists.</p>
</div>
<div class="list-group-item form-group">
<p>There are no associated permissions to the API key being requested here. The application cannot do anything with your BTCPay account other than validating your account exists.</p>
</div>
}
@for (int i = 0; i < Model.PermissionValues.Count; i++)
{
<div class="list-group-item form-group">
<div class="list-group-item form-group">
<div class="form-check">
<input type="hidden" asp-for="PermissionValues[i].Permission">
@if (Model.Strict)
{
<input id="@Model.PermissionValues[i].Permission" type="hidden" asp-for="PermissionValues[i].Value" />
<input type="checkbox" class="form-check-inline" checked="@Model.PermissionValues[i].Value" disabled />
<input id="@Model.PermissionValues[i].Permission" type="hidden" asp-for="PermissionValues[i].Value" />
<input type="checkbox" checked="@Model.PermissionValues[i].Value" disabled class="form-check-input" />
}
else
{
<input id="@Model.PermissionValues[i].Permission" type="checkbox" asp-for="PermissionValues[i].Value" class="form-check-inline" />
<input id="@Model.PermissionValues[i].Permission" type="checkbox" asp-for="PermissionValues[i].Value" class="form-check-input" />
}
<label asp-for="PermissionValues[i].Value" class="h5">@Model.PermissionValues[i].Title</label>
<label for="@Model.PermissionValues[i].Permission" class="h5 form-check-label">@Model.PermissionValues[i].Title</label>
@if (Model.PermissionValues[i].Forbidden)
{
<br />
<span class="text-danger">
This permission is not available for your account.
</span>
<br />
<span class="text-danger">
This permission is not available for your account.
</span>
}
<p>@Model.PermissionValues[i].Description</p>
<span class="form-text text-muted">@Model.PermissionValues[i].Description</span>
</div>
</div>
}
@if (hasStorePermission)
{
@if (Model.StoreMode == ManageController.AddApiKeyViewModel.ApiKeyStoreMode.AllStores)
@if (Model.StoreMode == ManageController.AddApiKeyViewModel.ApiKeyStoreMode.AllStores)
{
<div class="list-group-item form-group">
@if (Model.Strict)
<div class="list-group-item form-group">
<div class="form-check">
@if (Model.Strict)
{
<input id="@Model.StoreManagementPermission.Permission" type="hidden" asp-for="StoreManagementPermission.Value" />
<input type="checkbox" class="form-check-inline" checked="@Model.StoreManagementPermission.Value" disabled />
<input id="@Model.StoreManagementPermission.Permission" type="hidden" asp-for="StoreManagementPermission.Value" />
<input type="checkbox" checked="@Model.StoreManagementPermission.Value" disabled class="form-check-input" />
}
else
{
<input id="@Model.StoreManagementPermission.Permission" type="checkbox" asp-for="StoreManagementPermission.Value" class="form-check-inline" />
<input id="@Model.StoreManagementPermission.Permission" type="checkbox" asp-for="StoreManagementPermission.Value" class="form-check-input" />
}
<label asp-for="StoreManagementPermission" class="h5">@Model.StoreManagementPermission.Title</label>
<br />
<span asp-validation-for="StoreManagementPermission" class="text-danger"></span>
<p class="mb-0">@Model.StoreManagementPermission.Description</p>
@if (Model.SelectiveStores)
<label for="@Model.StoreManagementPermission.Permission" class="h5 form-check-label">@Model.StoreManagementPermission.Title</label>
@if (Model.SelectiveStores)
{
<button type="submit" class="btn btn-link" name="command" value="change-store-mode">Give permission to specific stores instead</button>
<button type="submit" class="btn btn-link" name="command" value="change-store-mode">select specific stores...</button>
}
</div>
<br />
<span asp-validation-for="StoreManagementPermission" class="text-danger"></span>
<span class="form-text text-muted">@Model.StoreManagementPermission.Description</span>
</div>
</div>
}
else if (Model.StoreMode == ManageController.AddApiKeyViewModel.ApiKeyStoreMode.Specific)
{
<div class="list-group-item p-0 border-0 mb-2">
<li class="list-group-item">
<h5 class="mb-1">@Model.StoreManagementSelectivePermission.Title</h5>
<p class="mb-0">@Model.StoreManagementSelectivePermission.Description</p>
<button type="submit" class="btn btn-link" name="command" value="change-store-mode">Give permission to all stores instead</button>
</li>
@if (!Model.Stores.Any())
<div class="list-group-item">
<h5 class="mb-1">@Model.StoreManagementSelectivePermission.Title</h5>
<span class="form-text text-muted">@Model.StoreManagementSelectivePermission.Description</span>
<button type="submit" class="btn btn-link" name="command" value="change-store-mode">Give permission to all stores instead</button>
</div>
@if (!Model.Stores.Any())
{
<li class="list-group-item alert-warning">
You currently have no stores configured.
</li>
<div class="list-group-item alert-warning">
You currently have no stores configured.
</div>
}
@for (var index = 0; index < Model.SpecificStores.Count; index++)
@for (var index = 0; index < Model.SpecificStores.Count; index++)
{
<div class="list-group-item transaction-output-form p-0 pl-lg-2">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-10 py-2 ">
<div class="form-group my-0">
@if (Model.SpecificStores[index] == null)
<div class="list-group-item transaction-output-form p-0 pl-lg-2">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-10 py-2 ">
<div class="form-group my-0">
@if (Model.SpecificStores[index] == null)
{
<select asp-for="SpecificStores[index]" class="form-control" asp-items="@(new SelectList(Model.Stores.Where(data => !Model.SpecificStores.Contains(data.Id)), nameof(StoreData.Id), nameof(StoreData.StoreName)))"></select>
<select asp-for="SpecificStores[index]" class="form-control" asp-items="@(new SelectList(Model.Stores.Where(data => !Model.SpecificStores.Contains(data.Id)), nameof(StoreData.Id), nameof(StoreData.StoreName)))"></select>
}
else
{
var store = Model.Stores.SingleOrDefault(data => data.Id == Model.SpecificStores[index]);
<select asp-for="SpecificStores[index]" class="form-control" asp-items="@(new SelectList(new[] {store}, nameof(StoreData.Id), nameof(StoreData.StoreName), store.Id))"></select>
<select asp-for="SpecificStores[index]" class="form-control" asp-items="@(new SelectList(new[] {store}, nameof(StoreData.Id), nameof(StoreData.StoreName), store.Id))"></select>
}
<span asp-validation-for="SpecificStores[index]" class="text-danger"></span>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-2 pull-right">
<button type="submit" title="Remove Store Permission" name="command" value="@($"remove-store:{index}")"
class="d-block d-lg-none d-xl-none btn btn-danger mb-2 ml-2">
Remove
</button>
<button type="submit" title="Remove Store Permission" name="command" value="@($"remove-store:{index}")"
class="d-none d-lg-block remove-btn text-decoration-none h-100 align-middle btn text-danger btn-link fa fa-times rounded-0 pull-right">
</button>
</div>
</div>
</div>
}
@if (Model.SpecificStores.Count < Model.Stores.Length)
{
<div class="list-group-item">
<button type="submit" name="command" value="add-store" class="ml-1 btn btn-secondary">Add another store </button>
</div>
}
<span asp-validation-for="SpecificStores[index]" class="text-danger"></span>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-2 pull-right">
<button type="submit" title="Remove Store Permission" name="command" value="@($"remove-store:{index}")"
class="d-block d-lg-none d-xl-none btn btn-danger mb-2 ml-2">
Remove
</button>
<button type="submit" title="Remove Store Permission" name="command" value="@($"remove-store:{index}")"
class="d-none d-lg-block remove-btn text-decoration-none h-100 align-middle btn text-danger btn-link fa fa-times rounded-0 pull-right">
</button>
</div>
</div>
</div>
}
@if (Model.SpecificStores.Count < Model.Stores.Length)
{
<div class="list-group-item">
<button type="submit" name="command" value="add-store" class="ml-1 btn btn-secondary">Add another store </button>
</div>
}
}
}
</div>