mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-15 14:41:37 +00:00
Refactor ReviewAttachmentsDialog to use FileAttachment type for improved handling and deletion
This commit is contained in:
parent
aeed61d635
commit
69c3e490d7
@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
@{
|
@{
|
||||||
var currentFolder = string.Empty;
|
var currentFolder = string.Empty;
|
||||||
foreach (var filePath in this.DocumentPaths)
|
foreach (var fileAttachment in this.DocumentPaths)
|
||||||
{
|
{
|
||||||
var folderPath = Path.GetDirectoryName(filePath);
|
var folderPath = Path.GetDirectoryName(fileAttachment.FilePath);
|
||||||
if (folderPath != currentFolder)
|
if (folderPath != currentFolder)
|
||||||
{
|
{
|
||||||
currentFolder = folderPath;
|
currentFolder = folderPath;
|
||||||
@ -32,7 +32,7 @@
|
|||||||
</MudStack>
|
</MudStack>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (File.Exists(filePath))
|
@if (fileAttachment.Exists)
|
||||||
{
|
{
|
||||||
<MudStack Row Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center" Class="ms-3 mb-2">
|
<MudStack Row Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center" Class="ms-3 mb-2">
|
||||||
<div style="min-width: 0; flex: 1; overflow: hidden;">
|
<div style="min-width: 0; flex: 1; overflow: hidden;">
|
||||||
@ -40,7 +40,7 @@
|
|||||||
<span class="d-inline-flex align-items-center" style="overflow: hidden; width: 100%;">
|
<span class="d-inline-flex align-items-center" style="overflow: hidden; width: 100%;">
|
||||||
<MudIcon Icon="@Icons.Material.Filled.AttachFile" Class="mr-2" Style="flex-shrink: 0;"/>
|
<MudIcon Icon="@Icons.Material.Filled.AttachFile" Class="mr-2" Style="flex-shrink: 0;"/>
|
||||||
<MudText Style="white-space: nowrap;">
|
<MudText Style="white-space: nowrap;">
|
||||||
@Path.GetFileName(filePath)
|
@fileAttachment.FileName
|
||||||
</MudText>
|
</MudText>
|
||||||
</span>
|
</span>
|
||||||
</MudTooltip>
|
</MudTooltip>
|
||||||
@ -51,7 +51,7 @@
|
|||||||
Color="Color.Error"
|
Color="Color.Error"
|
||||||
Class="ml-2"
|
Class="ml-2"
|
||||||
Style="flex-shrink: 0;"
|
Style="flex-shrink: 0;"
|
||||||
OnClick="@(() => this.DeleteAttachment(filePath))"/>
|
OnClick="@(() => this.DeleteAttachment(fileAttachment))"/>
|
||||||
</MudTooltip>
|
</MudTooltip>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
|
||||||
@ -64,7 +64,7 @@
|
|||||||
<span class="d-inline-flex align-items-center" style="overflow: hidden; width: 100%;">
|
<span class="d-inline-flex align-items-center" style="overflow: hidden; width: 100%;">
|
||||||
<MudIcon Icon="@Icons.Material.Filled.Report" Color="Color.Error" Class="mr-2" Style="flex-shrink: 0;"/>
|
<MudIcon Icon="@Icons.Material.Filled.Report" Color="Color.Error" Class="mr-2" Style="flex-shrink: 0;"/>
|
||||||
<MudText Style="white-space: nowrap;">
|
<MudText Style="white-space: nowrap;">
|
||||||
<s>@Path.GetFileName(filePath)</s>
|
<s>@fileAttachment.FileName</s>
|
||||||
</MudText>
|
</MudText>
|
||||||
</span>
|
</span>
|
||||||
</MudTooltip>
|
</MudTooltip>
|
||||||
@ -75,7 +75,7 @@
|
|||||||
Color="Color.Error"
|
Color="Color.Error"
|
||||||
Class="ml-2"
|
Class="ml-2"
|
||||||
Style="flex-shrink: 0;"
|
Style="flex-shrink: 0;"
|
||||||
OnClick="@(() => this.DeleteAttachment(filePath))"/>
|
OnClick="@(() => this.DeleteAttachment(fileAttachment))"/>
|
||||||
</MudTooltip>
|
</MudTooltip>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using AIStudio.Chat;
|
||||||
using AIStudio.Components;
|
using AIStudio.Components;
|
||||||
using AIStudio.Tools.PluginSystem;
|
using AIStudio.Tools.PluginSystem;
|
||||||
|
|
||||||
@ -13,14 +14,14 @@ public partial class ReviewAttachmentsDialog : MSGComponentBase
|
|||||||
private IMudDialogInstance MudDialog { get; set; } = null!;
|
private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public HashSet<string> DocumentPaths { get; set; } = new();
|
public HashSet<FileAttachment> DocumentPaths { get; set; } = new();
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
private IDialogService DialogService { get; set; } = null!;
|
private IDialogService DialogService { get; set; } = null!;
|
||||||
|
|
||||||
private void Close() => this.MudDialog.Close(DialogResult.Ok(this.DocumentPaths));
|
private void Close() => this.MudDialog.Close(DialogResult.Ok(this.DocumentPaths));
|
||||||
|
|
||||||
public static async Task<HashSet<string>> OpenDialogAsync(IDialogService dialogService, params HashSet<string> documentPaths)
|
public static async Task<HashSet<FileAttachment>> OpenDialogAsync(IDialogService dialogService, params HashSet<FileAttachment> documentPaths)
|
||||||
{
|
{
|
||||||
var dialogParameters = new DialogParameters<ReviewAttachmentsDialog>
|
var dialogParameters = new DialogParameters<ReviewAttachmentsDialog>
|
||||||
{
|
{
|
||||||
@ -35,12 +36,12 @@ public partial class ReviewAttachmentsDialog : MSGComponentBase
|
|||||||
if (dialogResult.Data is null)
|
if (dialogResult.Data is null)
|
||||||
return documentPaths;
|
return documentPaths;
|
||||||
|
|
||||||
return dialogResult.Data as HashSet<string> ?? documentPaths;
|
return dialogResult.Data as HashSet<FileAttachment> ?? documentPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteAttachment(string filePath)
|
private void DeleteAttachment(FileAttachment fileAttachment)
|
||||||
{
|
{
|
||||||
if (this.DocumentPaths.Remove(filePath))
|
if (this.DocumentPaths.Remove(fileAttachment))
|
||||||
{
|
{
|
||||||
this.StateHasChanged();
|
this.StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user