fix(cms): gate Session hero input to upload path; warn (not error) on missing hero
Edit forms (BatchEdit/TrackEdit/TrackNew) show the guidance alert instead of an inert picker, via an AllowHeroUpload flag. Missing-hero nudge is Severity.Warning; null-ReleaseId hero drop is now logged.
This commit is contained in:
@@ -1,48 +1,65 @@
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
|
||||
@* Session-medium fields. The hero image is resource-addressed (POST api/release/{id}/session/hero-image)
|
||||
and therefore cannot be uploaded until the release exists. The file is selected here, held by the
|
||||
parent form, and uploaded after the create call returns a release id — the same deferred-upload
|
||||
pattern AlbumHeaderFields uses for cover art ("Will upload on submit"). The hero is optional; the
|
||||
parent warns (does not block) when a Session is submitted without one. *@
|
||||
<MudItem xs="12">
|
||||
<MudField Label="Hero Image" Variant="Variant.Outlined" InnerPadding="false">
|
||||
<MudStack Spacing="3">
|
||||
<MudText Typo="Typo.body2" Color="Color.Default">
|
||||
Sessions are single-track live releases. The hero image is the session's primary visual identity.
|
||||
</MudText>
|
||||
@* Session-medium fields. When AllowHeroUpload is true (BatchUpload create path), the hero image
|
||||
file picker is shown — the file is held by the parent and POSTed after the release is created.
|
||||
When false (edit paths: BatchEdit, TrackEdit, TrackNew), the original guidance alert is rendered
|
||||
instead, directing the admin to the Sessions browser per-row replace action. This gate prevents
|
||||
a dead/inert control on edit forms that do not wire the hero callbacks. *@
|
||||
@if (AllowHeroUpload)
|
||||
{
|
||||
<MudItem xs="12">
|
||||
<MudField Label="Hero Image" Variant="Variant.Outlined" InnerPadding="false">
|
||||
<MudStack Spacing="3">
|
||||
<MudText Typo="Typo.body2" Color="Color.Default">
|
||||
Sessions are single-track live releases. The hero image is the session's primary visual identity.
|
||||
</MudText>
|
||||
|
||||
@if (HeroImageFile is { } selectedHero)
|
||||
{
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||
<MudText Typo="Typo.body2" Color="Color.Default">Selected: @selectedHero.Name</MudText>
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Clear"
|
||||
Color="Color.Error"
|
||||
Size="Size.Small"
|
||||
Disabled="Disabled"
|
||||
OnClick="ClearHeroFile"
|
||||
aria-label="Cancel hero image selection" />
|
||||
</MudStack>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Color="Color.Default">No hero image — optional, but recommended.</MudText>
|
||||
}
|
||||
@if (HeroImageFile is { } selectedHero)
|
||||
{
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
||||
<MudText Typo="Typo.body2" Color="Color.Default">Selected: @selectedHero.Name</MudText>
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Clear"
|
||||
Color="Color.Error"
|
||||
Size="Size.Small"
|
||||
Disabled="Disabled"
|
||||
OnClick="ClearHeroFile"
|
||||
aria-label="Cancel hero image selection" />
|
||||
</MudStack>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Color="Color.Default">No hero image — optional, but recommended.</MudText>
|
||||
}
|
||||
|
||||
<InputFile OnChange="HandleHeroFileSelected" accept="image/*" disabled="@Disabled" />
|
||||
@if (HeroImageFile is not null)
|
||||
{
|
||||
<MudText Typo="Typo.caption">Will upload on submit.</MudText>
|
||||
}
|
||||
</MudStack>
|
||||
</MudField>
|
||||
</MudItem>
|
||||
<InputFile OnChange="HandleHeroFileSelected" accept="image/*" disabled="@Disabled" />
|
||||
@if (HeroImageFile is not null)
|
||||
{
|
||||
<MudText Typo="Typo.caption">Will upload on submit.</MudText>
|
||||
}
|
||||
</MudStack>
|
||||
</MudField>
|
||||
</MudItem>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudItem xs="12">
|
||||
<MudAlert Severity="Severity.Info" Dense="true" Variant="Variant.Outlined">
|
||||
Sessions are single-track live releases. After upload, set the hero image from the
|
||||
<strong>Release Archive → Sessions</strong> browser.
|
||||
</MudAlert>
|
||||
</MudItem>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public IBrowserFile? HeroImageFile { get; set; }
|
||||
[Parameter] public EventCallback<IBrowserFile?> HeroImageFileChanged { get; set; }
|
||||
[Parameter] public bool Disabled { get; set; }
|
||||
|
||||
// When true (BatchUpload create path), render the hero file picker.
|
||||
// When false/absent (edit paths), render the guidance alert directing the admin to the
|
||||
// Sessions browser — no dead control where callbacks are unwired.
|
||||
[Parameter] public bool AllowHeroUpload { get; set; }
|
||||
|
||||
private Task HandleHeroFileSelected(InputFileChangeEventArgs e) =>
|
||||
HeroImageFileChanged.InvokeAsync(e.File);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user