feat: also show the file name in edit mode

This commit is contained in:
2025-01-24 08:18:19 +07:00
parent 98977c8ed5
commit 098a7d308b
3 changed files with 15 additions and 11 deletions

View File

@@ -4,13 +4,11 @@
<MudDialog>
<DialogContent>
@if (IsNew)
{
<MudTextField @bind-Value="FileName" Label="File name" Variant="Variant.Outlined"
Style="margin-bottom: 16px;"
ShrinkLabel="true"></MudTextField>
}
<MudText Typo="Typo.caption" Style="padding-left: 8px; padding-bottom: 4px;">File content</MudText>
<MudTextField @bind-Value="FileName" Label="File name" Variant="Variant.Outlined"
Style="margin-bottom: 8px;"
ShrinkLabel="true"
Disabled="@(!IsNew)"></MudTextField>
<MudText Typo="Typo.caption" Style="padding-left: 18px; padding-bottom: 8px;">File content</MudText>
<StandaloneCodeEditor ConstructionOptions="@EditorConstructionOptions"
CssClass="caddy-file-editor"></StandaloneCodeEditor>
</DialogContent>

View File

@@ -15,15 +15,21 @@ public partial class CaddyfileEditor : ComponentBase
/// <summary>
/// Determines if the Caddy configuration file is new
/// </summary>
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();
}

View File

@@ -13,7 +13,7 @@ public partial class ReverseProxyItem : ComponentBase
private Task Edit()
{
return DialogService.ShowAsync<CaddyfileEditor.CaddyfileEditor>(FileName, options: new DialogOptions
return DialogService.ShowAsync<CaddyfileEditor.CaddyfileEditor>("Caddy file", options: new DialogOptions
{
FullWidth = true,
MaxWidth = MaxWidth.Medium,