chore: tweak the delete dialog
All checks were successful
Caddy Manager CI build / docker (push) Successful in 2m52s

This commit is contained in:
2025-07-10 21:59:39 +07:00
parent 84e70b724a
commit 199ab601d5
2 changed files with 12 additions and 10 deletions

View File

@@ -2,6 +2,7 @@ using System.Globalization;
using CaddyManager.Components.Pages.Generic; using CaddyManager.Components.Pages.Generic;
using CaddyManager.Contracts.Caddy; using CaddyManager.Contracts.Caddy;
using CaddyManager.Contracts.Docker; using CaddyManager.Contracts.Docker;
using Humanizer;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using MudBlazor; using MudBlazor;
@@ -75,20 +76,21 @@ public partial class CaddyReverseProxiesPage : ComponentBase
/// </summary> /// </summary>
private Task Delete() private Task Delete()
{ {
var confWord = _selectedCaddyConfigurations.Count > 1 ? "configurations" : "configuration"; var confWord = "configuration".ToQuantity(_selectedCaddyConfigurations.Count, ShowQuantityAs.None);
return DialogService.ShowAsync<ConfirmationDialog>($"Delete {confWord}", options: new DialogOptions return DialogService.ShowAsync<ConfirmationDialog>($"Delete {_selectedCaddyConfigurations.Count} {confWord}", options: new DialogOptions
{ {
FullWidth = true, FullWidth = true,
MaxWidth = MaxWidth.ExtraSmall MaxWidth = MaxWidth.ExtraSmall
}, parameters: new DialogParameters }, parameters: new DialogParameters<ConfirmationDialog>
{ {
{ {
"Message", p => p.Message,
$"Are you sure you want to delete the selected {confWord}?" $"Are you sure to delete the selected {confWord}?\n\n" +
$"{string.Join("\n", _selectedCaddyConfigurations.Select(c => $"\t{c}"))}"
}, },
{ {
"OnConfirm", EventCallback.Factory.Create(this, () => p => p.OnConfirm, EventCallback.Factory.Create(this, () =>
{ {
var response = CaddyService.DeleteCaddyConfigurations(_selectedCaddyConfigurations.ToList()); var response = CaddyService.DeleteCaddyConfigurations(_selectedCaddyConfigurations.ToList());
@@ -108,9 +110,9 @@ public partial class CaddyReverseProxiesPage : ComponentBase
} }
}) })
}, },
{ "ConfirmText", "Yes" }, { p => p.ConfirmText, "Yes" },
{ "ConfirmColor", Color.Error }, { p => p.ConfirmColor, Color.Error },
{ "CancelText", "No" } { p => p.CancelText, "No" }
}); });
} }

View File

@@ -1,6 +1,6 @@
<MudDialog> <MudDialog>
<DialogContent> <DialogContent>
<MudText Typo="Typo.body1">@Message</MudText> <MudText Typo="Typo.body1" Style="white-space: pre-wrap;">@Message</MudText>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<MudButton OnClick="Cancel">@CancelText</MudButton> <MudButton OnClick="Cancel">@CancelText</MudButton>