mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-17 14:18:00 +00:00
first version of the import function
This commit is contained in:
1 parent
fda42ac24b
commit
0e63f93696
39 files changed
+1535
-46
No files matched your search
@@ -1,19 +1,38 @@
|
||||
using AIStudio.Settings;
|
||||
|
||||
using Lua;
|
||||
|
||||
namespace AIStudio.Dialogs.Settings;
|
||||
|
||||
public partial class SettingsDialogProfiles : SettingsDialogBase
|
||||
{
|
||||
private async Task AddProfile()
|
||||
private Task AddProfile() => this.AddProfile(null);
|
||||
|
||||
private async Task ImportProfile()
|
||||
{
|
||||
if (!this.SettingsManager.ConfigurationData.App.CanImportConfigurationSnippet("PROFILES"))
|
||||
return;
|
||||
var table = await ConfigurationSnippetImportDialog.ShowAsync(this.DialogService, "PROFILES", T("Import Profile"));
|
||||
if (table is not null && this.SettingsManager.ConfigurationData.App.CanImportConfigurationSnippet("PROFILES"))
|
||||
await this.AddProfile(table);
|
||||
}
|
||||
|
||||
private async Task AddProfile(LuaTable? importedConfiguration)
|
||||
{
|
||||
if (importedConfiguration is not null && !this.SettingsManager.ConfigurationData.App.CanImportConfigurationSnippet("PROFILES"))
|
||||
return;
|
||||
|
||||
var dialogParameters = new DialogParameters<ProfileDialog>
|
||||
{
|
||||
{ x => x.IsEditing, false },
|
||||
};
|
||||
if (importedConfiguration is not null)
|
||||
dialogParameters.Add(x => x.ImportedConfiguration, importedConfiguration);
|
||||
|
||||
var dialogReference = await this.DialogService.ShowAsync<ProfileDialog>(T("Add Profile"), dialogParameters, DialogOptions.FULLSCREEN);
|
||||
var dialogResult = await dialogReference.Result;
|
||||
if (dialogResult is null || dialogResult.Canceled)
|
||||
if (dialogResult is null || dialogResult.Canceled ||
|
||||
(importedConfiguration is not null && !this.SettingsManager.ConfigurationData.App.CanImportConfigurationSnippet("PROFILES")))
|
||||
return;
|
||||
|
||||
var addedProfile = (Profile)dialogResult.Data!;
|
||||
@@ -95,4 +114,4 @@ public partial class SettingsDialogProfiles : SettingsDialogBase
|
||||
|
||||
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user