From faaba7866c3874d34b7b07cbde36fdb07af10fe9 Mon Sep 17 00:00:00 2001 From: Amir Pournasserian Date: Mon, 19 Oct 2026 08:18:17 -0400 Subject: [PATCH 1/3] Keep the media form's base version and stop refused uploads filtering the library Closes #2629. --- .../Components/Pages/MediaAssetView.razor | 17 ++- .../Components/Pages/MediaLibraryView.razor | 23 +++- src/FluentCMS.Admin/Media/MediaForms.cs | 47 +++++-- src/FluentCMS.Host/FluentCmsHost.cs | 1 + src/FluentCMS.Host/Media/MediaEndpoints.cs | 40 +++++- .../Media/MediaScreenTests.cs | 119 ++++++++++++++---- .../FluentCMS.Tests/Admin/MediaViewsTests.cs | 67 +++++++++- 7 files changed, 265 insertions(+), 49 deletions(-) diff --git a/src/FluentCMS.Admin/Components/Pages/MediaAssetView.razor b/src/FluentCMS.Admin/Components/Pages/MediaAssetView.razor index 857265d58..037689c6f 100644 --- a/src/FluentCMS.Admin/Components/Pages/MediaAssetView.razor +++ b/src/FluentCMS.Admin/Components/Pages/MediaAssetView.razor @@ -5,6 +5,7 @@ @using FluentCMS.Core.Media @inject IMediaLibrary Library @inject IWhereUsed WhereUsed +@inject FluentCMS.Core.Schema.IContentTypeDirectory ContentTypes @inject NavigationManager Navigation @inject IStringLocalizer L @@ -66,7 +67,8 @@
- + @* The version the shown details were made from: a refused save keeps it, so a change saved meanwhile is a conflict. *@ + @if (_message is not null) {

@_message

@@ -120,7 +122,9 @@ { - @usage.ContentType @usage.EntryId.ToString("N")[..8] + + @usage.ContentType @usage.EntryId.ToString("N")[..8] + @@ -148,6 +152,9 @@ @code { private MediaAsset? _asset; private IReadOnlyList _usage = []; + + // The audit subject of each using type's items: an entity type's items are entities in the log, every other type's are entries. + private Dictionary _subjects = new(StringComparer.Ordinal); private IReadOnlyList _errors = []; private string? _formError; private string? _message; @@ -192,6 +199,12 @@ BaseVersion = _asset.LatestVersion, }; _usage = await WhereUsed.ForMediaAsync(Id); + foreach (var slug in _usage.Select(usage => usage.ContentType).Distinct()) + { + var type = await ContentTypes.GetAsync(slug); + _subjects[slug] = type.IsSuccess && type.Value.Definition.IsEntity ? "entity" : "entry"; + } + return true; } diff --git a/src/FluentCMS.Admin/Components/Pages/MediaLibraryView.razor b/src/FluentCMS.Admin/Components/Pages/MediaLibraryView.razor index d60347fca..0a7e9c4b1 100644 --- a/src/FluentCMS.Admin/Components/Pages/MediaLibraryView.razor +++ b/src/FluentCMS.Admin/Components/Pages/MediaLibraryView.razor @@ -60,17 +60,17 @@
- - + + - +
- +