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:
@@ -66,6 +66,11 @@ export function DocumentEntry({
|
||||
}: DocumentEntryProps) {
|
||||
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
|
||||
? null
|
||||
: isAuthorized
|
||||
@@ -84,8 +89,9 @@ export function DocumentEntry({
|
||||
// triggers the row's view / request-access activation.
|
||||
<Checkbox
|
||||
className="relative z-2"
|
||||
checked={selected ?? false}
|
||||
onCheckedChange={onSelectedChange}
|
||||
checked={selectable && (selected ?? false)}
|
||||
disabled={!selectable}
|
||||
onCheckedChange={selectable ? onSelectedChange : undefined}
|
||||
aria-label={t("selection.selectRow", { title: typeof title === "string" ? title : "" })}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -68,7 +68,7 @@ export function DocumentsSelectionBar({ entries }: DocumentsSelectionBarProps) {
|
||||
<Button
|
||||
variant="ghost"
|
||||
color="neutral"
|
||||
onClick={() => selectAll(entries.map(entry => entry.id))}
|
||||
onClick={() => selectAll(entries.filter(entry => entry.locked).map(entry => entry.id))}
|
||||
>
|
||||
{t("selection.selectAll")}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user