mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-07-27 21:42:56 +00:00
Added a lockable button component
This commit is contained in:
parent
3c8cef2501
commit
5d197024b5
5
app/MindWork AI Studio/Components/LockableButton.razor
Normal file
5
app/MindWork AI Studio/Components/LockableButton.razor
Normal 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>
|
27
app/MindWork AI Studio/Components/LockableButton.razor.cs
Normal file
27
app/MindWork AI Studio/Components/LockableButton.razor.cs
Normal 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();
|
||||
}
|
||||
}
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user