2023-01-21 19:08:12 +01:00
@using BTCPayServer.Abstractions.Models
2023-05-26 16:49:32 +02:00
@using BTCPayServer.Services.Stores
2024-03-14 10:25:40 +01:00
@using BTCPayServer.Client
@using Microsoft.AspNetCore.Mvc.TagHelpers
2022-07-15 05:38:33 +02:00
@model StoreUsersViewModel
2023-05-26 16:49:32 +02:00
@inject StoreRepository StoreRepository
2018-03-23 08:24:57 +01:00
@{
2024-11-07 00:58:47 +01:00
var storeId = Model.StoreId;
2024-03-19 14:58:33 +01:00
var roles = new SelectList(
2024-03-28 01:01:34 +01:00
await StoreRepository.GetStoreRoles(storeId),
2024-03-19 14:58:33 +01:00
nameof(StoreRepository.StoreRole.Id), nameof(StoreRepository.StoreRole.Role),
Model.Role);
2024-10-17 15:51:40 +02:00
ViewData.SetActivePage(StoreNavPages.Users, StringLocalizer["Store Users"], storeId);
2024-03-19 14:58:33 +01:00
}
@section PageHeadContent {
<style>
@@media (min-width: 576px) {
#Role { width: auto !important; }
}
</style>
2018-03-23 08:24:57 +01:00
}
2024-07-25 15:46:02 +02:00
<h2 class="mb-2 mb-lg-3" text-translate="true">@ViewData["Title"]</h2>
2024-06-19 15:23:10 +02:00
<partial name="_StatusMessage" />
2018-03-23 08:24:57 +01:00
<div class="row">
2024-06-19 15:23:10 +02:00
<div class="col-xxl-constrain col-xl-8">
2024-10-25 15:48:53 +02:00
<p>@ViewLocalizer["Give other registered BTCPay Server users access to your store. See the {0} for granted permissions.", Html.ActionLink(StringLocalizer["roles"], "ListRoles", "UIStores", new { storeId })]</p>
2021-04-08 15:32:42 +02:00
@if (!ViewContext.ModelState.IsValid)
{
2023-12-21 15:43:12 +01:00
<div asp-validation-summary="All"></div>
2021-04-08 15:32:42 +02:00
}
2024-03-14 10:25:40 +01:00
<form method="post" class="d-flex flex-wrap align-items-center gap-3" permission="@Policies.CanModifyStoreSettings">
2024-10-25 15:48:53 +02:00
<input asp-for="Email" type="text" class="form-control" placeholder="@StringLocalizer["user@example.com"]" style="flex: 1 1 14rem">
2024-03-19 14:58:33 +01:00
<select asp-for="Role" class="form-select" asp-items="roles"></select>
2024-10-17 15:51:40 +02:00
<button type="submit" role="button" class="btn btn-primary text-nowrap flex-grow-1 flex-sm-grow-0" id="AddUser" text-translate="true">Add User</button>
2021-05-19 04:39:27 +02:00
</form>
2024-06-19 15:23:10 +02:00
<div class="table-responsive-md">
<table class="table table-hover">
<thead>
2021-04-08 15:32:42 +02:00
<tr>
2024-10-17 15:51:40 +02:00
<th text-translate="true">Email</th>
<th text-translate="true">Name</th>
<th text-translate="true">Role</th>
<th class="actions-col" permission="@Policies.CanModifyStoreSettings"></th>
2021-04-08 15:32:42 +02:00
</tr>
2024-06-19 15:23:10 +02:00
</thead>
<tbody id="StoreUsersList">
@foreach (var user in Model.Users)
{
<tr>
<td>@user.Email</td>
2024-06-26 10:39:22 +02:00
<td>@user.Name</td>
2024-06-19 15:23:10 +02:00
<td>@user.Role</td>
<td class="actions-col" permission="@Policies.CanModifyStoreSettings">
<div class="d-inline-flex align-items-center gap-3">
2024-10-17 15:51:40 +02:00
<a asp-action="UpdateStoreUser" asp-route-storeId="@Model.StoreId" asp-route-userId="@user.Id" data-bs-toggle="modal" data-bs-target="#EditModal" data-user-email="@user.Email" data-user-role="@user.Role" text-translate="true">Change Role</a>
2024-10-25 15:48:53 +02:00
<a asp-action="DeleteStoreUser" asp-route-storeId="@Model.StoreId" asp-route-userId="@user.Id" data-bs-toggle="modal" data-bs-target="#ConfirmModal" data-description="@StringLocalizer["This action will prevent {0} from accessing this store and its settings.", Html.Encode(user.Email)]" data-confirm-input="@StringLocalizer["REMOVE"]" text-translate="true">Remove</a>
2024-06-19 15:23:10 +02:00
</div>
</td>
</tr>
}
</tbody>
</table>
</div>
2018-03-23 08:24:57 +01:00
</div>
</div>
2021-09-07 04:55:53 +02:00
2024-10-25 15:48:53 +02:00
<partial name="_Confirm" model="@(new ConfirmModel(StringLocalizer["Remove store user"], StringLocalizer["This action will prevent the user from accessing this store and its settings. Are you sure?"], StringLocalizer["Delete"]))" permission="@Policies.CanModifyStoreSettings" />
2021-09-07 04:55:53 +02:00
2024-03-19 14:58:33 +01:00
<div class="modal fade" id="EditModal" tabindex="-1" aria-labelledby="EditTitle" aria-hidden="true" permission="@Policies.CanModifyStoreSettings">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
2024-10-17 15:51:40 +02:00
<h4 class="modal-title" id="EditTitle"><span text-translate="true">Edit</span> <span id="EditUserEmail">store user</span></h4>
2024-10-25 15:48:53 +02:00
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="@StringLocalizer["Close"]">
2024-03-19 14:58:33 +01:00
<vc:icon symbol="close" />
</button>
</div>
<form id="EditForm" method="post" rel="noreferrer noopener">
<div class="modal-body">
2024-10-17 15:51:40 +02:00
<label asp-for="Role" for="EditUserRole" class="form-label" text-translate="true">New role</label>
2024-03-19 14:58:33 +01:00
<select asp-for="Role" id="EditUserRole" class="form-select w-auto" asp-items="roles"></select>
</div>
<div class="modal-footer">
2024-10-17 15:51:40 +02:00
<button type="button" class="btn btn-secondary only-for-js" data-bs-dismiss="modal" id="EditCancel" text-translate="true">Cancel</button>
<button type="submit" class="btn btn-primary" id="EditContinue" text-translate="true">Change Role</button>
2024-03-19 14:58:33 +01:00
</div>
</form>
</div>
</div>
</div>
<script>
(function () {
const modal = document.getElementById('EditModal')
modal.addEventListener('show.bs.modal', event => {
const $target = event.relatedTarget
const $form = document.getElementById('EditForm')
const $role = document.getElementById('EditUserRole')
const $email = document.getElementById('EditUserEmail')
const { userEmail, userRole } = $target.dataset
const action = $target.dataset.action || ($target.nodeName === 'A'
? $target.getAttribute('href')
: $target.form.getAttribute('action'))
if ($form && !$form.hasAttribute('action')) $form.setAttribute('action', action)
if (userEmail) $email.textContent = userEmail
if (userRole) $role.value = userRole
});
})()
</script>
2021-09-07 04:55:53 +02:00
@section PageFootContent {
<partial name="_ValidationScriptsPartial" />
2021-12-16 11:17:02 +01:00
}