mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 15:39:46 +00:00
Refactored footer buttons to allow other, specific buttons
This commit is contained in:
parent
9fa2fbac32
commit
bc0755e363
@ -34,11 +34,11 @@
|
||||
@if (this.FooterButtons.Count > 0)
|
||||
{
|
||||
<MudStack Row="@true" Wrap="Wrap.Wrap" Class="mt-3 mr-2">
|
||||
@foreach (var buttonData in this.FooterButtons)
|
||||
@foreach (var button in this.FooterButtons)
|
||||
{
|
||||
switch (buttonData)
|
||||
switch (button)
|
||||
{
|
||||
case var _ when !string.IsNullOrWhiteSpace(buttonData.Tooltip):
|
||||
case ButtonData buttonData when !string.IsNullOrWhiteSpace(buttonData.Tooltip):
|
||||
<MudTooltip Text="@buttonData.Tooltip">
|
||||
<MudButton Variant="Variant.Filled" Color="@buttonData.Color" StartIcon="@GetButtonIcon(buttonData.Icon)" OnClick="async () => await buttonData.AsyncAction()">
|
||||
@buttonData.Text
|
||||
@ -46,7 +46,7 @@
|
||||
</MudTooltip>
|
||||
break;
|
||||
|
||||
default:
|
||||
case ButtonData buttonData:
|
||||
<MudButton Variant="Variant.Filled" Color="@buttonData.Color" StartIcon="@GetButtonIcon(buttonData.Icon)" OnClick="async () => await buttonData.AsyncAction()">
|
||||
@buttonData.Text
|
||||
</MudButton>
|
||||
|
@ -39,7 +39,7 @@ public abstract partial class AssistantBase : ComponentBase
|
||||
|
||||
protected virtual bool ShowDedicatedProgress => false;
|
||||
|
||||
protected virtual IReadOnlyList<ButtonData> FooterButtons => [];
|
||||
protected virtual IReadOnlyList<IButtonData> FooterButtons => [];
|
||||
|
||||
protected static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
|
||||
|
||||
|
@ -25,8 +25,8 @@ public partial class AssistantGrammarSpelling : AssistantBaseCore
|
||||
|
||||
protected override bool ShowDedicatedProgress => true;
|
||||
|
||||
protected override IReadOnlyList<ButtonData> FooterButtons => new[]
|
||||
{
|
||||
protected override IReadOnlyList<IButtonData> FooterButtons =>
|
||||
[
|
||||
new ButtonData("Copy result", Icons.Material.Filled.ContentCopy, Color.Default, string.Empty, () => this.CopyToClipboard(this.correctedText)),
|
||||
};
|
||||
|
||||
|
@ -24,16 +24,12 @@ public partial class AssistantRewriteImprove : AssistantBaseCore
|
||||
|
||||
protected override bool ShowResult => false;
|
||||
|
||||
#region Overrides of AssistantBase
|
||||
|
||||
protected override bool ShowDedicatedProgress => true;
|
||||
|
||||
#endregion
|
||||
|
||||
protected override IReadOnlyList<ButtonData> FooterButtons => new[]
|
||||
{
|
||||
new ButtonData("Copy result", Icons.Material.Filled.ContentCopy, Color.Default, string.Empty, () => this.CopyToClipboard(this.rewrittenText)),
|
||||
};
|
||||
protected override IReadOnlyList<IButtonData> FooterButtons =>
|
||||
[
|
||||
new ButtonData("Copy result", Icons.Material.Filled.ContentCopy, Color.Default, string.Empty, () => this.CopyToClipboard(this.rewrittenText))
|
||||
];
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
namespace AIStudio.Tools;
|
||||
|
||||
public readonly record struct ButtonData(string Text, string Icon, Color Color, string Tooltip, Func<Task> AsyncAction);
|
||||
public readonly record struct ButtonData(string Text, string Icon, Color Color, string Tooltip, Func<Task> AsyncAction) : IButtonData
|
||||
{
|
||||
public ButtonTypes Type => ButtonTypes.BUTTON;
|
||||
}
|
7
app/MindWork AI Studio/Tools/ButtonTypes.cs
Normal file
7
app/MindWork AI Studio/Tools/ButtonTypes.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace AIStudio.Tools;
|
||||
|
||||
public enum ButtonTypes
|
||||
{
|
||||
BUTTON = 0,
|
||||
SEND_TO,
|
||||
}
|
6
app/MindWork AI Studio/Tools/IButtonData.cs
Normal file
6
app/MindWork AI Studio/Tools/IButtonData.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace AIStudio.Tools;
|
||||
|
||||
public interface IButtonData
|
||||
{
|
||||
public ButtonTypes Type { get; }
|
||||
}
|
Loading…
Reference in New Issue
Block a user