Allowed the attachments dialog to hide the remove button

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
j-erler 2026-09-24 00:16:13 +02:00
parent 40ac215359
commit 63eedafb1c
2 changed files with 37 additions and 13 deletions

View File

@ -9,7 +9,14 @@
Disabled="@this.IsZoneDisabled" Disabled="@this.IsZoneDisabled"
Context="isDropTarget"> Context="isDropTarget">
<MudJustifiedText Typo="Typo.body1" Class="mb-3"> <MudJustifiedText Typo="Typo.body1" Class="mb-3">
@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.") @if (this.CanRemove)
{
@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.")
}
else
{
@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.")
}
</MudJustifiedText> </MudJustifiedText>
@if (this.CanAttach) @if (this.CanAttach)
@ -66,11 +73,14 @@
OnClick="@(() => this.InvestigateFile(fileAttachment))"/> OnClick="@(() => this.InvestigateFile(fileAttachment))"/>
</MudTooltip> </MudTooltip>
<MudTooltip Text="@T("Remove this attachment.")" Placement="Placement.Bottom"> @if (this.CanRemove)
<MudIconButton Icon="@Icons.Material.Filled.Delete" {
Color="Color.Error" <MudTooltip Text="@T("Remove this attachment.")" Placement="Placement.Bottom">
OnClick="@(() => this.DeleteAttachment(fileAttachment))"/> <MudIconButton Icon="@Icons.Material.Filled.Delete"
</MudTooltip> Color="Color.Error"
OnClick="@(() => this.DeleteAttachment(fileAttachment))"/>
</MudTooltip>
}
</MudToolBar> </MudToolBar>
</MudStack> </MudStack>
} }
@ -93,11 +103,14 @@
Color="Color.Primary" Color="Color.Primary"
Disabled="true"/> Disabled="true"/>
<MudTooltip Text="@T("Remove this attachment.")" Placement="Placement.Bottom"> @if (this.CanRemove)
<MudIconButton Icon="@Icons.Material.Filled.Delete" {
Color="Color.Error" <MudTooltip Text="@T("Remove this attachment.")" Placement="Placement.Bottom">
OnClick="@(() => this.DeleteAttachment(fileAttachment))"/> <MudIconButton Icon="@Icons.Material.Filled.Delete"
</MudTooltip> Color="Color.Error"
OnClick="@(() => this.DeleteAttachment(fileAttachment))"/>
</MudTooltip>
}
</MudToolBar> </MudToolBar>
</MudStack> </MudStack>
} }

View File

@ -38,6 +38,16 @@ public partial class ReviewAttachmentsDialog : MSGComponentBase
[Parameter] [Parameter]
public Func<bool>? IsAttachingUnavailable { get; set; } public Func<bool>? IsAttachingUnavailable { get; set; }
/// <summary>
/// Whether the user may remove attachments here.
/// </summary>
/// <remarks>
/// False when this dialog gathers the attachments of several messages at once: a removal would
/// reach into a message that was already sent, and nothing here could tell which one.
/// </remarks>
[Parameter]
public bool CanRemove { get; set; } = true;
[Inject] [Inject]
private IDialogService DialogService { get; set; } = null!; private IDialogService DialogService { get; set; } = null!;
@ -120,11 +130,12 @@ public partial class ReviewAttachmentsDialog : MSGComponentBase
private async Task PathsDropped(List<string> paths) => await this.AttachPathsAsync(paths); private async Task PathsDropped(List<string> paths) => await this.AttachPathsAsync(paths);
public static async Task<HashSet<FileAttachment>> OpenDialogAsync(IDialogService dialogService, HashSet<FileAttachment> documentPaths, Func<List<string>, Task<IReadOnlyList<FileAttachment>>>? attachPaths = null, Func<bool>? isAttachingUnavailable = null) public static async Task<HashSet<FileAttachment>> OpenDialogAsync(IDialogService dialogService, HashSet<FileAttachment> documentPaths, Func<List<string>, Task<IReadOnlyList<FileAttachment>>>? attachPaths = null, Func<bool>? isAttachingUnavailable = null, bool canRemove = true)
{ {
var dialogParameters = new DialogParameters<ReviewAttachmentsDialog> var dialogParameters = new DialogParameters<ReviewAttachmentsDialog>
{ {
{ x => x.DocumentPaths, documentPaths } { x => x.DocumentPaths, documentPaths },
{ x => x.CanRemove, canRemove },
}; };
if (attachPaths is not null) if (attachPaths is not null)