feat(auth): disable write affordances for viewer role

This commit is contained in:
Nora
2026-06-22 15:20:05 -06:00
parent b8b679b108
commit f91d7b3b46
5 changed files with 166 additions and 103 deletions
+26 -15
View File
@@ -18,6 +18,7 @@ import {
resubmitRejectedWithDownload,
} from "@/lib/inbox-api";
import { downloadBlob } from "@/lib/download";
import { RoleGate } from "@/auth/RoleGate";
type LaneKey = "rejected" | "candidates" | "unmatched" | "done_today";
@@ -202,21 +203,31 @@ export default function Inbox() {
/>
</main>
{/* Per-lane bulk bars. Each shows when its lane has a selection. */}
<BulkBar
lane="rejected"
count={selected.rejected.length}
onResubmit={onResubmit}
onDismiss={() => {}}
onExport={() => onExport("rejected")}
/>
<BulkBar
lane="candidates"
count={selected.candidates.length}
onResubmit={() => {}}
onDismiss={onDismiss}
onExport={() => onExport("candidates")}
/>
{/* Per-lane bulk bars. Each shows when its lane has a selection.
The two write-affordance BulkBars (rejected → resubmit,
candidates → dismiss) are gated by RoleGate so a viewer-role
account can still SEE the rows and select them but cannot
trigger a state change. The export buttons live inside the
same BulkBar component but are read-only, so we let them
remain visible to viewers. */}
<RoleGate allow={["admin", "user"]} fallback={null}>
<BulkBar
lane="rejected"
count={selected.rejected.length}
onResubmit={onResubmit}
onDismiss={() => {}}
onExport={() => onExport("rejected")}
/>
</RoleGate>
<RoleGate allow={["admin", "user"]} fallback={null}>
<BulkBar
lane="candidates"
count={selected.candidates.length}
onResubmit={() => {}}
onDismiss={onDismiss}
onExport={() => onExport("candidates")}
/>
</RoleGate>
<BulkBar
lane="unmatched"
count={selected.unmatched.length}