mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-25 23:33:48 +00:00
Added a notice naming the page when a source opens without it (#1233)
This commit is contained in:
1 parent
e63e70a5cf
commit
deb75c8dd1
18 files changed
+447
-57
No files matched your search
@@ -53,7 +53,7 @@
|
||||
|
||||
@if (this.ShowOpen)
|
||||
{
|
||||
<MudTooltip Text="@GetOpenTooltip(this.PageNumber)" Placement="@this.TooltipPlacement" ShowOnFocus="@false">
|
||||
<MudTooltip Text="@GetOpenTooltip(this.PageNumber, this.CanOpenAtPage)" Placement="@this.TooltipPlacement" ShowOnFocus="@false">
|
||||
<MudIconButton Icon="@AppIcons.OPEN_EXTERNAL" Size="Size.Small" Class="icon-button-compact" OnClick="@this.Open"/>
|
||||
</MudTooltip>
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
using AIStudio.Tools.Rust;
|
||||
using AIStudio.Tools.Services;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -82,6 +83,9 @@ public partial class FileActions : MSGComponentBase
|
||||
[Inject]
|
||||
private RustService RustService { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
private RuntimeInfoResponse RuntimeInfo { get; init; }
|
||||
|
||||
private FileActionsKind kind;
|
||||
|
||||
/// <summary>
|
||||
@@ -94,14 +98,28 @@ public partial class FileActions : MSGComponentBase
|
||||
/// </summary>
|
||||
private bool isMissing;
|
||||
|
||||
/// <summary>
|
||||
/// Whether a page can reach the program which opens a file, see RuntimeInfoResponseExtensions.
|
||||
/// </summary>
|
||||
private bool CanOpenAtPage => this.RuntimeInfo.CanOpenDocumentsAtPage;
|
||||
|
||||
/// <summary>
|
||||
/// The tooltip of opening a file, at its page where there is one.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Inside a Flatpak, no page reaches the program, so the tooltip promises none and says why. Elsewhere,
|
||||
/// whether the page arrives depends on the program, and the user hears afterwards when it did not, see
|
||||
/// SourceDocumentLocationExtensions.GetPageNotice.
|
||||
/// </remarks>
|
||||
/// <param name="pageNumber">The page the file opens at, or null when it opens at its beginning.</param>
|
||||
/// <param name="canOpenAtPage">Whether a page can reach the program at all; false inside a Flatpak.</param>
|
||||
/// <returns>The tooltip.</returns>
|
||||
internal static string GetOpenTooltip(int? pageNumber) => pageNumber is { } page
|
||||
? string.Format(TB("Open the file at page {0}"), page)
|
||||
: TA("Open the file in the program your system uses for it");
|
||||
internal static string GetOpenTooltip(int? pageNumber, bool canOpenAtPage) => pageNumber switch
|
||||
{
|
||||
{ } page when canOpenAtPage => string.Format(TB("Open the file at page {0}"), page),
|
||||
{ } page => string.Format(TB("Open the file. As a Flatpak, AI Studio cannot open it at page {0}, where the passage is."), page),
|
||||
_ => TA("Open the file in the program your system uses for it"),
|
||||
};
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
</MudText>
|
||||
}
|
||||
|
||||
<MudTooltip Text="@FileActions.GetOpenTooltip(pageRange.First)" Placement="Placement.Top">
|
||||
<MudTooltip Text="@FileActions.GetOpenTooltip(pageRange.First, this.CanOpenAtPage)" Placement="Placement.Top">
|
||||
<MudLink Typo="Typo.body1" OnClick="@(() => this.OpenDocument(pagedDocument with { PageNumber = pageRange.First }))">
|
||||
@pageRange
|
||||
</MudLink>
|
||||
@@ -55,7 +55,7 @@
|
||||
{
|
||||
@* Inline rather than the usual inline block: a long title, e.g., one naming many
|
||||
parts, then wraps like text right after its number instead of moving below it. *@
|
||||
<MudTooltip Text="@FileActions.GetOpenTooltip(null)" Placement="Placement.Top" RootClass="d-inline">
|
||||
<MudTooltip Text="@FileActions.GetOpenTooltip(null, this.CanOpenAtPage)" Placement="Placement.Top" RootClass="d-inline">
|
||||
<MudLink Typo="Typo.body1" OnClick="@(() => this.OpenDocument(document))">
|
||||
@entry.Title
|
||||
</MudLink>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using AIStudio.Dialogs;
|
||||
using AIStudio.Tools.RAG;
|
||||
using AIStudio.Tools.Rust;
|
||||
using AIStudio.Tools.Services;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -39,6 +40,9 @@ public partial class SourcesList : MSGComponentBase
|
||||
[Inject]
|
||||
private RustService RustService { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
private RuntimeInfoResponse RuntimeInfo { get; init; }
|
||||
|
||||
[Inject]
|
||||
private IDialogService DialogService { get; init; } = null!;
|
||||
|
||||
@@ -112,6 +116,11 @@ public partial class SourcesList : MSGComponentBase
|
||||
|
||||
private async Task OpenDocument(SourceDocumentLocation document) => await document.OpenAsync(this.RustService);
|
||||
|
||||
/// <summary>
|
||||
/// Whether a page can reach the program which opens a document, see RuntimeInfoResponseExtensions.
|
||||
/// </summary>
|
||||
private bool CanOpenAtPage => this.RuntimeInfo.CanOpenDocumentsAtPage;
|
||||
|
||||
/// <summary>
|
||||
/// The files of sources which are no longer at their place, by their paths, as FileActions found out.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user