Mediascherm: vaste hoogte van de bulkbalk, hele tegel selecteert, kleinere tegels, 0 dagen bij opruimen
Continuous Integration / config-sls (pull_request) Successful in 9s
Continuous Integration / config-asf (pull_request) Successful in 7s
Continuous Integration / changes (pull_request) Successful in 20s
Continuous Integration / frontend-prepare (pull_request) Successful in 30s
Continuous Integration / backend-build (pull_request) Successful in 1m40s
Continuous Integration / vulnerability-scan (pull_request) Successful in 1m48s
Continuous Integration / frontend-build (pull_request) Successful in 56s
Continuous Integration / frontend-test (pull_request) Successful in 2m48s
Continuous Integration / frontend-lint (pull_request) Successful in 42s
Continuous Integration / backend-test (pull_request) Successful in 4m37s
Continuous Integration / publish-sls-test (pull_request) Skipped
Continuous Integration / publish-sls-production (pull_request) Skipped
Continuous Integration / deploy-sls-test (pull_request) Skipped
Continuous Integration / deploy-sls-production (pull_request) Skipped
Continuous Integration / publish-asf-test (pull_request) Skipped
Continuous Integration / deploy-asf-test (pull_request) Skipped
Continuous Integration / smoke-sls-test (pull_request) Skipped
Continuous Integration / smoke-asf-test (pull_request) Skipped
Continuous Integration / compile-sites (pull_request) Successful in 10m43s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 21:03:05 +01:00
co-authored by Claude Sonnet 5.5
parent e4f2569d20
commit 723226c7c4
10 changed files with 120 additions and 16 deletions
@@ -73,3 +73,4 @@ Kept while Bryan is away (2026-11-17): no questions to him, a most probable assu
| 42 | **One progress pattern for upload, processing and a new crop** (Bryan, 2026-11-17, after seeing it on test). | A shared `ProcessingProgress` (text "Wordt verwerkt…", one 0-100% bar, the percentage, no spinner, no step counts) is used on every photo and for the batch. The batch bar covers upload and processing together; there are no byte counts from the upload, so a photo's percentage is staged: waiting 0, uploading 15, uploaded 30, then 30-100 from the server's processing steps. A new crop uses the full 0-100 from its steps. The counter "x van y verwerkt" stays per batch. | Real upload byte progress (needs XHR progress in the API client). | `features/media/components/ProcessingProgress.tsx`, `lib/photoProgress.ts`, `hero/components/ProcessingStatus.tsx` |
| 43 | **"Slide toevoegen" replaces the per-slide library button** (Bryan, 2026-11-17, after seeing it on test; replaces assumption 36's per-slide button). | The per-slide "Kies uit bibliotheek" is gone. The existing add button is "Slide toevoegen" and opens the shared picker: choose a library photo or upload one on the spot (it also lands in the library, ML-17); one photo makes one NEW slide. A slide's photo cannot be changed or replaced: remove the slide and add another. Dropping files on the section still adds one slide per file (same upload as before). The crop per slide stays a goal (phase 2). | Keep a per-slide change button: Bryan said no. | `HeroPage.addSlideWithPhoto`, `LibraryPickerDialog` |
| 44 | **Tiles or list in the library** (Bryan, 2026-11-17). | The library and the trash show the photos as tiles (grid of thumbnails, selectable, same usage and links) by default, with a switch Tiles / List next to the filters. The choice is remembered in the browser (`localStorage`, guarded; it falls back to tiles). The clean-up dialog keeps its list. The picker already is a grid. | Remember the choice on the server per user: needs a user-settings store. | `PhotoSelectionList` (`layout`), `lib/layoutPreference.ts`, `MediaLibraryPage` |
| 45 | **Media screen details** (Bryan, 2026-11-17): bulk bar keeps its height; the whole tile selects; smaller tiles; 0 days in the clean-up; no time-basis choice. | The bar is an invisible placeholder of the same height (h-9) while nothing is selected. A click on a tile selects it (shift for a range); links, buttons and the box itself do their own thing. One more tile per row at every width. The clean-up slider goes from 0: 0 days means every photo that is not in use right now qualifies at the next clean-up (preview and confirmation unchanged, with a note at 0). The period always counts from the last use (assumption 29); there was no separate checkbox for the time basis in the clean-up (the only checkbox is "Alleen ongebruikte foto's", a filter, which stays because it protects photos in use), so nothing was removed. | If Bryan meant "Alleen ongebruikte foto's": removing it would put photos in use in the clean-up (counted from their upload date). | `BulkActionBar`, `PhotoSelectionList`, `CleanupDialog`, `CleanupSelection.MinDays` |
@@ -23,11 +23,13 @@ export interface BulkActionBarProps {
/**
* The actions on the selected photos: the count, a way to clear the selection and the actions. It sits in the header of
* the photo list (see <c>PhotoSelectionList</c>), which is the one shared place for it. The actions are data, so more of
* them (tags, move) can be added without touching the list. It shows nothing while nothing is selected.
* them (tags, move) can be added without touching the list. While nothing is selected it is an empty box of the same height.
*/
export function BulkActionBar({ count, actions, onClear, summary }: BulkActionBarProps) {
const { t } = useTranslation();
if (count === 0) return null;
// The bar keeps its height while nothing is selected (an invisible placeholder), so the photos never jump when the first
// photo is selected.
if (count === 0) return <div aria-hidden="true" className="h-9 flex-1" data-testid="bulk-action-bar-placeholder" />;
return (
<div role="toolbar" aria-label={t('media.bulk.label')} data-testid="bulk-action-bar" className="flex flex-1 flex-wrap items-center gap-3">
<span className="text-sm font-medium" data-testid="bulk-count">
@@ -12,11 +12,11 @@ import { DeleteDialog } from './DeleteDialog';
import { PhotoSelectionList } from './PhotoSelectionList';
const DEFAULT_DAYS = 7;
const MIN_DAYS = 1;
const MIN_DAYS = 0;
const MAX_DAYS = 365;
/**
* "Clean up": the photos older than the chosen number of days (by default 7), by default only the unused ones, newest
* "Clean up": the photos not used for the chosen number of days (by default 7; 0 = every unused photo now), by default only the unused ones, newest
* first and all selected so single photos can be taken out. Confirming moves exactly the selected photos to the trash
* (a photo in use asks for a second confirmation naming the places).
*/
@@ -61,7 +61,7 @@ export function CleanupDialog({ open, onOpenChange }: { open: boolean; onOpenCha
<div className="space-y-4">
<div className="space-y-1">
<Label htmlFor="cleanup-days">{t('media.cleanup.days', { count: days })}</Label>
<Label htmlFor="cleanup-days">{days === 0 ? t('media.cleanup.daysZero') : t('media.cleanup.days', { count: days })}</Label>
<input
id="cleanup-days"
type="range"
@@ -73,6 +73,11 @@ export function CleanupDialog({ open, onOpenChange }: { open: boolean; onOpenCha
className="w-full accent-primary"
data-testid="cleanup-days"
/>
{days === 0 && (
<p className="text-xs text-muted-foreground" data-testid="cleanup-zero-note">
{t('media.cleanup.zeroNote')}
</p>
)}
</div>
<CheckboxField
checked={onlyUnused}
@@ -13,7 +13,7 @@ const items: PhotoItem[] = [
{ id: 'p4', name: 'Foto 4', bytes: 10, createdAt: '2026-11-14T10:00:00Z', uses: [] },
];
function Harness({ disabled }: { disabled?: (item: PhotoItem) => boolean }) {
function Harness({ disabled, layout }: { disabled?: (item: PhotoItem) => boolean; layout?: 'list' | 'tiles' }) {
const [selection, setSelection] = useState<Selection>(emptySelection);
return (
<>
@@ -22,12 +22,30 @@ function Harness({ disabled }: { disabled?: (item: PhotoItem) => boolean }) {
selection={selection}
onSelectionChange={setSelection}
isDisabled={disabled}
layout={layout}
bulk={{ actions: [{ id: 'delete', label: 'Verwijderen', destructive: true, run: vi.fn() }], onClear: () => setSelection(emptySelection) }}
/>
</>
);
}
function PhotoSelectionListWithLink() {
const [selection, setSelection] = useState<Selection>(emptySelection);
return (
<PhotoSelectionList
layout="tiles"
items={items}
selection={selection}
onSelectionChange={setSelection}
renderUse={(_use, label) => (
<a href="#x" onClick={(event) => event.preventDefault()} data-testid="use-link-p1">
{label}
</a>
)}
/>
);
}
beforeEach(async () => {
await i18n.changeLanguage('nl');
});
@@ -140,4 +158,45 @@ describe('the bulk bar is part of the list header, above the photos', () => {
const first = screen.getByTestId('photo-row-p1');
expect(bar.compareDocumentPosition(first) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
});
it('keeps the header the same height before and after the first selection, so nothing jumps', async () => {
render(<Harness />);
const placeholder = screen.getByTestId('bulk-action-bar-placeholder');
expect(placeholder).toHaveClass('h-9');
expect(placeholder).toHaveAttribute('aria-hidden', 'true');
await userEvent.click(screen.getByRole('checkbox', { name: 'Foto 2' }));
expect(screen.queryByTestId('bulk-action-bar-placeholder')).not.toBeInTheDocument();
// The buttons of the bar are small (h-9), the same as the placeholder.
expect(screen.getByTestId('bulk-clear')).toHaveClass('h-9');
});
it('selects a tile by clicking the photo, but not when a link on the tile is clicked', async () => {
render(
<>
<PhotoSelectionListWithLink />
</>,
);
await userEvent.click(screen.getByTestId('photo-row-p2'));
expect(screen.getByRole('checkbox', { name: 'Foto 2' })).toBeChecked();
await userEvent.click(screen.getByTestId('photo-row-p2'));
expect(screen.getByRole('checkbox', { name: 'Foto 2' })).not.toBeChecked();
await userEvent.click(screen.getAllByTestId('use-link-p1')[0]!);
expect(screen.getByRole('checkbox', { name: 'Foto 1' })).not.toBeChecked();
// The box itself toggles once (the click on the box does not also toggle the tile).
await userEvent.click(screen.getByRole('checkbox', { name: 'Foto 3' }));
expect(screen.getByRole('checkbox', { name: 'Foto 3' })).toBeChecked();
});
it('does not select a disabled tile by clicking it', async () => {
render(<Harness layout="tiles" disabled={(item) => item.id === 'p1'} />);
await userEvent.click(screen.getByTestId('photo-row-p1'));
expect(screen.getByRole('checkbox', { name: 'Foto 1' })).not.toBeChecked();
});
});
@@ -89,7 +89,7 @@ export function PhotoSelectionList({ items, selection, onSelectionChange, isDisa
</span>
</div>
<ul
className={layout === 'tiles' ? 'grid grid-cols-2 gap-3 py-3 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5' : 'divide-y'}
className={layout === 'tiles' ? 'grid grid-cols-3 gap-3 py-3 sm:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6' : 'divide-y'}
aria-label={t('media.list.label')}
data-layout={layout}
data-testid="photo-items"
@@ -149,8 +149,14 @@ export function PhotoSelectionList({ items, selection, onSelectionChange, isDisa
return tiles ? (
<li
key={item.id}
className={cn('relative overflow-hidden rounded-md border bg-card', selection.has(item.id) && 'ring-2 ring-primary')}
className={cn('relative overflow-hidden rounded-md border bg-card', !disabled && 'cursor-pointer', selection.has(item.id) && 'ring-2 ring-primary')}
data-testid={`photo-row-${item.id}`}
// The whole tile selects (the box stays for keyboards and screen readers). A link or button on the tile
// (the places a photo is used) does its own thing and does not select.
onClick={(event) => {
if (disabled || (event.target as HTMLElement).closest('a, button, input, label')) return;
onItemClick(item.id, !selection.has(item.id), event.shiftKey);
}}
>
{/* flex (not a block with an inline box inside): no line box, so no extra space under the checkbox and equal padding on all four sides */}
<div className="absolute left-2 top-2 z-[1] flex rounded bg-background/90 p-1 shadow-sm" data-testid={`photo-chip-${item.id}`}>{checkbox}</div>
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it } from 'vitest';
import { http, HttpResponse } from 'msw';
import { screen, waitFor, within } from '@testing-library/react';
import { fireEvent, screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import i18n from '@/i18n/config';
import { server } from '@/mocks/server';
@@ -323,6 +323,22 @@ describe('MediaLibraryPage', () => {
expect(screen.getByTestId('layout-list')).toBeInTheDocument();
});
it('allows 0 days in the clean-up and says what that means', async () => {
renderPage();
await screen.findByTestId('photo-selection-list');
await userEvent.click(screen.getByTestId('cleanup-open'));
const dialog = await screen.findByTestId('cleanup-dialog');
const slider = within(dialog).getByTestId('cleanup-days');
expect(slider).toHaveAttribute('min', '0');
fireEvent.change(slider, { target: { value: '0' } });
expect(await within(dialog).findByTestId('cleanup-zero-note')).toHaveTextContent('direct in aanmerking');
expect(within(dialog).getByText('Direct: elke ongebruikte foto')).toBeInTheDocument();
await waitFor(() => expect(within(dialog).getByTestId('cleanup-summary')).toBeInTheDocument());
expect(within(dialog).getByTestId('cleanup-confirm')).toBeInTheDocument();
});
it('shows an error when the library cannot be loaded', async () => {
server.use(http.get('*/media-library/photos', () => new HttpResponse(null, { status: 500 })));
renderPage();
@@ -834,7 +834,7 @@
"cleanup": {
"open": "Clean up",
"title": "Clean up",
"description": "Photos older than the number of days below, newest first. Take out the photos you want to keep.",
"description": "Photos that have not been used for a number of days (counted from the last use), newest first. Take out the photos you want to keep.",
"days_one": "Older than {{count}} day",
"days_other": "Older than {{count}} days",
"onlyUnused": "Only unused photos",
@@ -843,7 +843,9 @@
"selectedSize": "Selected: {{size}}",
"trashNote": "The selected photos go to the trash and can be restored for 7 days.",
"confirm_one": "{{count}} photo to the trash",
"confirm_other": "{{count}} photos to the trash"
"confirm_other": "{{count}} photos to the trash",
"daysZero": "Immediately: every unused photo",
"zeroNote": "At 0 days every photo that is not used anywhere right now qualifies at once, even if it was just detached. You see the overview first and confirm yourself; the photos go to the trash."
},
"picker": {
"upload": "Upload an image",
@@ -834,7 +834,7 @@
"cleanup": {
"open": "Opruimen",
"title": "Opruimen",
"description": "Foto's die ouder zijn dan het aantal dagen hieronder, nieuwste eerst. Haal foto's uit de selectie die je wilt houden.",
"description": "Foto's die al een aantal dagen niet gebruikt zijn (geteld vanaf het laatste gebruik), nieuwste eerst. Haal foto's uit de selectie die je wilt houden.",
"days_one": "Ouder dan {{count}} dag",
"days_other": "Ouder dan {{count}} dagen",
"onlyUnused": "Alleen ongebruikte foto's",
@@ -843,7 +843,9 @@
"selectedSize": "Geselecteerd: {{size}}",
"trashNote": "De geselecteerde foto's gaan naar de prullenbak en kunnen 7 dagen worden teruggezet.",
"confirm_one": "{{count}} foto naar de prullenbak",
"confirm_other": "{{count}} foto's naar de prullenbak"
"confirm_other": "{{count}} foto's naar de prullenbak",
"daysZero": "Direct: elke ongebruikte foto",
"zeroNote": "Bij 0 dagen komt elke foto die op dit moment nergens wordt gebruikt direct in aanmerking, ook als hij net is losgekoppeld. Je ziet eerst het overzicht en bevestigt zelf; de foto’s gaan naar de prullenbak."
},
"picker": {
"upload": "Afbeelding uploaden",
@@ -45,13 +45,23 @@ public class MediaLibraryTests
}
[Theory]
[InlineData(-5, 1)]
[InlineData(0, 1)]
[InlineData(-5, 0)]
[InlineData(0, 0)]
[InlineData(1, 1)]
[InlineData(7, 7)]
[InlineData(365, 365)]
[InlineData(4000, 365)]
public void The_period_stays_inside_the_slider_range(int days, int expected) => CleanupSelection.ClampDays(days).Should().Be(expected);
[Fact]
public void Zero_days_selects_every_unused_photo_at_once_and_keeps_those_in_use_out_unless_asked()
{
var used = Item(0, used: true);
var unused = Item(0);
CleanupSelection.Select([used, unused], Now.AddMinutes(1), 0, onlyUnused: true).Should().ContainSingle().Which.Should().Be(unused);
}
[Fact]
public void A_photo_exactly_at_the_boundary_is_not_selected_yet()
{
@@ -8,7 +8,8 @@ namespace SlpModularCms.Core.Media.Library;
public static class CleanupSelection
{
public const int DefaultDays = 7;
public const int MinDays = 1;
/// <summary>0 means: every photo that is not in use qualifies at the next clean-up (Bryan, 2026-11-17).</summary>
public const int MinDays = 0;
public const int MaxDays = 365;
/// <summary>The days kept inside the slider range.</summary>