Added importing of configurations exported from AI Studio (#1007)

Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
Peer HogeterpandThorsten Sommer authored and GitHub committed 2026-10-16 17:22:23 +02:00
1 parent f8c0232cfd
commit 22065783c2
49 files changed
+3257 -263

No files matched your search

@@ -23,7 +23,20 @@ public partial class DataSourceERI_V1Dialog : MSGComponentBase, ISecretId
[Parameter]
public DataSourceERI_V1 DataSource { get; set; }
/// <summary>
/// Whether the data source was imported. It then fills the form like an edited one, but the
/// dialog does not connect to its server before the user tests the connection.
/// </summary>
[Parameter]
public bool IsImport { get; set; }
/// <summary>
/// The token or password an imported data source brought along.
/// </summary>
[Parameter]
public string ImportedSecret { get; set; } = string.Empty;
[Inject]
private ILogger<DataSourceERI_V1Dialog> Logger { get; init; } = null!;
@@ -43,6 +56,8 @@ public partial class DataSourceERI_V1Dialog : MSGComponentBase, ISecretId
private bool dataIsValid;
private string[] dataIssues = [];
private string dataSecretStorageIssue = string.Empty;
private string importRetrievalIssue = string.Empty;
private string importedRetrievalId = string.Empty;
private string dataEditingPreviousInstanceName = string.Empty;
private List<AuthMethod> availableAuthMethods = [];
private DataSourceSecurity dataSecurityPolicy;
@@ -92,13 +107,12 @@ public partial class DataSourceERI_V1Dialog : MSGComponentBase, ISecretId
.Concat(this.SettingsManager.ConfigurationData.Mailboxes.Select(x => x.Name.ToLowerInvariant()))
.ToList();
// When editing, we need to load the data:
if(this.IsEditing)
// An edited data source fills the form, and so does an imported one:
if(this.IsEditing || this.IsImport)
{
//
// Assign the data to the form fields:
//
this.dataEditingPreviousInstanceName = this.DataSource.Name.ToLowerInvariant();
this.dataNum = this.DataSource.Num;
this.dataId = this.DataSource.Id;
this.dataName = this.DataSource.Name;
@@ -114,7 +128,12 @@ public partial class DataSourceERI_V1Dialog : MSGComponentBase, ISecretId
// restore the selected retrieval process id. That's why we
// assign the selected retrieval id to the default retrieval process:
this.dataSelectedRetrievalProcess = this.dataSelectedRetrievalProcess with { Id = this.DataSource.SelectedRetrievalId };
}
// When editing, we need to load the data:
if(this.IsEditing)
{
this.dataEditingPreviousInstanceName = this.DataSource.Name.ToLowerInvariant();
if (this.dataAuthMethod is AuthMethod.TOKEN or AuthMethod.USERNAME_PASSWORD)
{
// Load the secret:
@@ -135,7 +154,13 @@ public partial class DataSourceERI_V1Dialog : MSGComponentBase, ISecretId
// Select the retrieval process:
this.dataSelectedRetrievalProcess = this.availableRetrievalProcesses.FirstOrDefault(n => n.Id == this.DataSource.SelectedRetrievalId);
}
else if (this.IsImport)
{
// The first connection test, which the user starts, selects the imported retrieval process:
this.dataSecret = this.ImportedSecret;
this.importedRetrievalId = this.DataSource.SelectedRetrievalId;
}
await base.OnInitializedAsync();
}
@@ -179,6 +204,8 @@ public partial class DataSourceERI_V1Dialog : MSGComponentBase, ISecretId
};
}
private void ClearImportRetrievalIssue() => this.importRetrievalIssue = string.Empty;
private bool IsConnectionEncrypted() => this.dataHostname.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase);
private bool IsConnectionPossible()
@@ -253,7 +280,23 @@ public partial class DataSourceERI_V1Dialog : MSGComponentBase, ISecretId
}
this.availableRetrievalProcesses = retrievalInfoRequest.Data ?? [];
// Only the first successful test after an import resolves the imported retrieval ID;
// afterward, the selection belongs to the user:
if (!string.IsNullOrWhiteSpace(this.importedRetrievalId))
{
var importedRetrieval = this.availableRetrievalProcesses.FirstOrDefault(item => item.Id == this.importedRetrievalId);
if (importedRetrieval != default)
this.dataSelectedRetrievalProcess = importedRetrieval;
else
{
this.importRetrievalIssue = string.Format(T("The server does not offer the imported retrieval process '{0}'. Please select another one before you save."), this.importedRetrievalId);
this.dataSelectedRetrievalProcess = default;
}
this.importedRetrievalId = string.Empty;
}
this.connectionTested = true;
this.connectionSuccessfulTested = true;
this.Logger.LogInformation("Connection to the ERI v1 server was successful tested.");