mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 08:19:47 +00:00
Add DisabledActionParam to ButtonData for conditional button disabling
This commit is contained in:
parent
12d36a96e1
commit
125c3c1c66
@ -97,14 +97,14 @@
|
|||||||
{
|
{
|
||||||
case ButtonData buttonData when !string.IsNullOrWhiteSpace(buttonData.Tooltip):
|
case ButtonData buttonData when !string.IsNullOrWhiteSpace(buttonData.Tooltip):
|
||||||
<MudTooltip Text="@buttonData.Tooltip">
|
<MudTooltip Text="@buttonData.Tooltip">
|
||||||
<MudButton Variant="Variant.Filled" Color="@buttonData.Color" StartIcon="@GetButtonIcon(buttonData.Icon)" OnClick="async () => await buttonData.AsyncAction()">
|
<MudButton Variant="Variant.Filled" Color="@buttonData.Color" Disabled="@buttonData.DisabledAction()" StartIcon="@GetButtonIcon(buttonData.Icon)" OnClick="async () => await buttonData.AsyncAction()">
|
||||||
@buttonData.Text
|
@buttonData.Text
|
||||||
</MudButton>
|
</MudButton>
|
||||||
</MudTooltip>
|
</MudTooltip>
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ButtonData buttonData:
|
case ButtonData buttonData:
|
||||||
<MudButton Variant="Variant.Filled" Color="@buttonData.Color" StartIcon="@GetButtonIcon(buttonData.Icon)" OnClick="async () => await buttonData.AsyncAction()">
|
<MudButton Variant="Variant.Filled" Color="@buttonData.Color" Disabled="@buttonData.DisabledAction()" StartIcon="@GetButtonIcon(buttonData.Icon)" OnClick="async () => await buttonData.AsyncAction()">
|
||||||
@buttonData.Text
|
@buttonData.Text
|
||||||
</MudButton>
|
</MudButton>
|
||||||
break;
|
break;
|
||||||
|
@ -1,6 +1,21 @@
|
|||||||
namespace AIStudio.Tools;
|
namespace AIStudio.Tools;
|
||||||
|
|
||||||
public readonly record struct ButtonData(string Text, string Icon, Color Color, string Tooltip, Func<Task> AsyncAction) : IButtonData
|
public readonly record struct ButtonData(string Text, string Icon, Color Color, string Tooltip, Func<Task> AsyncAction, Func<bool>? DisabledActionParam) : IButtonData
|
||||||
{
|
{
|
||||||
public ButtonTypes Type => ButtonTypes.BUTTON;
|
public ButtonTypes Type => ButtonTypes.BUTTON;
|
||||||
|
|
||||||
|
public Func<bool> DisabledAction
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var data = this;
|
||||||
|
return () =>
|
||||||
|
{
|
||||||
|
if (data.DisabledActionParam is null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return data.DisabledActionParam();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user