mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-09-27 00:13:38 +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)
|
||||
{
|
||||
var isSelected = this.SelectedToolIds.Contains(item.Definition.Id);
|
||||
var isConfigured = item.ConfigurationState.IsConfigured;
|
||||
var providerConfidenceHint = this.GetProviderConfidenceHint(item);
|
||||
var warningText = this.GetWarningText(item);
|
||||
<div class="tool-selection-row">
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Spacing="1">
|
||||
@*
|
||||
@ -81,17 +80,13 @@
|
||||
</MudButton>
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Settings" Size="Size.Small" OnClick="@(async () => await this.OpenSettings(item.Definition.Id))" />
|
||||
</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>
|
||||
}
|
||||
@if (!item.IsActive)
|
||||
{
|
||||
<MudText Typo="Typo.caption" Color="Color.Warning" Class="ml-2">@T("This tool has been disabled by your organization.")</MudText>
|
||||
}
|
||||
@if (!string.IsNullOrWhiteSpace(providerConfidenceHint))
|
||||
{
|
||||
<MudText Typo="Typo.caption" Color="Color.Warning" Class="ml-2">@providerConfidenceHint</MudText>
|
||||
@*
|
||||
A caption renders as an inline span by default, and an inline element
|
||||
cannot be justified. The div makes it a block of its own.
|
||||
*@
|
||||
<MudJustifiedText Typo="Typo.caption" HtmlTag="div" Color="Color.Warning" Class="ml-2">@warningText</MudJustifiedText>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@ -104,4 +99,4 @@
|
||||
</MudCardActions>
|
||||
</MudCard>
|
||||
</MudPopover>
|
||||
</div>
|
||||
</div>
|
||||
@ -129,6 +129,29 @@ public partial class ToolSelection : MSGComponentBase
|
||||
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)
|
||||
{
|
||||
var parameters = new DialogParameters<ToolSettingsDialog>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user