Compare commits

...
Author SHA1 Message Date
spark a8ffc38ca8 feat(squads): show each athlete face in the squad panel
The list did not say who already has a face, or what that face looks like.
2026-11-06 22:00:30 +00:00
spark 256473e3a7 feat(library): put colour and selection where the cull happens
ci / typescript (push) Failing after 4m31s
ci / rust (push) Successful in 13m8s
Colour, selection and marking stay visible while culling.
2026-11-06 21:48:50 +00:00
spark ea6ae03ad1 feat(library): filter photos with no colour and add selection menus
ci / typescript (push) Failing after 4m24s
ci / rust (push) Successful in 13m50s
The colour bar had no unmarked-only filter, and the system menu cannot select photos.
2026-11-06 21:43:03 +00:00
spark ba1142c73f feat(library): filter photos with no colour and add selection menus
ci / typescript (pull_request) Failing after 4m31s
ci / rust (pull_request) Successful in 14m18s
The colour bar had no way to show only unmarked photos, and the system menu cannot select or mark them.
2026-11-06 21:42:59 +00:00
spark ea8308d703 chore(app): republish the library interface
ci / typescript (push) Failing after 4m12s
ci / rust (push) Successful in 14m36s
The running app was still the previous build.
2026-11-06 21:40:46 +00:00
spark 3813fe90ae chore(app): republish the library interface
ci / typescript (pull_request) Failing after 4m18s
ci / rust (pull_request) Successful in 14m40s
The colour filter and drag-select were on main, and the running app was still the previous build.
2026-11-06 21:40:43 +00:00
spark 2241d54dab fix(library): drag a rectangle to select several photos
ci / typescript (push) Failing after 4m3s
ci / rust (push) Successful in 15m4s
One colour paints the whole selection.
2026-11-06 21:29:45 +00:00
16 changed files with 458 additions and 44 deletions

No files matched your search

+21 -2
View File
@@ -1388,11 +1388,15 @@ export class SportsService {
const season = event.fixture?.season ?? seasonOf(event.startsAt);
const players = await this.squad(team.id, season);
const personOf = await this.peopleOf(event.organizationId, players);
const faceOf = await this.facesOf([...personOf.values()]);
sides.push({
side,
team: { id: team.id, name: team.name, abbreviation: team.abbreviation, logoUrl: team.logoUrl },
players: players.map((p) => {
const tally = counts(personOf.get(p.id) ?? null);
const personId = personOf.get(p.id) ?? null;
const tally = counts(personId);
const enrolled = personId ? faceOf.get(personId) ?? null : null;
const official = p.photoUrl && /^https?:\/\//i.test(p.photoUrl) ? p.photoUrl : null;
return {
id: p.id,
number: p.number,
@@ -1400,7 +1404,9 @@ export class SportsService {
fullName: p.fullName,
position: p.position,
hasPhoto: !!p.photoUrl,
personId: personOf.get(p.id) ?? null,
faceUrl: enrolled ?? official,
hasFace: !!enrolled,
personId,
photos: { confirmed: tally.confirmed, likely: tally.likely },
photoIds: tally.photoIds,
};
@@ -1765,6 +1771,19 @@ export class SportsService {
return linked?.season ?? null;
}
/** Signed URL of each person's enrolled face. People without a reference photo are absent. */
private async facesOf(personIds: string[]): Promise<Map<string, string>> {
const ids = [...new Set(personIds)];
const out = new Map<string, string>();
if (!ids.length) return out;
const people = await this.deps.db.person.findMany({
where: { id: { in: ids }, referenceKey: { not: null } },
select: { id: true },
});
for (const person of people) out.set(person.id, this.deps.storage.personUrl(person.id));
return out;
}
/** Which person is each squad row: the row itself, or the same human at the club they play for now. */
private async peopleOf(orgId: string, players: SportsPlayer[]): Promise<Map<string, string>> {
const out = new Map<string, string>();
+17 -1
View File
@@ -103,6 +103,18 @@ export const t = {
markColor: "Marcar",
colorOnly: (name: string) => `Só ${name.toLowerCase()}`,
colorWithout: (name: string) => `Sem ${name.toLowerCase()}`,
colorUncolored: "Só sem cor",
colorNone: "Sem cor",
menuSelectColor: (name: string) => `Selecionar ${name.toLowerCase()}`,
dropPartial: "O arrasto não trouxe o lote todo. Escolhe as fotografias aqui.",
dropChoose: "Escolher fotografias",
menuSelection: "Seleção",
menuSelectAll: "Selecionar todas",
menuSelectNone: "Limpar seleção",
menuSelectUncolored: "Selecionar sem cor",
menuImage: "Imagem",
menuSetColor: "Definir cor",
menuSetRating: "Definir estrelas",
colors: { RED: "Vermelho", YELLOW: "Amarelo", GREEN: "Verde", BLUE: "Azul", PURPLE: "Roxo" },
deliveryFilter: "Envio:",
deliveryStates: { any: "Todas", unsent: "Por enviar", queued: "A enviar", sent: "Enviadas", failed: "Com erro" },
@@ -132,7 +144,7 @@ export const t = {
setUpDelivery: "Configurar envio",
noTargetsHelp: "Ainda não há destinos de envio (FTP da agência, pasta, etc.). Cria um em Entregar.",
deliveryBadge: { QUEUED: "A enviar", DONE: "Enviada", FAILED: "Envio falhou" },
shortcuts: "P escolher · X rejeitar · U limpar · 0–5 estrelas · 6–9 cor · Delete tirar do evento · I informação · E/Enter lupa · G/Esc grelha · D revelar · R recortar · W conta-gotas · Ctrl+Alt+2 revelar · Photo Mechanic: T marcar · Cmd+1–5 cor · Ctrl+1–5 estrelas (Windows: Ctrl cor, Alt estrelas)",
shortcuts: "P escolher · X rejeitar · U limpar · 0–5 estrelas · 6–9 cor · arrastar seleciona várias · Delete tirar do evento · I informação · E/Enter lupa · G/Esc grelha · D revelar · R recortar · W conta-gotas · Ctrl+Alt+2 revelar · Photo Mechanic: T marcar · Cmd+1–5 cor · Ctrl+1–5 estrelas (Windows: Ctrl cor, Alt estrelas)",
selected: (n: number) => (n === 1 ? "1 selecionada" : `${n} selecionadas`),
ofTotal: (n: number, total: number) => `${n} de ${total}`,
players: "Jogadores",
@@ -834,6 +846,10 @@ export const t = {
never: "ainda não lido",
addFpf: "Seguir competição FPF (link do resultados.fpf.pt)",
add: "Adicionar",
showFaces: "Caras",
faceKnown: "Cara registada",
faceSquadOnly: "Foto do plantel, ainda sem cara registada",
faceNone: "Sem cara",
squadsSync: "Atualizar pessoas a partir dos plantéis",
squadsSynced: "Pessoas atualizadas",
},
+17 -2
View File
@@ -1,7 +1,7 @@
import type { ColorLabel } from "@photoreport/contracts";
import { t } from "../i18n.js";
import { LABEL_COLOR } from "./Grid.js";
import { ALL_PHOTOS, cycleColor, isAll, type LibraryFilter } from "./store.js";
import { ALL_PHOTOS, cycleColor, isAll, onlyUncolored, type LibraryFilter } from "./store.js";
const FLAGS: LibraryFilter["flag"][] = ["all", "PICK", "UNFLAGGED", "UNREJECTED", "REJECT"];
const DELIVERY: LibraryFilter["delivery"][] = ["any", "unsent", "queued", "sent", "failed"];
@@ -50,13 +50,28 @@ export function FilterBar(props: { filter: LibraryFilter; onChange: (f: LibraryF
aria-pressed={on}
aria-label={hiding ? t.colorWithout(t.colors[c]) : on ? t.colorOnly(t.colors[c]) : t.colors[c]}
title={hiding ? t.colorWithout(t.colors[c]) : on ? t.colorOnly(t.colors[c]) : t.colors[c]}
className={`relative h-3 w-3 rounded-[2px] ${on ? "outline outline-1 outline-offset-1 outline-white" : "opacity-60 hover:opacity-100"}`}
className={`relative h-5 w-6 rounded-[2px] ${on ? "outline outline-2 outline-offset-1 outline-white" : "opacity-80 hover:opacity-100"}`}
style={{ background: LABEL_COLOR[c] ?? undefined }}
>
{hiding && <span aria-hidden="true" className="absolute left-1/2 top-[-3px] h-[18px] w-px -translate-x-1/2 rotate-45 bg-white" />}
</button>
);
})}
<button
type="button"
onClick={() => set(onlyUncolored(f))}
aria-pressed={f.uncolored}
aria-label={t.colorUncolored}
title={t.colorUncolored}
className={`flex h-5 items-center gap-1 rounded-[2px] border border-dotted px-1.5 text-[11px] ${f.uncolored ? "border-white bg-[#1a1a1a] text-ink outline outline-2 outline-offset-1 outline-white" : "border-faint bg-[#2a2a2a] text-muted hover:text-ink"}`}
>
<span aria-hidden="true" className="h-3 w-3 rounded-[1px] border border-dotted border-current" />
{t.colorNone}
</button>
{f.uncolored && <span className="text-ink">{t.colorUncolored}</span>}
{f.color && !f.uncolored && (
<span className="text-ink">{f.withoutColor ? t.colorWithout(t.colors[f.color]) : t.colorOnly(t.colors[f.color])}</span>
)}
</span>
{!compact && <span aria-hidden="true" className="text-line">|</span>}
{!compact && (
+1 -1
View File
@@ -70,7 +70,7 @@ const Cell = memo(function Cell({ photo, index, src, orgId, selected, focused, o
aria-pressed={selected}
aria-label={`${photo.name}${photo.flag === "PICK" ? ", escolhida" : photo.flag === "REJECT" ? ", rejeitada" : ""}${photo.rating ? `, ${photo.rating} estrelas` : ""}`}
className={`relative flex aspect-square flex-col items-center justify-between gap-1 border px-2 pb-1 pt-4 ${
selected ? "border-[#9a9a9a] bg-cell-on" : "border-[#151516] bg-cell hover:bg-[#444445]"
selected ? "border-white bg-cell-on shadow-[inset_0_0_0_2px_#fff]" : "border-[#151516] bg-cell hover:bg-[#444445]"
} ${focused ? "outline outline-1 outline-offset-[-3px] outline-white/60" : ""} ${photo.flag === "REJECT" ? "opacity-40" : ""}`}
>
<span aria-hidden="true" className="absolute left-2 top-0.5 font-mono text-xl font-bold text-white/[0.08]">
+150
View File
@@ -0,0 +1,150 @@
import type { ColorLabel } from "@photoreport/contracts";
import { useEffect, useRef, useState, type ReactNode } from "react";
import { t } from "../i18n.js";
import { LABEL_COLOR } from "./Grid.js";
const COLORS = ["NONE", "RED", "YELLOW", "GREEN", "BLUE", "PURPLE"] as const satisfies readonly ColorLabel[];
type OpenMenu = "selection" | "image" | null;
/**
* Selection and colour commands that the macOS menu bar does not offer (that bar is the webview's
* Cut / Copy / Paste). Acts on the photos in the grid, the same way Photo Mechanic's Image menu does.
*/
export function LibraryMenus(props: {
canEdit: boolean;
hasSelection: boolean;
canRemove: boolean;
onSelectAll: () => void;
onSelectNone: () => void;
onSelectUncolored: () => void;
onSelectColor: (color: ColorLabel) => void;
onColor: (color: ColorLabel) => void;
onRating: (rating: number) => void;
onFlag: (flag: "PICK" | "REJECT" | "NONE") => void;
onInfo: () => void;
onRemove: () => void;
}) {
const [open, setOpen] = useState<OpenMenu>(null);
const root = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!open) return;
const onDown = (e: MouseEvent) => {
if (root.current && !root.current.contains(e.target as Node)) setOpen(null);
};
const onKey = (e: KeyboardEvent) => {
if (e.key === "Escape") setOpen(null);
};
window.addEventListener("mousedown", onDown);
window.addEventListener("keydown", onKey);
return () => {
window.removeEventListener("mousedown", onDown);
window.removeEventListener("keydown", onKey);
};
}, [open]);
const run = (fn: () => void) => {
setOpen(null);
fn();
};
return (
<div ref={root} className="flex items-center gap-1">
<MenuButton label={t.menuSelection} pressed={open === "selection"} onClick={() => setOpen(open === "selection" ? null : "selection")}>
{open === "selection" && (
<MenuPanel>
<Item label={t.menuSelectAll} onSelect={() => run(props.onSelectAll)} />
<Item label={t.menuSelectNone} onSelect={() => run(props.onSelectNone)} />
<Item label={t.menuSelectUncolored} onSelect={() => run(props.onSelectUncolored)} />
{COLORS.filter((c) => c !== "NONE").map((c) => (
<Item key={c} label={t.menuSelectColor(t.colors[c])} swatch={LABEL_COLOR[c] ?? undefined} onSelect={() => run(() => props.onSelectColor(c))} />
))}
</MenuPanel>
)}
</MenuButton>
<MenuButton label={t.menuImage} pressed={open === "image"} onClick={() => setOpen(open === "image" ? null : "image")}>
{open === "image" && (
<MenuPanel>
<p className="px-3 pb-1 pt-1 text-[11px] text-faint">{t.menuSetColor}</p>
{COLORS.map((c) => (
<Item
key={c}
label={c === "NONE" ? t.colorNone : t.colors[c]}
disabled={!props.canEdit || !props.hasSelection}
swatch={c === "NONE" ? "none" : (LABEL_COLOR[c] ?? undefined)}
onSelect={() => run(() => props.onColor(c))}
/>
))}
<p className="px-3 pb-1 pt-2 text-[11px] text-faint">{t.menuSetRating}</p>
<div className="flex gap-1 px-3 pb-1">
{[0, 1, 2, 3, 4, 5].map((n) => (
<button
key={n}
type="button"
disabled={!props.canEdit || !props.hasSelection}
className="text-[13px] text-star disabled:opacity-40"
onClick={() => run(() => props.onRating(n))}
>
{n === 0 ? "0" : "★"}
</button>
))}
</div>
<Item label={t.photoMenuPick} disabled={!props.canEdit || !props.hasSelection} onSelect={() => run(() => props.onFlag("PICK"))} />
<Item label={t.photoMenuReject} disabled={!props.canEdit || !props.hasSelection} onSelect={() => run(() => props.onFlag("REJECT"))} />
<Item label={t.photoMenuClear} disabled={!props.canEdit || !props.hasSelection} onSelect={() => run(() => props.onFlag("NONE"))} />
<Item label={t.photoMenuInfo} disabled={!props.canEdit || !props.hasSelection} onSelect={() => run(props.onInfo)} />
{props.canRemove && (
<Item label={t.photoMenuRemove} danger disabled={!props.canEdit || !props.hasSelection} onSelect={() => run(props.onRemove)} />
)}
</MenuPanel>
)}
</MenuButton>
</div>
);
}
function MenuButton(props: { label: string; pressed: boolean; onClick: () => void; children: ReactNode }) {
return (
<div className="relative">
<button
type="button"
aria-expanded={props.pressed}
aria-haspopup="menu"
onClick={props.onClick}
className={`h-6 border border-black px-2 text-[12px] ${props.pressed ? "bg-cell-on text-ink" : "bg-cell text-ink hover:bg-cell-on"}`}
>
{props.label}
</button>
{props.children}
</div>
);
}
function MenuPanel(props: { children: ReactNode }) {
return (
<div role="menu" className="absolute left-0 top-7 z-40 min-w-[200px] border border-line bg-panel py-1 shadow-xl">
{props.children}
</div>
);
}
function Item(props: { label: string; disabled?: boolean; danger?: boolean; swatch?: string; onSelect: () => void }) {
return (
<button
type="button"
role="menuitem"
disabled={props.disabled}
className={`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[13px] disabled:opacity-40 ${
props.danger ? "text-danger hover:bg-[#3a2020]" : "text-ink hover:bg-cell-on"
}`}
onClick={() => {
if (props.disabled) return;
props.onSelect();
}}
>
{props.swatch === "none" && <span className="h-2.5 w-2.5 rounded-[2px] border border-dotted border-faint" />}
{props.swatch && props.swatch !== "none" && <span className="h-2.5 w-2.5 rounded-[2px]" style={{ background: props.swatch }} />}
{props.label}
</button>
);
}
+47 -1
View File
@@ -1,5 +1,9 @@
import type { ColorLabel } from "@photoreport/contracts";
import { useEffect, useRef } from "react";
import { t } from "../i18n.js";
import { LABEL_COLOR } from "./Grid.js";
const COLORS = ["NONE", "RED", "YELLOW", "GREEN", "BLUE", "PURPLE"] as const satisfies readonly ColorLabel[];
export interface PhotoMenuAction {
id: string;
@@ -15,6 +19,8 @@ export function PhotoContextMenu(props: {
y: number;
actions: PhotoMenuAction[];
onClose: () => void;
onColor?: (color: ColorLabel) => void;
onRating?: (rating: number) => void;
}) {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
@@ -37,7 +43,7 @@ export function PhotoContextMenu(props: {
}, [props.onClose]);
// Keep the menu on screen.
const left = Math.min(props.x, typeof window !== "undefined" ? window.innerWidth - 220 : props.x);
const top = Math.min(props.y, typeof window !== "undefined" ? window.innerHeight - props.actions.length * 32 - 16 : props.y);
const top = Math.min(props.y, typeof window !== "undefined" ? window.innerHeight - props.actions.length * 32 - 88 : props.y);
return (
<div
ref={ref}
@@ -46,6 +52,46 @@ export function PhotoContextMenu(props: {
className="fixed z-[60] min-w-[200px] border border-line bg-panel py-1 shadow-xl"
style={{ left, top }}
>
{(props.onColor || props.onRating) && (
<div className="border-b border-line px-3 py-2">
{props.onColor && (
<div className="flex items-center gap-1" role="group" aria-label={t.menuSetColor}>
{COLORS.map((c) => (
<button
key={c}
type="button"
title={c === "NONE" ? t.colorNone : t.colors[c]}
aria-label={c === "NONE" ? t.colorNone : t.colors[c]}
className={c === "NONE" ? "h-5 w-5 rounded-[2px] border border-dotted border-faint" : "h-5 w-5 rounded-[2px]"}
style={c === "NONE" ? undefined : { background: LABEL_COLOR[c] ?? undefined }}
onClick={() => {
props.onColor?.(c);
props.onClose();
}}
/>
))}
</div>
)}
{props.onRating && (
<div className="mt-1.5 flex items-center gap-1" role="group" aria-label={t.menuSetRating}>
{[0, 1, 2, 3, 4, 5].map((n) => (
<button
key={n}
type="button"
className="px-0.5 text-[14px] text-star"
aria-label={String(n)}
onClick={() => {
props.onRating?.(n);
props.onClose();
}}
>
{n === 0 ? "0" : "★"}
</button>
))}
</div>
)}
</div>
)}
{props.actions.map((a) => (
<button
key={a.id}
+54
View File
@@ -0,0 +1,54 @@
import type { ColorLabel } from "@photoreport/contracts";
import { t } from "../i18n.js";
import { LABEL_COLOR } from "./Grid.js";
const COLORS = ["NONE", "RED", "YELLOW", "GREEN", "BLUE", "PURPLE"] as const satisfies readonly ColorLabel[];
/** The row that appears as soon as photos are selected: colour, stars and flag, on the whole selection. */
export function SelectionBar(props: {
count: number;
onColor: (color: ColorLabel) => void;
onRating: (rating: number) => void;
onFlag: (flag: "PICK" | "REJECT" | "NONE") => void;
}) {
return (
<div className="flex flex-wrap items-center gap-x-4 gap-y-1 border-b border-line bg-panel px-3 py-1.5 text-[12px]">
<span className="font-semibold text-ink">{t.selected(props.count)}</span>
<span className="flex items-center gap-1" role="group" aria-label={t.menuSetColor}>
{COLORS.map((c) => (
<button
key={c}
type="button"
title={c === "NONE" ? t.colorNone : t.colors[c]}
aria-label={c === "NONE" ? t.colorNone : t.colors[c]}
onClick={() => props.onColor(c)}
className={
c === "NONE"
? "flex h-6 items-center gap-1 rounded-[2px] border border-dotted border-faint px-1.5 text-muted hover:border-white hover:text-ink"
: "h-6 w-7 rounded-[2px] hover:outline hover:outline-2 hover:outline-offset-1 hover:outline-white"
}
style={c === "NONE" ? undefined : { background: LABEL_COLOR[c] ?? undefined }}
>
{c === "NONE" ? t.colorNone : null}
</button>
))}
</span>
<span className="flex items-center gap-0.5" role="group" aria-label={t.menuSetRating}>
{[0, 1, 2, 3, 4, 5].map((n) => (
<button key={n} type="button" className="px-0.5 text-[15px] text-star" aria-label={String(n)} onClick={() => props.onRating(n)}>
{n === 0 ? "0" : "★"}
</button>
))}
</span>
<button type="button" className="h-6 border border-black bg-cell px-2 text-ink hover:bg-cell-on" onClick={() => props.onFlag("PICK")}>
{t.photoMenuPick}
</button>
<button type="button" className="h-6 border border-black bg-cell px-2 text-ink hover:bg-cell-on" onClick={() => props.onFlag("REJECT")}>
{t.photoMenuReject}
</button>
<button type="button" className="h-6 border border-black bg-cell px-2 text-ink hover:bg-cell-on" onClick={() => props.onFlag("NONE")}>
{t.photoMenuClear}
</button>
</div>
);
}
+13 -2
View File
@@ -12,7 +12,7 @@ const squads: EventSquads = {
side: "home",
team: { id: "t1", name: "ÁGUAS SANTAS MILANEZA", abbreviation: "ASM", logoUrl: null },
players: [
{ id: "pl1", number: "5", name: "Miguel Baptista", fullName: null, position: null, hasPhoto: false, personId: "pe1", photos: { confirmed: 0, likely: 2 }, photoIds: ["a", "b"] },
{ id: "pl1", number: "5", name: "Miguel Baptista", fullName: null, position: null, hasPhoto: true, faceUrl: "/v1/files/persons/pe1/reference", hasFace: true, personId: "pe1", photos: { confirmed: 0, likely: 2 }, photoIds: ["a", "b"] },
{ id: "pl2", number: "7", name: "Gabriel", fullName: null, position: null, hasPhoto: false, personId: null, photos: { confirmed: 0, likely: 0 }, photoIds: [] },
],
},
@@ -32,7 +32,7 @@ function Harness() {
return (
<>
<SquadsButton
api={{ eventSquads: vi.fn().mockResolvedValue(squads) } as unknown as ApiClient}
api={{ eventSquads: vi.fn().mockResolvedValue(squads), absolute: (path: string) => path } as unknown as ApiClient}
event={{ id: "e1", homeTeamId: "t1", awayTeamId: "t2" } as EventSummary}
canEdit={false}
onSaved={() => {}}
@@ -59,4 +59,15 @@ describe("squad panel", () => {
await waitFor(() => expect(screen.getByTestId("picked").textContent).toBe("b+c"));
expect(miguel.getAttribute("aria-pressed")).toBe("false");
});
it("shows each athlete's face only when asked", async () => {
window.localStorage.clear();
render(<Harness />);
fireEvent.click(screen.getByRole("button", { name: "Plantéis" }));
await screen.findByRole("button", { name: /Miguel Baptista/ });
expect(document.querySelector("img")).toBeNull();
fireEvent.click(screen.getByRole("button", { name: "Caras" }));
expect(document.querySelector("img")?.getAttribute("src")).toContain("/v1/files/persons/pe1/reference");
expect(document.querySelectorAll("span[title$='Sem cara']").length).toBe(2);
});
});
+39 -1
View File
@@ -1,9 +1,12 @@
import { ApiError, type ApiClient, type EventSquads, type EventSummary } from "@photoreport/sdk";
import { useEffect, useState } from "react";
import { t } from "../i18n.js";
import { prefs } from "../platform.js";
import { FixturePicker } from "./EventForm.js";
import { type PlayerPick, picksFrom } from "./squadFilter.js";
const FACES_PREF = "squad-faces";
/**
* The open event's squads (from the federations): who is who by number, and whether each player is already a person
* of the organisation (faces and jersey numbers name people). An older event can be linked to its match here.
@@ -11,6 +14,7 @@ import { type PlayerPick, picksFrom } from "./squadFilter.js";
*/
export function SquadsButton({ api, event, canEdit, onSaved, facesTick = 0, selectedIds = [], onPlayers }: { api: ApiClient; event: EventSummary; canEdit: boolean; onSaved: (e: EventSummary) => void; facesTick?: number; selectedIds?: readonly string[]; onPlayers?: (picks: PlayerPick[]) => void }) {
const [open, setOpen] = useState(false);
const [showFaces, setShowFaces] = useState(() => prefs.get(FACES_PREF) === "1");
const [squads, setSquads] = useState<EventSquads | null>(null);
const [status, setStatus] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
@@ -86,6 +90,20 @@ export function SquadsButton({ api, event, canEdit, onSaved, facesTick = 0, sele
)
) : (
<div className="grid grid-cols-2 gap-3 p-3 max-sm:grid-cols-1">
<div className="col-span-full flex justify-end">
<button
type="button"
aria-pressed={showFaces}
onClick={() => {
const next = !showFaces;
setShowFaces(next);
prefs.set(FACES_PREF, next ? "1" : "0");
}}
className={`h-6 border border-black px-2 ${showFaces ? "bg-accent text-white" : "bg-cell text-ink hover:bg-cell-on"}`}
>
{t.sports.showFaces}
</button>
</div>
{squads?.sides.map((s) => (
<div key={s.side}>
<p className="mb-1 font-semibold text-ink">{s.team.name}</p>
@@ -100,8 +118,9 @@ export function SquadsButton({ api, event, canEdit, onSaved, facesTick = 0, sele
aria-pressed={on}
title={p.personId ? t.sports.photosHelp(p.photos?.confirmed ?? 0, p.photos?.likely ?? 0) : t.sports.notPerson}
onClick={() => toggle(p.id)}
className={`flex w-full gap-2 px-1 py-0.5 text-left ${on ? "bg-cell-on" : "hover:bg-cell"} disabled:cursor-default disabled:hover:bg-transparent`}
className={`flex w-full items-center gap-2 px-1 py-0.5 text-left ${on ? "bg-cell-on" : "hover:bg-cell"} disabled:cursor-default disabled:hover:bg-transparent`}
>
{showFaces && <FaceThumb name={p.name} url={p.faceUrl} hasFace={p.hasFace === true} absolute={(path) => api.absolute(path)} />}
<span className="w-7 shrink-0 text-right font-mono text-accent">{p.number ?? "–"}</span>
<span className="truncate text-ink">{p.name}</span>
<span className="ml-auto shrink-0 font-mono text-[11px]">
@@ -140,3 +159,22 @@ export function SquadsButton({ api, event, canEdit, onSaved, facesTick = 0, sele
</div>
);
}
/** The enrolled face, the squad photo, or an empty slot when this athlete has neither. */
function FaceThumb(props: { name: string; url?: string | null; hasFace: boolean; absolute: (path: string) => string }) {
const [failed, setFailed] = useState(false);
if (!props.url || failed) {
return <span title={`${props.name}: ${t.sports.faceNone}`} className="inline-block h-8 w-8 shrink-0 border border-dashed border-[#555] bg-raised" />;
}
const title = props.hasFace ? t.sports.faceKnown : t.sports.faceSquadOnly;
return (
<img
src={props.absolute(props.url)}
alt=""
title={`${props.name}: ${title}`}
loading="lazy"
onError={() => setFailed(true)}
className={`h-8 w-8 shrink-0 object-cover ${props.hasFace ? "outline outline-1 outline-offset-[-1px] outline-white" : "opacity-70"}`}
/>
);
}
+3 -2
View File
@@ -53,8 +53,9 @@ export function savedFilter(orgId: string): LibraryFilter {
return {
flag: FLAGS.includes(v.flag as string) ? v.flag! : "all",
minRating: Number.isInteger(v.minRating) && v.minRating! >= 0 && v.minRating! <= 5 ? v.minRating! : 0,
color: COLORS.includes(v.color as string) ? v.color! : null,
withoutColor: v.withoutColor === true && COLORS.includes(v.color as string),
color: v.uncolored === true || !COLORS.includes(v.color as string) ? null : v.color!,
withoutColor: v.uncolored !== true && v.withoutColor === true && COLORS.includes(v.color as string),
uncolored: v.uncolored === true,
delivery: DELIVERY.includes(v.delivery as string) ? v.delivery! : "any",
noPlayers: v.noPlayers === true,
};
+7 -2
View File
@@ -1,6 +1,6 @@
import type { PhotoSummary } from "@photoreport/contracts";
import { describe, expect, it } from "vitest";
import { ALL_PHOTOS, cycleColor, initialLibrary, type LibraryFilter, libraryReducer, matchesFilter, patchForKey } from "./store.js";
import { ALL_PHOTOS, cycleColor, initialLibrary, type LibraryFilter, libraryReducer, matchesFilter, onlyUncolored, patchForKey } from "./store.js";
const photo = (id: string, capturedAt: string, extra: Partial<PhotoSummary> = {}): PhotoSummary => ({
id,
@@ -80,7 +80,12 @@ describe("library store", () => {
expect(matchesFilter(photo("a", "", { colorLabel: "RED" }), hideRed)).toBe(false);
expect(matchesFilter(photo("a", "", { colorLabel: "NONE" }), hideRed)).toBe(true);
expect(matchesFilter(photo("a", "", { colorLabel: "GREEN" }), hideRed)).toBe(true);
expect(cycleColor(hideRed, "RED")).toEqual({ color: null, withoutColor: false });
expect(cycleColor(hideRed, "RED")).toEqual({ color: null, withoutColor: false, uncolored: false });
const bare = onlyUncolored(ALL_PHOTOS);
expect(bare).toEqual({ color: null, withoutColor: false, uncolored: true });
expect(matchesFilter(photo("a", "", { colorLabel: "NONE" }), { ...ALL_PHOTOS, ...bare })).toBe(true);
expect(matchesFilter(photo("a", "", { colorLabel: "RED" }), { ...ALL_PHOTOS, ...bare })).toBe(false);
expect(onlyUncolored({ ...ALL_PHOTOS, ...bare })).toEqual({ color: null, withoutColor: false, uncolored: false });
expect(matchesFilter(photo("a", "", { delivery: "FAILED" }), { ...ALL_PHOTOS, delivery: "failed" })).toBe(true);
});
+17 -8
View File
@@ -221,21 +221,29 @@ export interface LibraryFilter {
color: ColorLabel | null;
/** When set with `color`, hide photos that wear it and keep the rest. */
withoutColor: boolean;
/** Photo Mechanic's dotted chip: only photos with no colour class. */
uncolored: boolean;
delivery: "any" | "unsent" | "queued" | "sent" | "failed";
noPlayers: boolean;
}
export const ALL_PHOTOS: LibraryFilter = { flag: "all", minRating: 0, color: null, withoutColor: false, delivery: "any", noPlayers: false };
export const ALL_PHOTOS: LibraryFilter = { flag: "all", minRating: 0, color: null, withoutColor: false, uncolored: false, delivery: "any", noPlayers: false };
export function isAll(f: LibraryFilter): boolean {
return f.flag === "all" && !f.minRating && !f.color && !f.withoutColor && f.delivery === "any" && !f.noPlayers;
return f.flag === "all" && !f.minRating && !f.color && !f.withoutColor && !f.uncolored && f.delivery === "any" && !f.noPlayers;
}
/** Colour chip: first click keeps that colour, second click hides it, third click clears. */
export function cycleColor(f: LibraryFilter, color: ColorLabel): Pick<LibraryFilter, "color" | "withoutColor"> {
if (f.color !== color) return { color, withoutColor: false };
if (!f.withoutColor) return { color, withoutColor: true };
return { color: null, withoutColor: false };
export function cycleColor(f: LibraryFilter, color: ColorLabel): Pick<LibraryFilter, "color" | "withoutColor" | "uncolored"> {
if (f.uncolored || f.color !== color) return { color, withoutColor: false, uncolored: false };
if (!f.withoutColor) return { color, withoutColor: true, uncolored: false };
return { color: null, withoutColor: false, uncolored: false };
}
/** The dotted chip: only photos that have no colour, or back to every colour. */
export function onlyUncolored(f: LibraryFilter): Pick<LibraryFilter, "color" | "withoutColor" | "uncolored"> {
if (f.uncolored) return { color: null, withoutColor: false, uncolored: false };
return { color: null, withoutColor: false, uncolored: true };
}
export function matchesFilter(photo: PhotoSummary, f: LibraryFilter): boolean {
@@ -244,8 +252,9 @@ export function matchesFilter(photo: PhotoSummary, f: LibraryFilter): boolean {
if (f.flag === "UNREJECTED" && photo.flag === "REJECT") return false;
if (f.flag === "UNFLAGGED" && photo.flag !== "NONE") return false;
if (f.minRating && photo.rating < f.minRating) return false;
if (f.color && f.withoutColor && photo.colorLabel === f.color) return false;
if (f.color && !f.withoutColor && photo.colorLabel !== f.color) return false;
if (f.uncolored && photo.colorLabel !== "NONE") return false;
if (!f.uncolored && f.color && f.withoutColor && photo.colorLabel === f.color) return false;
if (!f.uncolored && f.color && !f.withoutColor && photo.colorLabel !== f.color) return false;
const d = photo.delivery ?? "NONE";
if (f.delivery === "unsent" && d !== "NONE") return false;
if (f.delivery === "queued" && d !== "QUEUED") return false;
+62 -22
View File
@@ -18,7 +18,7 @@ import { beginDropWait, folderDropPath, folderMeta, htmlDropIsFolder, mergeFolde
import { finishMergedJpeg } from "../library/finishMergedJpeg.js";
import { mergeFolderNative } from "../library/folderMerge.js";
import { MERGE_EDGE } from "../library/mergeStacks.js";
import { Grid, LABEL_COLOR, Loupe, type LoupeFace } from "../library/Grid.js";
import { Grid, Loupe, type LoupeFace } from "../library/Grid.js";
import { InfoPanel } from "../library/InfoPanel.js";
import { IptcInfo } from "../library/IptcInfo.js";
import { useLibraryLive } from "../library/realtime.js";
@@ -40,6 +40,8 @@ import { isNetworkError, offlineQueue } from "../offline/queue.js";
import { ensureRoster } from "../offline/roster.js";
import { patchPhotos, useQueueSize } from "../offline/sync.js";
import { FilterBar } from "../library/FilterBar.js";
import { LibraryMenus } from "../library/LibraryMenus.js";
import { SelectionBar } from "../library/SelectionBar.js";
import { SendButton } from "../library/SendButton.js";
import { isDesktop, prefs } from "../platform.js";
import { activePhoto, savedFilter, saveFilter, setActivePhoto } from "../library/active.js";
@@ -62,6 +64,7 @@ export function LibraryPage() {
const [targets, setTargets] = useState<DeliveryTarget[]>([]);
const [iptcOpen, setIptcOpen] = useState(false);
const [photoMenu, setPhotoMenu] = useState<{ x: number; y: number; id: string } | null>(null);
const [dropPartial, setDropPartial] = useState(false);
const { open: openFolderScan, syncGames } = useFolderScan();
const [state, dispatch] = useReducer(libraryReducer, initialLibrary);
const [filter, setFilterState] = useState<LibraryFilter>(() => savedFilter(orgId));
@@ -545,6 +548,28 @@ export function LibraryPage() {
<div className="flex min-h-[70vh] min-w-0 flex-1 flex-col lg:min-h-0">
<div className="flex flex-wrap items-center gap-x-4 gap-y-1 border-b border-line bg-raised px-3 py-1.5 text-[12px]">
{!sheet && (
<LibraryMenus
canEdit={canCull}
hasSelection={selection.length > 0}
canRemove={isEventScope(state.scope)}
onSelectAll={() => dispatch({ type: "selectAll", visible: visibleIds })}
onSelectNone={() => dispatch({ type: "selectAll", visible: [] })}
onSelectUncolored={() => {
const ids = visible.filter((p) => p.colorLabel === "NONE").map((p) => p.id);
dispatch({ type: "selectMany", ids, focus: ids[0] ?? null });
}}
onSelectColor={(color) => {
const ids = visible.filter((p) => p.colorLabel === color).map((p) => p.id);
dispatch({ type: "selectMany", ids, focus: ids[0] ?? null });
}}
onColor={(color) => void patch(selection.map((p) => p.id), { colorLabel: color })}
onRating={(rating) => void patch(selection.map((p) => p.id), { rating })}
onFlag={(flag) => void patch(selection.map((p) => p.id), { flag })}
onInfo={() => setIptcOpen(true)}
onRemove={() => setRemoveOpen(true)}
/>
)}
<FilterBar filter={filter} onChange={setFilter} />
{players.length > 0 && (
<span className="flex min-w-0 items-center gap-2">
@@ -606,25 +631,6 @@ export function LibraryPage() {
{canCull && openEvent && (
<AutopilotButton api={api} event={openEvent} targets={targets} canEdit={canCreate} onSaved={(e) => setEvents((list) => list.map((x) => (x.id === e.id ? e : x)))} />
)}
{canCull && !sheet && selection.length > 0 && (
<span className="flex items-center gap-1" role="group" aria-label={t.markColor}>
<span className="text-faint">{t.markColor}</span>
{(["RED", "YELLOW", "GREEN", "BLUE", "PURPLE"] as const).map((c) => (
<button
key={c}
type="button"
title={t.colors[c]}
aria-label={t.colors[c]}
className="h-3.5 w-3.5 rounded-[2px] hover:outline hover:outline-1 hover:outline-offset-1 hover:outline-white"
style={{ background: LABEL_COLOR[c] ?? undefined }}
onClick={() => {
const clearing = selection.every((p) => p.colorLabel === c);
void patch(selection.map((p) => p.id), { colorLabel: clearing ? "NONE" : c });
}}
/>
))}
</span>
)}
{canCull && !sheet && selection.length > 0 && (
<select
aria-label={t.shop.addToGallery}
@@ -733,6 +739,7 @@ export function LibraryPage() {
</span>
)}
<span>
{selection.length > 0 ? `${t.selected(selection.length)} · ` : ""}
{t.ofTotal(visible.length, state.photos.length)} · {picks} ⚑
</span>
<span className="flex items-center gap-1.5" title={live}>
@@ -742,6 +749,15 @@ export function LibraryPage() {
</span>
</div>
{canCull && !sheet && selection.length > 0 && (
<SelectionBar
count={selection.length}
onColor={(color) => void patch(selection.map((p) => p.id), { colorLabel: color })}
onRating={(rating) => void patch(selection.map((p) => p.id), { rating })}
onFlag={(flag) => void patch(selection.map((p) => p.id), { flag })}
/>
)}
<div
className={`min-h-0 flex-1 ${sheet ? "flex flex-col overflow-hidden" : "overflow-y-auto"} ${dragging ? "outline outline-2 -outline-offset-4 outline-accent" : ""}`}
onDragOver={(e) => {
@@ -760,10 +776,27 @@ export function LibraryPage() {
return;
}
void beginDropWait().then((kind) => {
if (kind === "files") uploads.add(files, uploadInto);
if (kind !== "files") return;
// The current shell only receives the few files WebKit lists. Do not upload that slice.
setDropPartial(true);
});
}}
>
{dropPartial && (
<p className="m-3 flex items-center gap-3 border border-star/50 bg-star/10 px-3 py-2 text-[13px] text-ink">
<span>{t.dropPartial}</span>
<button
type="button"
className="h-7 border border-black bg-cell px-2.5 text-ink hover:bg-cell-on"
onClick={() => {
setDropPartial(false);
fileInput.current?.click();
}}
>
{t.dropChoose}
</button>
</p>
)}
{error && (
<p role="alert" className="m-3 border border-danger/40 bg-danger/10 px-3 py-2 text-[13px] text-danger">
{error}
@@ -875,7 +908,14 @@ export function LibraryPage() {
/>
{photoMenu && photoMenuActions.length > 0 && (
<PhotoContextMenu x={photoMenu.x} y={photoMenu.y} actions={photoMenuActions} onClose={() => setPhotoMenu(null)} />
<PhotoContextMenu
x={photoMenu.x}
y={photoMenu.y}
actions={photoMenuActions}
onClose={() => setPhotoMenu(null)}
onColor={(color) => void patch(selection.map((p) => p.id), { colorLabel: color })}
onRating={(rating) => void patch(selection.map((p) => p.id), { rating })}
/>
)}
{removeOpen && isEventScope(state.scope) && (
<RemoveFromEventDialog
@@ -40,6 +40,10 @@ describe("decide", () => {
expect(decide("api", "issues", push(["apps/api/x"])).action).toBe("ignore");
});
it("deploys when a merge commit lists no files", () => {
expect(decide("app", "push", push([])).action).toBe("deploy");
});
it("deploys when Gitea truncated the commit list", () => {
expect(decide("ml", "push", push(["docs/x.md"], { total_commits: 30 })).action).toBe("deploy");
});
+2
View File
@@ -33,6 +33,8 @@ export function decide(service: Service, event: string | undefined, payload: Pus
return { action: "deploy", sha, reason: "commit list truncated" };
}
const paths = commits.flatMap((c) => [...(c.added ?? []), ...(c.modified ?? []), ...(c.removed ?? [])]);
// A merge commit often arrives with an empty file list. Skipping it left the app on an older build.
if (paths.length === 0) return { action: "deploy", sha, reason: "push listed no paths" };
return touchesService(service, paths)
? { action: "deploy", sha, reason: "owned paths changed" }
: { action: "ignore", reason: "no owned paths changed" };
+4
View File
@@ -219,6 +219,10 @@ export interface EventSquads {
fullName: string | null;
position: string | null;
hasPhoto: boolean;
/** The enrolled face, or the squad photo when there is no face yet. */
faceUrl?: string | null;
/** An enrolled reference face, the one recognition uses. */
hasFace?: boolean;
personId: string | null;
/** Photos of them in this event: confirmed, and taken for them by the faces (70% or more) not confirmed yet. */
photos?: { confirmed: number; likely: number };