mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-12 13:21:37 +00:00
Added hot reload for managed policies
This commit is contained in:
parent
b35333a9b6
commit
f9f73643b2
@ -215,7 +215,7 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
|||||||
|
|
||||||
this.policyDefinitionExpanded = !this.selectedPolicy?.IsProtected ?? true;
|
this.policyDefinitionExpanded = !this.selectedPolicy?.IsProtected ?? true;
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
this.ApplyFilters([], [ Event.CONFIGURATION_CHANGED ]);
|
this.ApplyFilters([], [ Event.CONFIGURATION_CHANGED, Event.PLUGINS_RELOADED ]);
|
||||||
this.UpdateProviders();
|
this.UpdateProviders();
|
||||||
this.ApplyPolicyPreselection(preferPolicyPreselection: true);
|
this.ApplyPolicyPreselection(preferPolicyPreselection: true);
|
||||||
}
|
}
|
||||||
@ -484,6 +484,11 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
|||||||
this.UpdateProviders();
|
this.UpdateProviders();
|
||||||
this.StateHasChanged();
|
this.StateHasChanged();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Event.PLUGINS_RELOADED:
|
||||||
|
this.HandlePluginsReloaded();
|
||||||
|
this.StateHasChanged();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
@ -491,6 +496,49 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private void HandlePluginsReloaded()
|
||||||
|
{
|
||||||
|
// Check if the currently selected policy still exists after plugin reload:
|
||||||
|
if (this.selectedPolicy is not null)
|
||||||
|
{
|
||||||
|
var stillExists = this.SettingsManager.ConfigurationData.DocumentAnalysis.Policies
|
||||||
|
.Any(p => p.Id == this.selectedPolicy.Id);
|
||||||
|
|
||||||
|
if (!stillExists)
|
||||||
|
{
|
||||||
|
// Policy was removed, select a new one:
|
||||||
|
this.selectedPolicy = this.SettingsManager.ConfigurationData.DocumentAnalysis.Policies.FirstOrDefault();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Policy still exists, update the reference to the potentially updated version:
|
||||||
|
this.selectedPolicy = this.SettingsManager.ConfigurationData.DocumentAnalysis.Policies
|
||||||
|
.First(p => p.Id == this.selectedPolicy.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No policy was selected, select the first one if available:
|
||||||
|
this.selectedPolicy = this.SettingsManager.ConfigurationData.DocumentAnalysis.Policies.FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update form values to reflect the current policy:
|
||||||
|
this.ResetForm();
|
||||||
|
|
||||||
|
// Update the expansion state based on the policy protection:
|
||||||
|
this.policyDefinitionExpanded = !this.selectedPolicy?.IsProtected ?? true;
|
||||||
|
|
||||||
|
// Update available providers:
|
||||||
|
this.UpdateProviders();
|
||||||
|
|
||||||
|
// Apply policy preselection:
|
||||||
|
this.ApplyPolicyPreselection(preferPolicyPreselection: true);
|
||||||
|
|
||||||
|
// Reset validation state:
|
||||||
|
this.form?.ResetValidation();
|
||||||
|
this.ClearInputIssues();
|
||||||
|
}
|
||||||
|
|
||||||
private string? ValidatePolicyDescription(string description)
|
private string? ValidatePolicyDescription(string description)
|
||||||
{
|
{
|
||||||
if(string.IsNullOrWhiteSpace(description))
|
if(string.IsNullOrWhiteSpace(description))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user