mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 21:59:48 +00:00
Added validation to the directory selection component
This commit is contained in:
parent
a75020fb9b
commit
6a31b1bfa7
@ -346,4 +346,4 @@ else
|
||||
</MudText>
|
||||
|
||||
<MudTextSwitch Label="Should we write the generated code to the file system?" Disabled="@this.IsNoneERIServerSelected" @bind-Value="@this.writeToFilesystem" LabelOn="Yes, please write or update all generated code to the file system" LabelOff="No, just show me the code" />
|
||||
<SelectDirectory Label="Base directory where to write the code" @bind-Directory="@this.baseDirectory" Disabled="@(this.IsNoneERIServerSelected || !this.writeToFilesystem)" DirectoryDialogTitle="Select the target directory for the ERI server"/>
|
||||
<SelectDirectory Label="Base directory where to write the code" @bind-Directory="@this.baseDirectory" Disabled="@(this.IsNoneERIServerSelected || !this.writeToFilesystem)" DirectoryDialogTitle="Select the target directory for the ERI server" Validation="@this.ValidateDirectory" />
|
||||
|
@ -739,6 +739,17 @@ public partial class AssistantERI : AssistantBaseCore
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string? ValidateDirectory(string path)
|
||||
{
|
||||
if(!this.writeToFilesystem)
|
||||
return null;
|
||||
|
||||
if(string.IsNullOrWhiteSpace(path))
|
||||
return "Please provide a base directory for the ERI server to write files to.";
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string GetMultiSelectionAuthText(List<Auth> selectedValues)
|
||||
{
|
||||
|
@ -4,6 +4,7 @@
|
||||
Text="@this.Directory"
|
||||
Label="@this.Label"
|
||||
ReadOnly="@true"
|
||||
Validation="@this.Validation"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentIcon="@Icons.Material.Filled.Folder"
|
||||
UserAttributes="@SPELLCHECK_ATTRIBUTES"
|
||||
|
@ -21,6 +21,9 @@ public partial class SelectDirectory : ComponentBase
|
||||
[Parameter]
|
||||
public string DirectoryDialogTitle { get; set; } = "Select Directory";
|
||||
|
||||
[Parameter]
|
||||
public Func<string, string?> Validation { get; set; } = _ => null;
|
||||
|
||||
[Inject]
|
||||
private SettingsManager SettingsManager { get; init; } = null!;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user