mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-09-27 00:53:37 +00:00
Improved the layout of tool warnings in the tool selection
This commit is contained in:
parent
ae6d916c1c
commit
74d6d42f94
@ -44,8 +44,7 @@
|
|||||||
@foreach (var item in this.catalog)
|
@foreach (var item in this.catalog)
|
||||||
{
|
{
|
||||||
var isSelected = this.SelectedToolIds.Contains(item.Definition.Id);
|
var isSelected = this.SelectedToolIds.Contains(item.Definition.Id);
|
||||||
var isConfigured = item.ConfigurationState.IsConfigured;
|
var warningText = this.GetWarningText(item);
|
||||||
var providerConfidenceHint = this.GetProviderConfidenceHint(item);
|
|
||||||
<div class="tool-selection-row">
|
<div class="tool-selection-row">
|
||||||
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Spacing="1">
|
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Spacing="1">
|
||||||
@*
|
@*
|
||||||
@ -81,17 +80,13 @@
|
|||||||
</MudButton>
|
</MudButton>
|
||||||
<MudIconButton Icon="@Icons.Material.Filled.Settings" Size="Size.Small" OnClick="@(async () => await this.OpenSettings(item.Definition.Id))" />
|
<MudIconButton Icon="@Icons.Material.Filled.Settings" Size="Size.Small" OnClick="@(async () => await this.OpenSettings(item.Definition.Id))" />
|
||||||
</MudStack>
|
</MudStack>
|
||||||
@if (!isConfigured)
|
@if (!string.IsNullOrWhiteSpace(warningText))
|
||||||
{
|
{
|
||||||
<MudText Typo="Typo.caption" Color="Color.Warning" Class="ml-2">@(string.IsNullOrWhiteSpace(item.ConfigurationState.Message) ? T("Required settings are missing. Configure this tool before enabling it.") : item.ConfigurationState.Message)</MudText>
|
@*
|
||||||
}
|
A caption renders as an inline span by default, and an inline element
|
||||||
@if (!item.IsActive)
|
cannot be justified. The div makes it a block of its own.
|
||||||
{
|
*@
|
||||||
<MudText Typo="Typo.caption" Color="Color.Warning" Class="ml-2">@T("This tool has been disabled by your organization.")</MudText>
|
<MudJustifiedText Typo="Typo.caption" HtmlTag="div" Color="Color.Warning" Class="ml-2">@warningText</MudJustifiedText>
|
||||||
}
|
|
||||||
@if (!string.IsNullOrWhiteSpace(providerConfidenceHint))
|
|
||||||
{
|
|
||||||
<MudText Typo="Typo.caption" Color="Color.Warning" Class="ml-2">@providerConfidenceHint</MudText>
|
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@ -104,4 +99,4 @@
|
|||||||
</MudCardActions>
|
</MudCardActions>
|
||||||
</MudCard>
|
</MudCard>
|
||||||
</MudPopover>
|
</MudPopover>
|
||||||
</div>
|
</div>
|
||||||
@ -129,6 +129,29 @@ public partial class ToolSelection : MSGComponentBase
|
|||||||
this.ProviderConfidence.GetName());
|
this.ProviderConfidence.GetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Every reason why this tool is out of reach right now, as one text.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Several reasons can apply at once, such as a missing setting and a provider without the
|
||||||
|
/// confidence the tool needs. One justified paragraph reads better than a stack of short lines.
|
||||||
|
/// </remarks>
|
||||||
|
private string GetWarningText(ToolCatalogItem item)
|
||||||
|
{
|
||||||
|
var warnings = new List<string>(3);
|
||||||
|
if (!item.ConfigurationState.IsConfigured)
|
||||||
|
warnings.Add(string.IsNullOrWhiteSpace(item.ConfigurationState.Message) ? T("Required settings are missing. Configure this tool before enabling it.") : item.ConfigurationState.Message);
|
||||||
|
|
||||||
|
if (!item.IsActive)
|
||||||
|
warnings.Add(T("This tool has been disabled by your organization."));
|
||||||
|
|
||||||
|
var providerConfidenceHint = this.GetProviderConfidenceHint(item);
|
||||||
|
if (!string.IsNullOrWhiteSpace(providerConfidenceHint))
|
||||||
|
warnings.Add(providerConfidenceHint);
|
||||||
|
|
||||||
|
return string.Join(' ', warnings);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task OpenSettings(string toolId)
|
private async Task OpenSettings(string toolId)
|
||||||
{
|
{
|
||||||
var parameters = new DialogParameters<ToolSettingsDialog>
|
var parameters = new DialogParameters<ToolSettingsDialog>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user