mirror of
				https://github.com/MindWorkAI/AI-Studio.git
				synced 2025-11-04 11:40:21 +00:00 
			
		
		
		
	Added validation to the directory selection component
This commit is contained in:
		
							parent
							
								
									a75020fb9b
								
							
						
					
					
						commit
						6a31b1bfa7
					
				@ -346,4 +346,4 @@ else
 | 
				
			|||||||
</MudText>
 | 
					</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" />
 | 
					<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" />
 | 
				
			||||||
 | 
				
			|||||||
@ -740,6 +740,17 @@ public partial class AssistantERI : AssistantBaseCore
 | 
				
			|||||||
        return null;
 | 
					        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)
 | 
					    private string GetMultiSelectionAuthText(List<Auth> selectedValues)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if(selectedValues.Count == 0)
 | 
					        if(selectedValues.Count == 0)
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,7 @@
 | 
				
			|||||||
        Text="@this.Directory"
 | 
					        Text="@this.Directory"
 | 
				
			||||||
        Label="@this.Label"
 | 
					        Label="@this.Label"
 | 
				
			||||||
        ReadOnly="@true"
 | 
					        ReadOnly="@true"
 | 
				
			||||||
 | 
					        Validation="@this.Validation"
 | 
				
			||||||
        Adornment="Adornment.Start"
 | 
					        Adornment="Adornment.Start"
 | 
				
			||||||
        AdornmentIcon="@Icons.Material.Filled.Folder"
 | 
					        AdornmentIcon="@Icons.Material.Filled.Folder"
 | 
				
			||||||
        UserAttributes="@SPELLCHECK_ATTRIBUTES"
 | 
					        UserAttributes="@SPELLCHECK_ATTRIBUTES"
 | 
				
			||||||
 | 
				
			|||||||
@ -21,6 +21,9 @@ public partial class SelectDirectory : ComponentBase
 | 
				
			|||||||
    [Parameter]
 | 
					    [Parameter]
 | 
				
			||||||
    public string DirectoryDialogTitle { get; set; } = "Select Directory";
 | 
					    public string DirectoryDialogTitle { get; set; } = "Select Directory";
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    [Parameter]
 | 
				
			||||||
 | 
					    public Func<string, string?> Validation { get; set; } = _ => null;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    [Inject]
 | 
					    [Inject]
 | 
				
			||||||
    private SettingsManager SettingsManager { get; init; } = null!;
 | 
					    private SettingsManager SettingsManager { get; init; } = null!;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user