From 199ab601d5d3f798595d9fd6244f6aa503386a99 Mon Sep 17 00:00:00 2001 From: Duy Dao Date: Thu, 10 Jul 2025 21:59:39 +0700 Subject: [PATCH] chore: tweak the delete dialog --- .../CaddyReverseProxiesPage.razor.cs | 20 ++++++++++--------- .../Pages/Generic/ConfirmationDialog.razor | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CaddyManager/Components/Pages/Caddy/CaddyReverseProxies/CaddyReverseProxiesPage.razor.cs b/CaddyManager/Components/Pages/Caddy/CaddyReverseProxies/CaddyReverseProxiesPage.razor.cs index 87afdf2..f3288ae 100644 --- a/CaddyManager/Components/Pages/Caddy/CaddyReverseProxies/CaddyReverseProxiesPage.razor.cs +++ b/CaddyManager/Components/Pages/Caddy/CaddyReverseProxies/CaddyReverseProxiesPage.razor.cs @@ -2,6 +2,7 @@ using System.Globalization; using CaddyManager.Components.Pages.Generic; using CaddyManager.Contracts.Caddy; using CaddyManager.Contracts.Docker; +using Humanizer; using Microsoft.AspNetCore.Components; using MudBlazor; @@ -75,20 +76,21 @@ public partial class CaddyReverseProxiesPage : ComponentBase /// private Task Delete() { - var confWord = _selectedCaddyConfigurations.Count > 1 ? "configurations" : "configuration"; + var confWord = "configuration".ToQuantity(_selectedCaddyConfigurations.Count, ShowQuantityAs.None); - return DialogService.ShowAsync($"Delete {confWord}", options: new DialogOptions + return DialogService.ShowAsync($"Delete {_selectedCaddyConfigurations.Count} {confWord}", options: new DialogOptions { FullWidth = true, MaxWidth = MaxWidth.ExtraSmall - }, parameters: new DialogParameters + }, parameters: new DialogParameters { { - "Message", - $"Are you sure you want to delete the selected {confWord}?" + p => p.Message, + $"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()); @@ -108,9 +110,9 @@ public partial class CaddyReverseProxiesPage : ComponentBase } }) }, - { "ConfirmText", "Yes" }, - { "ConfirmColor", Color.Error }, - { "CancelText", "No" } + { p => p.ConfirmText, "Yes" }, + { p => p.ConfirmColor, Color.Error }, + { p => p.CancelText, "No" } }); } diff --git a/CaddyManager/Components/Pages/Generic/ConfirmationDialog.razor b/CaddyManager/Components/Pages/Generic/ConfirmationDialog.razor index 187b044..c9f87a5 100644 --- a/CaddyManager/Components/Pages/Generic/ConfirmationDialog.razor +++ b/CaddyManager/Components/Pages/Generic/ConfirmationDialog.razor @@ -1,6 +1,6 @@ - @Message + @Message @CancelText