Skip to content

Commit aaca34e

Browse files
Fixes for file attachments (#603)
1 parent 759a073 commit aaca34e

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

app/MindWork AI Studio/Components/AttachDocuments.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ else
6868
</MudStack>
6969
<div @onmouseenter="@this.OnMouseEnter" @onmouseleave="@this.OnMouseLeave">
7070
<MudPaper Height="20em" Outlined="true" Class="@this.dragClass" Style="overflow-y: auto;">
71-
@foreach (var fileInfo in this.DocumentPaths.Select(file => new FileInfo(file)))
71+
@foreach (var filePath in this.DocumentPaths)
7272
{
73-
<MudChip T="string" Color="Color.Dark" Text="@fileInfo.Name" tabindex="-1" Icon="@Icons.Material.Filled.Search" OnClick="@(() => this.InvestigateFile(@fileInfo))" OnClose="@(() => this.RemoveDocumentPathFromDocumentPaths(@fileInfo))"/>
73+
<MudChip T="string" Color="Color.Dark" Text="@Path.GetFileName(filePath)" tabindex="-1" Icon="@Icons.Material.Filled.Search" OnClick="@(() => this.InvestigateFile(filePath))" OnClose="@(() => this.RemoveDocument(filePath))"/>
7474
}
7575
</MudPaper>
7676
</div>

app/MindWork AI Studio/Components/AttachDocuments.razor.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private async Task AddFilesManually()
158158
continue;
159159

160160
if (!await FileExtensionValidation.IsExtensionValidWithNotifyAsync(selectedFilePath))
161-
return;
161+
continue;
162162

163163
this.DocumentPaths.Add(selectedFilePath);
164164
}
@@ -199,9 +199,9 @@ private void OnMouseLeave(EventArgs _)
199199
this.StateHasChanged();
200200
}
201201

202-
private async Task RemoveDocumentPathFromDocumentPaths(FileInfo file)
202+
private async Task RemoveDocument(string filePath)
203203
{
204-
this.DocumentPaths.Remove(file.ToString());
204+
this.DocumentPaths.Remove(filePath);
205205

206206
await this.DocumentPathsChanged.InvokeAsync(this.DocumentPaths);
207207
await this.OnChange(this.DocumentPaths);
@@ -210,12 +210,12 @@ private async Task RemoveDocumentPathFromDocumentPaths(FileInfo file)
210210
/// <summary>
211211
/// The user might want to check what we actually extract from his file and therefore give the LLM as an input.
212212
/// </summary>
213-
/// <param name="file">The file to check.</param>
214-
private async Task InvestigateFile(FileInfo file)
213+
/// <param name="filePath">The file to check.</param>
214+
private async Task InvestigateFile(string filePath)
215215
{
216216
var dialogParameters = new DialogParameters<DocumentCheckDialog>
217217
{
218-
{ x => x.FilePath, file.FullName },
218+
{ x => x.FilePath, filePath },
219219
};
220220

221221
await this.DialogService.ShowAsync<DocumentCheckDialog>(T("Document Preview"), dialogParameters, DialogOptions.FULLSCREEN);

app/MindWork AI Studio/Dialogs/ReviewAttachmentsDialog.razor

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
@inherits MSGComponentBase
22

33
<MudDialog>
4-
<TitleContent>
5-
<MudText Typo="Typo.h4">
6-
@T("Your attached files")
7-
</MudText>
8-
</TitleContent>
94
<DialogContent>
105
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
116
@T("Here you can see all attached files. Files that can no longer be found (deleted, renamed, or moved) are marked with a warning icon and a strikethrough name. You can remove any attachment using the trash can icon.")

app/MindWork AI Studio/Dialogs/ReviewAttachmentsDialog.razor.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
using AIStudio.Components;
2+
using AIStudio.Tools.PluginSystem;
3+
24
using Microsoft.AspNetCore.Components;
35

46
namespace AIStudio.Dialogs;
57

68
public partial class ReviewAttachmentsDialog : MSGComponentBase
79
{
10+
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(ReviewAttachmentsDialog).Namespace, nameof(ReviewAttachmentsDialog));
11+
812
[CascadingParameter]
913
private IMudDialogInstance MudDialog { get; set; } = null!;
1014

@@ -23,7 +27,7 @@ public static async Task<HashSet<string>> OpenDialogAsync(IDialogService dialogS
2327
{ x => x.DocumentPaths, documentPaths }
2428
};
2529

26-
var dialogReference = await dialogService.ShowAsync<ReviewAttachmentsDialog>("Your attached documents", dialogParameters, DialogOptions.FULLSCREEN);
30+
var dialogReference = await dialogService.ShowAsync<ReviewAttachmentsDialog>(TB("Your attached files"), dialogParameters, DialogOptions.FULLSCREEN);
2731
var dialogResult = await dialogReference.Result;
2832
if (dialogResult is null || dialogResult.Canceled)
2933
return documentPaths;

app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3436,7 +3436,7 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::RETRIEVALPROCESSDIALOG::T951463987"] = "Einb
34363436
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::REVIEWATTACHMENTSDIALOG::T1746160064"] = "Hier sehen Sie alle angehängten Dateien. Dateien, die nicht mehr gefunden werden können (gelöscht, umbenannt oder verschoben), sind mit einem Warnsymbol und einem durchgestrichenen Namen markiert. Sie können jeden Anhang über das Papierkorbsymbol entfernen."
34373437

34383438
-- There aren't any file attachments available right now.
3439-
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::REVIEWATTACHMENTSDIALOG::T2111340711"] = "Derzeit sind keine Dateianhänge verfügbar."
3439+
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::REVIEWATTACHMENTSDIALOG::T2111340711"] = "Derzeit sind keine Dateianhänge vorhanden."
34403440

34413441
-- The file was deleted, renamed, or moved.
34423442
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::REVIEWATTACHMENTSDIALOG::T3083729256"] = "Die Datei wurde gelöscht, umbenannt oder verschoben."

app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3436,7 +3436,7 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::RETRIEVALPROCESSDIALOG::T951463987"] = "Embe
34363436
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::REVIEWATTACHMENTSDIALOG::T1746160064"] = "Here you can see all attached files. Files that can no longer be found (deleted, renamed, or moved) are marked with a warning icon and a strikethrough name. You can remove any attachment using the trash can icon."
34373437

34383438
-- There aren't any file attachments available right now.
3439-
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::REVIEWATTACHMENTSDIALOG::T2111340711"] = "There aren't any file attachments available right now."
3439+
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::REVIEWATTACHMENTSDIALOG::T2111340711"] = "There aren't any file attachments right now."
34403440

34413441
-- The file was deleted, renamed, or moved.
34423442
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::REVIEWATTACHMENTSDIALOG::T3083729256"] = "The file was deleted, renamed, or moved."

0 commit comments

Comments
 (0)