From 098a7d308be58830bf2781ca9af22479a5966817 Mon Sep 17 00:00:00 2001 From: ebolo Date: Fri, 24 Jan 2025 08:18:19 +0700 Subject: [PATCH] feat: also show the file name in edit mode --- .../Pages/CaddyfileEditor/CaddyfileEditor.razor | 12 +++++------- .../Pages/CaddyfileEditor/CaddyfileEditor.razor.cs | 12 +++++++++--- .../Pages/ReverseProxies/ReverseProxyItem.razor.cs | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CaddyManager/Components/Pages/CaddyfileEditor/CaddyfileEditor.razor b/CaddyManager/Components/Pages/CaddyfileEditor/CaddyfileEditor.razor index c7d3fe1..a036b47 100644 --- a/CaddyManager/Components/Pages/CaddyfileEditor/CaddyfileEditor.razor +++ b/CaddyManager/Components/Pages/CaddyfileEditor/CaddyfileEditor.razor @@ -4,13 +4,11 @@ - @if (IsNew) - { - - } - File content + + File content diff --git a/CaddyManager/Components/Pages/CaddyfileEditor/CaddyfileEditor.razor.cs b/CaddyManager/Components/Pages/CaddyfileEditor/CaddyfileEditor.razor.cs index 1ab61ae..2772597 100644 --- a/CaddyManager/Components/Pages/CaddyfileEditor/CaddyfileEditor.razor.cs +++ b/CaddyManager/Components/Pages/CaddyfileEditor/CaddyfileEditor.razor.cs @@ -15,15 +15,21 @@ public partial class CaddyfileEditor : ComponentBase /// /// Determines if the Caddy configuration file is new /// - private bool IsNew => string.IsNullOrWhiteSpace(FileName); + private bool IsNew { get; set; } [Parameter] public string FileName { get; set; } = string.Empty; protected override Task OnInitializedAsync() { - // Load the content of the Caddy configuration file - _caddyConfigurationContent = CaddyService.GetCaddyConfigurationContent(FileName); + IsNew = string.IsNullOrWhiteSpace(FileName); + + if (!IsNew) + { + // Load the content of the Caddy configuration file + _caddyConfigurationContent = CaddyService.GetCaddyConfigurationContent(FileName); + } + return base.OnInitializedAsync(); } diff --git a/CaddyManager/Components/Pages/ReverseProxies/ReverseProxyItem.razor.cs b/CaddyManager/Components/Pages/ReverseProxies/ReverseProxyItem.razor.cs index 9a1c4e8..23d5d5f 100644 --- a/CaddyManager/Components/Pages/ReverseProxies/ReverseProxyItem.razor.cs +++ b/CaddyManager/Components/Pages/ReverseProxies/ReverseProxyItem.razor.cs @@ -13,7 +13,7 @@ public partial class ReverseProxyItem : ComponentBase private Task Edit() { - return DialogService.ShowAsync(FileName, options: new DialogOptions + return DialogService.ShowAsync("Caddy file", options: new DialogOptions { FullWidth = true, MaxWidth = MaxWidth.Medium,