Adding Providers can now be disabled in the plugin

This commit is contained in:
Peer Schütt 2025-07-11 16:05:03 +02:00
parent 6116c03f7c
commit 9c32595d72
4 changed files with 17 additions and 3 deletions

View File

@ -75,7 +75,7 @@
</MudText>
}
<MudButton Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@Icons.Material.Filled.AddRoad" Class="mt-3 mb-6" OnClick="@this.AddLLMProvider">
<MudButton Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@Icons.Material.Filled.AddRoad" Class="mt-3 mb-6" OnClick="@this.AddLLMProvider" Disabled="@this.SettingsManager.ConfigurationData.App.DontAllowUserToAddProvider">
@T("Add Provider")
</MudButton>

View File

@ -64,4 +64,8 @@ CONFIG["SETTINGS"] = {}
-- Configure the update behavior:
-- Allowed values are: NO_CHECK, ONCE_STARTUP, HOURLY, DAILY, WEEKLY
-- CONFIG["SETTINGS"]["DataApp.UpdateBehavior"] = "NO_CHECK"
-- CONFIG["SETTINGS"]["DataApp.UpdateBehavior"] = "NO_CHECK"
-- Configure the user permission to add providers:
-- Allowed values are: true, false
-- CONFIG["SETTINGS"]["DataApp.DontAllowUserToAddProvider"] = false

View File

@ -58,9 +58,13 @@ public sealed class DataApp
/// </summary>
public string PreselectedProfile { get; set; } = string.Empty;
/// <summary>
/// Should we preselect a chat template for the entire app?
/// </summary>
public string PreselectedChatTemplate { get; set; } = string.Empty;
/// <summary>
/// Should the user be allowed to add providers?
/// </summary>
public bool DontAllowUserToAddProvider { get; set; }
}

View File

@ -53,6 +53,12 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
SETTINGS_LOCKER.Register<DataApp>(x => x.UpdateBehavior, this.Id);
SETTINGS_MANAGER.ConfigurationData.App.UpdateBehavior = updateBehavior;
}
if (settingsTable.TryGetValue(SettingsManager.ToSettingName<DataApp>(x => x.DontAllowUserToAddProvider), out var dontAllowUserToAddProviderValue) && dontAllowUserToAddProviderValue.TryRead<bool>(out var dontAllowUserToAddProviderEntry))
{
SETTINGS_LOCKER.Register<DataApp>(x => x.DontAllowUserToAddProvider, this.Id);
SETTINGS_MANAGER.ConfigurationData.App.DontAllowUserToAddProvider = dontAllowUserToAddProviderEntry;
}
//
// Configured providers