shadcn.io is not affiliated with official shadcn/ui
User Permissions Table Block for Solid
A sharing table of five people with a role select and Read, Write, Delete and Admin boxes, where a role sets the boxes, editing a box makes the role Custom and three rules keep the boxes consistent.
Installation
Overview
Let people be given access by role and then adjusted, with this user permissions table for Solid with Ark UI. A compact header names the folder. Inside a hairline frame with a plus mark on each corner, a native table lists five people of an Accessnook vault, each with a Native Select for the role (Viewer, Editor, Admin or Custom) and four Checkbox boxes: Read, Write, Delete and Admin. Choosing a role sets the boxes; changing a box by hand turns the role into Custom. Three rules run on every edit and a polite line says what they did: Admin includes everything, anything beyond Read needs Read, and clearing Read clears the rest. A note beside the table, "What the rules do", lists the three; below the large breakpoint it moves under the table. On a phone the four boxes stack under the role as small labelled boxes. It is built from Native Select, Checkbox, Avatar and Guides. For sharing dialogs, folder access and any list where a role is a shortcut for boxes.
FAQ
How do I use my own people, roles and boxes?
Edit PEOPLE, START (each person's role and ticked boxes), BITS for the boxes and presetBits for what each role ticks. The three rules live in nextBits, one small function: change it if your product's rules differ, and the note beside the table (RULES) to match.
When does a role become Custom?
The moment you tick or clear a box yourself, even if the result happens to match a preset. Choosing Viewer, Editor or Admin from the select sets the boxes again; choosing Custom leaves them as they are. That keeps the select honest about what you did last.
What do the three rules do exactly?
Ticking Admin ticks Read, Write and Delete too. Ticking Write, Delete or Admin ticks Read if it wasn't. Clearing Read clears every other box. After an edit the status line names what came along, for example "Teodor: Admin ticked. Read, Write and Delete came with it. Now Custom."
Is it accessible?
Each select is named by its person ("Role of Teodor Wirth") and each box by its action and person ("Write for Teodor Wirth"). The table has a caption, the person is the row header and one polite line reports every change. On a phone the labelled boxes carry the same names, and only the set for the current width is in the page.
What stays local, and how do I wire real sharing?
The five people and their boxes are one useState list and nothing is sent. To make it real, call your API from setBit and setRole, send the whole set of boxes rather than one flag, and apply the rules on the server as well so a stale client can't leave Write ticked without Read.