Added a lockable button component

This commit is contained in:
Thorsten Sommer 2025-07-11 22:31:41 +02:00
parent 3c8cef2501
commit 5d197024b5
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 33 additions and 5 deletions

View File

@ -0,0 +1,5 @@
@inherits ConfigurationBaseCore
<MudButton Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@this.Icon" Disabled="@this.IsDisabled" Class="mt-3 mb-6" OnClick="@(async () => await this.ClickAsync())">
@this.Text
</MudButton>

View File

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Components;
namespace AIStudio.Components;
public partial class LockableButton : ConfigurationBaseCore
{
[Parameter]
public string Icon { get; set; } = Icons.Material.Filled.Info;
[Parameter]
public Func<Task> OnClickAsync { get; set; } = () => Task.CompletedTask;
[Parameter]
public Action OnClick { get; set; } = () => { };
[Parameter]
public string Text { get; set; } = string.Empty;
private async Task ClickAsync()
{
if (this.IsLocked() || this.Disabled())
return;
await this.OnClickAsync();
this.OnClick();
}
}

View File

@ -75,11 +75,7 @@
</MudText>
}
<MudTooltip Text="Disabled by a plugin" Disabled="@(!this.SettingsManager.ConfigurationData.App.DontAllowUserToAddProvider)" Arrow="true" Placement="Placement.Top">
<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>
</MudTooltip>
<LockableButton Text="@T("Add Provider")" IsLocked="@(() => !this.SettingsManager.ConfigurationData.App.AllowUserToAddProvider)" Icon="@Icons.Material.Filled.AddRoad" OnClickAsync="@this.AddLLMProvider" />
<MudText Typo="Typo.h4" Class="mb-3">
@T("LLM Provider Confidence")