feat: also show the file name in edit mode
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user