Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
010ef22f62 |
No files matched your search
@@ -105,6 +105,9 @@ export const t = {
|
||||
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",
|
||||
|
||||
@@ -50,7 +50,7 @@ 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" />}
|
||||
@@ -63,8 +63,15 @@ export function FilterBar(props: { filter: LibraryFilter; onChange: (f: LibraryF
|
||||
aria-pressed={f.uncolored}
|
||||
aria-label={t.colorUncolored}
|
||||
title={t.colorUncolored}
|
||||
className={`h-3 w-3 rounded-[2px] border border-dotted ${f.uncolored ? "border-white bg-[#1a1a1a] outline outline-1 outline-offset-1 outline-white" : "border-faint bg-[#2a2a2a] opacity-80 hover:opacity-100"}`}
|
||||
/>
|
||||
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 && (
|
||||
|
||||
@@ -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]">
|
||||
|
||||
@@ -18,6 +18,7 @@ export function LibraryMenus(props: {
|
||||
onSelectAll: () => void;
|
||||
onSelectNone: () => void;
|
||||
onSelectUncolored: () => void;
|
||||
onSelectColor: (color: ColorLabel) => void;
|
||||
onColor: (color: ColorLabel) => void;
|
||||
onRating: (rating: number) => void;
|
||||
onFlag: (flag: "PICK" | "REJECT" | "NONE") => void;
|
||||
@@ -55,6 +56,9 @@ export function LibraryMenus(props: {
|
||||
<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>
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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";
|
||||
@@ -41,6 +41,7 @@ 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";
|
||||
@@ -63,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));
|
||||
@@ -557,6 +559,10 @@ export function LibraryPage() {
|
||||
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 })}
|
||||
@@ -625,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}
|
||||
@@ -752,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}>
|
||||
@@ -761,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) => {
|
||||
@@ -779,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}
|
||||
@@ -894,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");
|
||||
});
|
||||
|
||||
@@ -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" };
|
||||
|
||||
Reference in new issue
Block a user