feat(cms): bring per-medium tab grids to ALL-tab parity (§8.C)

Render the rich CmsAlbumBrowser filtered per medium in the CUTS/SESSIONS/MIXES
tabs via an optional RowActions slot; retire the thin CmsMediumTable. Session
hero and Mix waveform actions preserved; ALL tab and TrackList unchanged.
This commit is contained in:
daniel-c-harvey
2026-06-13 22:33:31 -04:00
parent 4b9e6531fd
commit 3ef98aa3ff
8 changed files with 151 additions and 191 deletions
@@ -65,6 +65,10 @@ else
</MudTd>
<MudTd DataLabel="Tracks">@context.TrackCount</MudTd>
<MudTd DataLabel="Actions">
@* Medium-specific row action (Session hero, Mix waveform) when a host supplies one;
the ALL tab supplies none. Rendered before the shared edit/delete so the medium
affordance reads left-to-right ahead of the universal actions. *@
@RowActions?.Invoke(context.Release)
<MudTooltip Text="Batch Edit">
<MudIconButton Icon="@Icons.Material.Filled.Edit"
Size="Size.Small"
@@ -122,6 +126,13 @@ else
[Parameter] public bool IsLoading { get; set; }
[Parameter] public EventCallback OnReleasesChanged { get; set; }
// Optional per-row, medium-specific action slot (Session hero upload, Mix waveform generate),
// rendered in the Actions cell ahead of the shared edit/delete buttons. The ALL tab leaves it
// unset and renders the grid exactly as before. A per-medium host (CmsCut/Session/MixBrowser)
// supplies it so the rich grid filtered to one medium keeps that medium's bespoke affordance —
// the rich expand/delete/Type-chip/edit logic stays here, single-sourced, rather than forked.
[Parameter] public RenderFragment<ReleaseDto>? RowActions { get; set; }
private List<AlbumRow> _rows = new();
// Tracks the Releases reference last projected into _rows. Guards against OnParametersSet
@@ -2,27 +2,20 @@
@using DeepDrftModels.DTOs
@using DeepDrftModels.Enums
@* Cut-filtered release grid for the Release Archive's CUTS tab (Phase 9 §8.A). Derived from the same
CmsMediumBrowserBase pattern the Session/Mix browsers use, so a fourth medium would follow the same
shape with no parallel path. Cuts carry no medium-specific row action (no hero, no waveform), so the
ActionContent slot renders nothing — every row still gets the shared Edit affordance from
CmsMediumTable. Embedded as tab content only; it has no standalone @page route. *@
<CmsMediumTable TRow="CutRow"
Rows="Rows"
Loading="Loading"
ReleaseAccessor="@(row => row.Release)"
ThumbUrl="@(key => ThumbUrl(key))"
TitleHeader="Cut"
EmptyMessage="No cuts found.">
<ActionContent Context="row">
</ActionContent>
</CmsMediumTable>
@* CUTS tab content (Phase 9 §8.A/§8.C): the rich CmsAlbumBrowser grid filtered to Cut releases, so the
tab carries expand-tracks, delete, the Type chip, and per-row edit identically to the ALL tab — no
forked grid. Cuts have no medium-specific row action, so no RowActions slot is supplied; the grid
renders its shared edit/delete only. Embedded as tab content only; no standalone @page route. *@
<CmsAlbumBrowser Releases="Releases"
IsLoading="Loading"
OnReleasesChanged="ReloadAsync" />
@code {
protected override ReleaseMedium Medium => ReleaseMedium.Cut;
protected override string MediumNoun => "cuts";
protected override CutRow ToRow(ReleaseDto release) => new() { Release = release };
protected override ReleaseDto ReleaseOf(CutRow row) => row.Release;
public sealed class CutRow
{
@@ -7,14 +7,18 @@ using MudBlazor;
namespace DeepDrftManager.Components.Pages.Tracks;
/// <summary>
/// Shared fetch + state logic for the single-track medium browsers (Sessions, Mixes). Analogous to the
/// public-site <c>MediumBrowseBase</c>: subclasses supply the <see cref="Medium"/>, the noun used in
/// error text, and a per-row projection from <see cref="ReleaseDto"/> to their own row model; this base
/// owns the loading flag, the row list, the initial load, and the cover-thumbnail URL helper. The shared
/// table structure lives in <c>CmsMediumTable</c>; subclasses render it and fill only the action column.
/// Shared fetch + state logic for the per-medium browsers (Cuts, Sessions, Mixes). Each subclass feeds
/// the rich <c>CmsAlbumBrowser</c> grid a medium-filtered release list, so the per-medium tabs gain the
/// same expand-tracks / delete / Type-chip / edit behaviour as the ALL tab without re-implementing any of
/// it (§8.C parity — reuse, don't fork). This base owns the loading flag, the medium-filtered load, the
/// per-release row projection, and a cover-thumbnail helper; subclasses supply the <see cref="Medium"/>,
/// an error noun, and their bespoke per-row action (Session hero upload, Mix waveform generate) via the
/// rich grid's <c>RowActions</c> slot, looking their action-state row up with <see cref="RowFor"/>.
/// </summary>
/// <typeparam name="TRow">The subclass's row model wrapping a <see cref="ReleaseDto"/>.</typeparam>
public abstract class CmsMediumBrowserBase<TRow> : ComponentBase
/// <typeparam name="TRow">The subclass's row model wrapping a <see cref="ReleaseDto"/> plus its
/// medium-specific action state (upload/generate flags). The rich grid renders from the bare
/// <see cref="Releases"/> projection; <typeparamref name="TRow"/> only carries the action state.</typeparam>
public abstract class CmsMediumBrowserBase<TRow> : ComponentBase where TRow : class
{
[Inject] public required ICmsReleaseService CmsReleaseService { get; set; }
[Inject] public required ISnackbar Snackbar { get; set; }
@@ -28,11 +32,38 @@ public abstract class CmsMediumBrowserBase<TRow> : ComponentBase
/// <summary>Projects a fetched release into the subclass's row model.</summary>
protected abstract TRow ToRow(ReleaseDto release);
/// <summary>The release carried by a subclass row, for keying the action-state lookup.</summary>
protected abstract ReleaseDto ReleaseOf(TRow row);
protected List<TRow> Rows { get; private set; } = new();
protected bool Loading { get; private set; } = true;
// Bare release projection handed to the rich grid. The grid does the expand/delete/edit/Type-chip;
// it never sees TRow. Rebuilt on every (re)load so the grid re-projects against a fresh reference.
protected IReadOnlyList<ReleaseDto> Releases { get; private set; } = Array.Empty<ReleaseDto>();
// release.Id → action-state row, so a RowActions fragment (which the grid hands a ReleaseDto) can
// recover its TRow. Rebuilt alongside Rows so a refresh never leaves a stale row behind.
private Dictionary<long, TRow> _rowsById = new();
protected override async Task OnInitializedAsync() => await LoadAsync();
/// <summary>Recovers the action-state row for a release the rich grid is rendering. Null if the
/// release is not in the current page (e.g. just deleted), in which case the action is skipped.</summary>
protected TRow? RowFor(ReleaseDto release) =>
_rowsById.TryGetValue(release.Id, out var row) ? row : null;
/// <summary>
/// Reloads the medium-filtered release list. Wired to the rich grid's <c>OnReleasesChanged</c> so a
/// delete re-fetches the authoritative list (track counts, orphan cleanup) — the same single-load
/// posture <c>CmsAllReleasesGrid</c> uses for the ALL tab.
/// </summary>
protected async Task ReloadAsync()
{
await LoadAsync();
StateHasChanged();
}
private async Task LoadAsync()
{
Loading = true;
@@ -53,6 +84,8 @@ public abstract class CmsMediumBrowserBase<TRow> : ComponentBase
Rows = new List<TRow>();
}
Releases = Rows.Select(ReleaseOf).ToList();
_rowsById = Rows.ToDictionary(r => ReleaseOf(r).Id);
Loading = false;
}
@@ -1,74 +0,0 @@
@namespace DeepDrftManager.Components.Pages.Tracks
@typeparam TRow
@using DeepDrftModels.DTOs
@* Shared table shell for the single-track medium browsers (Sessions, Mixes). Renders the cover
thumbnail, title, artist, and a shared Edit affordance that every medium gets (9.5.E). The
medium-specific cells (hero / waveform / generate-or-upload action) are supplied per row via the
ActionContent slot, which receives the subclass's typed row. Fully controlled by the parent:
loading and row state are passed in. *@
@if (Loading)
{
<MudProgressCircular Indeterminate="true" Class="mt-4" />
}
else if (Rows.Count == 0)
{
<MudText Typo="Typo.body1" Class="mt-4">@EmptyMessage</MudText>
}
else
{
<MudTable T="TRow" Items="Rows" Hover="true" Striped="true" Dense="true" Bordered="false" FixedHeader="true">
<HeaderContent>
<MudTh Style="width: 1%;">Cover</MudTh>
<MudTh>@TitleHeader</MudTh>
<MudTh>Artist</MudTh>
<MudTh Style="width: 1%; white-space: nowrap;">Actions</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Cover">
@{ var release = ReleaseAccessor(context); }
@if (!string.IsNullOrEmpty(release.ImagePath))
{
<div class="cms-album-thumb" style="background-image: url('@ThumbUrl(release.ImagePath)');"></div>
}
else
{
<div class="cms-album-thumb cms-album-thumb--fallback"></div>
}
</MudTd>
<MudTd DataLabel="@TitleHeader">@ReleaseAccessor(context).Title</MudTd>
<MudTd DataLabel="Artist">@ReleaseAccessor(context).Artist</MudTd>
<MudTd DataLabel="Actions">
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
@ActionContent(context)
<MudTooltip Text="Edit release">
<MudIconButton Icon="@Icons.Material.Filled.Edit"
Size="Size.Small"
Color="Color.Primary"
Href="@($"/tracks/album/{Uri.EscapeDataString(ReleaseAccessor(context).Title)}/edit")" />
</MudTooltip>
</MudStack>
</MudTd>
</RowTemplate>
</MudTable>
}
@code {
[Parameter] public required IReadOnlyList<TRow> Rows { get; set; }
[Parameter] public bool Loading { get; set; }
/// <summary>Projects a row to its underlying release for the cover/title/artist cells.</summary>
[Parameter] public required Func<TRow, ReleaseDto> ReleaseAccessor { get; set; }
/// <summary>Medium-specific cell content (hero / waveform / generate action) for each row.</summary>
[Parameter] public required RenderFragment<TRow> ActionContent { get; set; }
/// <summary>Relative thumbnail URL builder; the base class supplies its proxy-aware helper.</summary>
[Parameter] public required Func<string, string> ThumbUrl { get; set; }
/// <summary>Column header / data-label for the title column (e.g. "Session", "Mix").</summary>
[Parameter] public string TitleHeader { get; set; } = "Title";
[Parameter] public string EmptyMessage { get; set; } = "Nothing here yet.";
}
@@ -1,14 +0,0 @@
/* Cover-thumbnail idiom shared by the medium browsers' tables. Blazor CSS isolation is per-component,
so this scoped copy of the album-browser thumb classes reaches only this component's own markup. */
.cms-album-thumb {
width: 40px;
height: 40px;
border-radius: 4px;
background-size: cover;
background-position: center;
flex-shrink: 0;
}
.cms-album-thumb--fallback {
background-color: var(--mud-palette-action-default-hover);
}
@@ -6,10 +6,11 @@
@inject ILogger<CmsMixBrowser> Logger
@* Embedded as the MIXES tab content of the Release Archive (Phase 9 §8.A), and still routable at
/tracks/mixes for direct-URL access. When embedded, the page chrome (title, container, the now-
meaningless "Back to Release Archive" button) is suppressed — the host tab strip owns that frame; only
the grid renders. The standalone route keeps the full page chrome. The per-row waveform affordance
(9.5.E) is preserved in both contexts. *@
/tracks/mixes for direct-URL access. The grid is the rich CmsAlbumBrowser filtered to Mixes (§8.C
parity: expand-tracks, delete, Type chip, per-row edit), with the Mix waveform generate supplied as
its medium-specific RowActions slot so that affordance survives the move off the thin table. When
embedded, the page chrome (title, container, the now-meaningless "Back to Release Archive" button) is
suppressed; the standalone route keeps it. The waveform affordance (9.5.E) is preserved in both. *@
@if (Embedded)
{
@GridContent
@@ -48,45 +49,49 @@ else
HasWaveform = !string.IsNullOrEmpty(release.MixMetadata?.WaveformEntryKey)
};
protected override ReleaseDto ReleaseOf(MixRow row) => row.Release;
// The grid itself — identical in the embedded and standalone contexts. Defined once as a fragment so
// both branches above render the same markup without duplication.
private RenderFragment GridContent => @<CmsMediumTable TRow="MixRow"
Rows="Rows"
Loading="Loading"
ReleaseAccessor="@(row => row.Release)"
ThumbUrl="@(key => ThumbUrl(key))"
TitleHeader="Mix"
EmptyMessage="No mixes found.">
<ActionContent Context="row">
@if (row.HasWaveform)
// both branches above render the same markup without duplication. The waveform generate is the Mix's
// medium-specific RowActions content; the grid hands it each release, and RowFor recovers the
// matching MixRow's generate state.
private RenderFragment GridContent => @<CmsAlbumBrowser Releases="Releases"
IsLoading="Loading"
OnReleasesChanged="ReloadAsync">
<RowActions Context="release">
@{ var row = RowFor(release); }
@if (row is not null)
{
<MudTooltip Text="Waveform generated">
<MudIcon Icon="@Icons.Material.Filled.CheckCircle" Color="Color.Success" Size="Size.Small" />
</MudTooltip>
}
else
{
<MudTooltip Text="No waveform — incomplete">
<MudIcon Icon="@Icons.Material.Filled.Cancel" Color="Color.Warning" Size="Size.Small" />
</MudTooltip>
}
<MudButton Variant="Variant.Outlined"
Size="Size.Small"
StartIcon="@Icons.Material.Filled.GraphicEq"
Disabled="@row.IsGenerating"
OnClick="@(() => GenerateWaveformAsync(row))">
@if (row.IsGenerating)
@if (row.HasWaveform)
{
<MudProgressCircular Class="mr-2" Size="Size.Small" Indeterminate="true" />
<span>Generating…</span>
<MudTooltip Text="Waveform generated">
<MudIcon Icon="@Icons.Material.Filled.CheckCircle" Color="Color.Success" Size="Size.Small" />
</MudTooltip>
}
else
{
<span>@(row.HasWaveform ? "Regenerate" : "Generate")</span>
<MudTooltip Text="No waveform — incomplete">
<MudIcon Icon="@Icons.Material.Filled.Cancel" Color="Color.Warning" Size="Size.Small" />
</MudTooltip>
}
</MudButton>
</ActionContent>
</CmsMediumTable>;
<MudButton Variant="Variant.Outlined"
Size="Size.Small"
StartIcon="@Icons.Material.Filled.GraphicEq"
Disabled="@row.IsGenerating"
OnClick="@(() => GenerateWaveformAsync(row))">
@if (row.IsGenerating)
{
<MudProgressCircular Class="mr-2" Size="Size.Small" Indeterminate="true" />
<span>Generating…</span>
}
else
{
<span>@(row.HasWaveform ? "Regenerate" : "Generate")</span>
}
</MudButton>
}
</RowActions>
</CmsAlbumBrowser>;
private async Task GenerateWaveformAsync(MixRow row)
{
@@ -7,10 +7,11 @@
@inject ILogger<CmsSessionBrowser> Logger
@* Embedded as the SESSIONS tab content of the Release Archive (Phase 9 §8.A), and still routable at
/tracks/sessions for direct-URL access. When embedded, the page chrome (title, container, the now-
meaningless "Back to Release Archive" button) is suppressed — the host tab strip owns that frame; only
the grid renders. The standalone route keeps the full page chrome. The per-row hero affordance (9.5.E)
is preserved in both contexts. *@
/tracks/sessions for direct-URL access. The grid is the rich CmsAlbumBrowser filtered to Sessions
(§8.C parity: expand-tracks, delete, Type chip, per-row edit), with the Session hero upload supplied
as its medium-specific RowActions slot so that affordance survives the move off the thin table. When
embedded, the page chrome (title, container, the now-meaningless "Back to Release Archive" button) is
suppressed; the standalone route keeps it. The hero affordance (9.5.E) is preserved in both contexts. *@
@if (Embedded)
{
@GridContent
@@ -49,47 +50,51 @@ else
HeroImageEntryKey = release.SessionMetadata?.HeroImageEntryKey
};
protected override ReleaseDto ReleaseOf(SessionRow row) => row.Release;
// The grid itself — identical in the embedded and standalone contexts. Defined once as a fragment so
// both branches above render the same markup without duplication.
private RenderFragment GridContent => @<CmsMediumTable TRow="SessionRow"
Rows="Rows"
Loading="Loading"
ReleaseAccessor="@(row => row.Release)"
ThumbUrl="@(key => ThumbUrl(key))"
TitleHeader="Session"
EmptyMessage="No sessions found.">
<ActionContent Context="row">
@if (row.HeroImageEntryKey is { Length: > 0 } heroKey)
// both branches above render the same markup without duplication. The hero upload is the Session's
// medium-specific RowActions content; the grid hands it each release, and RowFor recovers the
// matching SessionRow's upload state.
private RenderFragment GridContent => @<CmsAlbumBrowser Releases="Releases"
IsLoading="Loading"
OnReleasesChanged="ReloadAsync">
<RowActions Context="release">
@{ var row = RowFor(release); }
@if (row is not null)
{
<div class="cms-album-thumb" style="background-image: url('@ThumbUrl(heroKey)');"></div>
}
else
{
<div class="cms-album-thumb cms-album-thumb--fallback"></div>
}
<MudFileUpload T="IBrowserFile"
Accept="image/*"
FilesChanged="@(file => UploadHeroAsync(row, file))"
Disabled="@row.IsUploading">
<ActivatorContent>
<MudButton Variant="Variant.Outlined"
Size="Size.Small"
StartIcon="@Icons.Material.Filled.Image"
@if (row.HeroImageEntryKey is { Length: > 0 } heroKey)
{
<div class="cms-album-thumb" style="background-image: url('@ThumbUrl(heroKey)');"></div>
}
else
{
<div class="cms-album-thumb cms-album-thumb--fallback"></div>
}
<MudFileUpload T="IBrowserFile"
Accept="image/*"
FilesChanged="@(file => UploadHeroAsync(row, file))"
Disabled="@row.IsUploading">
@if (row.IsUploading)
{
<MudProgressCircular Class="mr-2" Size="Size.Small" Indeterminate="true" />
<span>Uploading…</span>
}
else
{
<span>@(row.HeroImageEntryKey is { Length: > 0 } ? "Replace hero" : "Set hero")</span>
}
</MudButton>
</ActivatorContent>
</MudFileUpload>
</ActionContent>
</CmsMediumTable>;
<ActivatorContent>
<MudButton Variant="Variant.Outlined"
Size="Size.Small"
StartIcon="@Icons.Material.Filled.Image"
Disabled="@row.IsUploading">
@if (row.IsUploading)
{
<MudProgressCircular Class="mr-2" Size="Size.Small" Indeterminate="true" />
<span>Uploading…</span>
}
else
{
<span>@(row.HeroImageEntryKey is { Length: > 0 } ? "Replace hero" : "Set hero")</span>
}
</MudButton>
</ActivatorContent>
</MudFileUpload>
}
</RowActions>
</CmsAlbumBrowser>;
private async Task UploadHeroAsync(SessionRow row, IBrowserFile? file)
{
@@ -1,6 +1,7 @@
/* Hero-thumbnail idiom for the session row's action cell. The cover thumb lives in CmsMediumTable's
own scoped CSS; this scoped copy reaches only the hero <div> rendered in this component's
ActionContent markup (Blazor CSS isolation is per-component). */
/* Hero-thumbnail idiom for the session row's action cell. The hero <div> is authored in this
component's RowActions fragment, so Blazor stamps it with this component's scope attribute even
though CmsAlbumBrowser renders it — this scoped copy reaches it (CSS isolation follows authoring
component, not rendering host). The grid's own cover thumb lives in CmsAlbumBrowser's scoped CSS. */
.cms-album-thumb {
width: 40px;
height: 40px;