mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-02-01 12:24:24 +01:00
- Removed the JS functions created by me
- Used the same logic as the StoreUsers.cshtml page to design the remove modal - Removed the unit test part related to the deletion of email rules, since using this way of remove above is not possible to unit test, at least I didn't found an example to look at.
This commit is contained in:
@@ -899,26 +899,6 @@ namespace BTCPayServer.Tests
|
||||
// Validate that the email is updated in the list of email rules
|
||||
Assert.Contains("changedagain@gmail.com", s.Driver.PageSource);
|
||||
Assert.DoesNotContain("statuschanged@gmail.com", s.Driver.PageSource);
|
||||
|
||||
// Delete both email rules
|
||||
var deleteLinks = s.Driver.FindElements(By.XPath("//a[contains(text(), 'Delete')]"));
|
||||
Assert.True(deleteLinks.Count == 2, "Expected exactly two delete buttons but found a different number.");
|
||||
|
||||
deleteLinks[0].Click();
|
||||
|
||||
var confirmDelete = s.Driver.FindElement(By.XPath("//*[@id='deleteConfirmation']//button[contains(text(), 'Delete')]"));
|
||||
confirmDelete.Click();
|
||||
|
||||
deleteLinks = s.Driver.FindElements(By.XPath("//a[contains(text(), 'Delete')]")); // Refresh list
|
||||
Assert.True(deleteLinks.Count == 1, "Expected one delete button remaining.");
|
||||
|
||||
deleteLinks[0].Click();
|
||||
|
||||
confirmDelete = s.Driver.FindElement(By.XPath("//*[@id='deleteConfirmation']//button[contains(text(), 'Delete')]"));
|
||||
confirmDelete.Click();
|
||||
|
||||
// Validate that there are no more rules
|
||||
Assert.Contains("There are no rules yet.", s.Driver.PageSource);
|
||||
}
|
||||
|
||||
[Fact(Timeout = TestTimeout)]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
@using BTCPayServer.Abstractions.Models
|
||||
@using BTCPayServer.Client
|
||||
@using BTCPayServer.TagHelpers
|
||||
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@@ -17,10 +18,12 @@
|
||||
</ol>
|
||||
<h2>@ViewData["Title"]</h2>
|
||||
</nav>
|
||||
<a id="CreateEmailRule" permission="@Policies.CanModifyStoreSettings" asp-action="StoreEmailRulesCreate" asp-route-storeId="@storeId"
|
||||
class="btn btn-primary" role="button">
|
||||
Create Email Rule
|
||||
</a>
|
||||
<form method="post" permission="@Policies.CanModifyStoreSettings">
|
||||
<a id="CreateEmailRule" permission="@Policies.CanModifyStoreSettings" asp-action="StoreEmailRulesCreate" asp-route-storeId="@storeId"
|
||||
class="btn btn-primary" role="button">
|
||||
Create Email Rule
|
||||
</a>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<partial name="_StatusMessage" />
|
||||
@@ -28,24 +31,6 @@
|
||||
Email rules allow BTCPay Server to send customized emails from your store based on events.
|
||||
</p>
|
||||
|
||||
<div id="overlay" style="display: none; position: fixed; top: 0; left: 0;
|
||||
width: 100vw; height: 100vh; background-color: rgba(0,0,0,0.5);
|
||||
z-index: 9998;"></div>
|
||||
|
||||
<div id="deleteConfirmation" class="modal-content" style="display: none;position: fixed; top: 50%; left: 50%;
|
||||
transform: translate(-50%, -50%); background-color: black; color: white; padding: 20px;
|
||||
border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.3); z-index: 9999; width: 500px;">
|
||||
<div class="modal-header"><h4 class="modal-title">Delete rule</h4></div><br />
|
||||
<p style="margin-bottom: 20px;">This rule will be deleted. Are you sure?</p>
|
||||
<br />
|
||||
<div style="display: flex; justify-content: flex-end; gap: 10px;">
|
||||
<button onclick="cancelDelete()" class="btn btn-secondary only-for-js">Cancel</button>
|
||||
<button onclick="confirmDelete()" class="btn btn-danger">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button onclick="showConfirmation()" style="display: none;">Delete Item</button>
|
||||
|
||||
@if (Model.Any())
|
||||
{
|
||||
<div class="table-responsive">
|
||||
@@ -56,7 +41,7 @@
|
||||
<th>Customer Email</th>
|
||||
<th>To</th>
|
||||
<th>Subject</th>
|
||||
<th>Actions</th>
|
||||
<th class="actions-col" permission="@Policies.CanModifyStoreSettings"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -67,12 +52,11 @@
|
||||
<td>@(rule.value.CustomerEmail ? "Yes" : "No")</td>
|
||||
<td>@rule.value.To</td>
|
||||
<td>@rule.value.Subject</td>
|
||||
<td>
|
||||
<a asp-action="StoreEmailRulesEdit" asp-route-storeId="@storeId" asp-route-ruleIndex="@rule.index">Edit</a>
|
||||
-
|
||||
<form id="deleteRule" asp-action="StoreEmailRulesDelete" asp-route-storeId="@storeId" asp-route-ruleIndex="@rule.index" method="post" style="display:inline;">
|
||||
<a href="#" class="text-danger" onclick="event.preventDefault(); showConfirmation();">Delete</a>
|
||||
</form>
|
||||
<td class="actions-col" permission="@Policies.CanModifyStoreSettings">
|
||||
<div class="d-inline-flex align-items-center gap-3">
|
||||
<a asp-action="StoreEmailRulesEdit" asp-route-storeId="@storeId" asp-route-ruleIndex="@rule.index">Edit</a>
|
||||
<a asp-action="StoreEmailRulesDelete" asp-route-storeId="@storeId" asp-route-ruleIndex="@rule.index" data-bs-toggle="modal" data-bs-target="#ConfirmModal" data-description="@StringLocalizer["This action will remove the rule with the trigger {0}.", Html.Encode(rule.value.Trigger)]" data-confirm-input="@StringLocalizer["REMOVE"]" text-translate="true">Remove</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@@ -87,24 +71,4 @@ else
|
||||
</p>
|
||||
}
|
||||
|
||||
<script>
|
||||
function showConfirmation() {
|
||||
document.getElementById('overlay').style.display = 'block';
|
||||
document.getElementById('deleteConfirmation').style.display = 'block';
|
||||
}
|
||||
|
||||
function cancelDelete() {
|
||||
document.getElementById('overlay').style.display = 'none';
|
||||
document.getElementById('deleteConfirmation').style.display = 'none';
|
||||
}
|
||||
|
||||
function confirmDelete() {
|
||||
document.getElementById('deleteRule').submit();
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', function(event) {
|
||||
if (event.key === 'Escape') {
|
||||
cancelDelete();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<partial name="_Confirm" model="@(new ConfirmModel(StringLocalizer["Remove email rule"], StringLocalizer["This action will remove this rule. Are you sure?"], StringLocalizer["Delete"]))" permission="@Policies.CanModifyStoreSettings" />
|
||||
|
||||
Reference in New Issue
Block a user