Disable row selection for non-lockable documents

Public / already-authorized and already-requested rows could be ticked
even though they never contribute to "Request Access (N)", making the
selection count look inconsistent with the CTA. Restrict selection to
locked rows: their checkbox is disabled otherwise, and "Select all" now
picks only the lockable rows.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-07-27 14:51:08 +02:00
parent 9353d85d03
commit 1d6218cb7d
2 changed files with 9 additions and 3 deletions

View File

@@ -66,6 +66,11 @@ export function DocumentEntry({
}: DocumentEntryProps) { }: DocumentEntryProps) {
const { t } = useTranslation("documents"); const { t } = useTranslation("documents");
// Only locked rows (not yet authorized, no pending request) can be requested,
// so only they are selectable — the checkbox is disabled otherwise to avoid a
// selection that wouldn't contribute to "Request Access".
const selectable = !isAuthorized && !requested;
const mobileHitLabel = requested const mobileHitLabel = requested
? null ? null
: isAuthorized : isAuthorized
@@ -84,8 +89,9 @@ export function DocumentEntry({
// triggers the row's view / request-access activation. // triggers the row's view / request-access activation.
<Checkbox <Checkbox
className="relative z-2" className="relative z-2"
checked={selected ?? false} checked={selectable && (selected ?? false)}
onCheckedChange={onSelectedChange} disabled={!selectable}
onCheckedChange={selectable ? onSelectedChange : undefined}
aria-label={t("selection.selectRow", { title: typeof title === "string" ? title : "" })} aria-label={t("selection.selectRow", { title: typeof title === "string" ? title : "" })}
/> />
)} )}

View File

@@ -68,7 +68,7 @@ export function DocumentsSelectionBar({ entries }: DocumentsSelectionBarProps) {
<Button <Button
variant="ghost" variant="ghost"
color="neutral" color="neutral"
onClick={() => selectAll(entries.map(entry => entry.id))} onClick={() => selectAll(entries.filter(entry => entry.locked).map(entry => entry.id))}
> >
{t("selection.selectAll")} {t("selection.selectAll")}
</Button> </Button>