Permission matrix per role — Workspace block

Pro

workspace-permission-matrix-per-role · for app, settings pages

Permission matrix per role

One selected role with a readable resource list, the merchant's own permissions only.

Documentation

Installation

One command copies the block into your project with the shadcn CLI (the registry is set once: Installation).

pnpm dlx shadcn-vue@latest add @trame/workspace-permission-matrix-per-role

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import WorkspacePermissionMatrixPerRole from '@/components/trame/blocks/workspace/workspace-permission-matrix-per-role.vue'

const props = {
title: "Workshop access",
roles: [
{
id: "atelier",
name: "Workshop"
},
{
id: "accueil",
name: "Front desk"
}
],
resources: [
{
id: "documents",
name: "Documents"
},
{
id: "commandes",
name: "Orders"
}
],
grants: [
{
roleId: "atelier",
resourceId: "documents",
permission: "read",
allowed: true
},
{
roleId: "atelier",
resourceId: "documents",
permission: "write",
allowed: true,
lockedReason: "Access is managed by the workspace lead."
}
],
toggle: "edit-permission"
}
</script>

<template>
<WorkspacePermissionMatrixPerRole v-bind="props" />
</template>

Props

Each prop says who changes it: Words, Picture, Action, Design, Data.* required.

PropTypeDescription
title*stringWordsthe section’s heading
roles*Role[] | nullDatathe roles, one row each
resources*Resource[]Datathe resources, one column group each
grants*Grant[]Datawho may do what: one entry per role, resource and permission
togglestringActiona grant’s box: the host receives `{ roleId, resourceId, permission, allowed }`, saves it and sends the grants back
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Role roles[] · 3 props
PropTypeDescription
id*stringDatathe role’s id
name*stringWordsthe role’s name
userCountnumberhow many users hold the role
Resource resources[] · 2 props
PropTypeDescription
id*stringDatathe resource’s id
name*stringWordsthe resource’s name
Grant grants[] · 5 props
PropTypeDescription
roleId*stringDatathe id of the role
resourceId*stringDatathe id of the resource
permission*'read' | 'write' | 'create' | 'delete'the permission: read, write, create or delete
allowed*booleantrue: the role has this permission
lockedReasonstringWordswhy it cannot be changed, when it cannot
Options options · 1 props
PropTypeDescription
mood'inverse' | 'brand' | 'warm' | 'tint' | stringa band of the page that redefines the theme surfaces inside it
What it asks your app for

The block never knows your app: it asks it, through one context provided once, where its links lead, what its actions do, how a price reads and which words to say (The host context).

MemberWhat it is for
hrefthe address an action leads to, or null to hide what leads there
actruns a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error }
canwhether the page has this action
cartCountthe cart badge’s number
cartDrawerwhether your app has a cart drawer
cartOpenwhether the cart drawer is open
labelyour word for an interface key, or undefined to keep the block’s own

The words it says itself, in English and French; label(key) replaces any of them:

KeyEnglishFrench
newsletter.alreadyYou are already subscribed.Vous êtes déjà inscrit.
newsletter.doneDone: you are subscribed.C’est noté : vous êtes inscrit.
newsletter.invalidCheck the email address.Vérifiez l’adresse e-mail.
newsletter.tooManyToo many attempts, try again in a moment.Trop de tentatives, réessayez dans un moment.

Features

  • Every word in the server HTML
  • Same markup in Vue and React
  • Theme tokens only: every theme, light and dark
  • Shows what you give it, invents nothing
  • No motion; still under reduced motion
  • Real buttons and links, a visible focus
  • Asks your app through actions: permission.set
  • Reads roles, permissions from your app

A workspace section, for app, settings pages.

More workspace blocks

  • Directory cards: a few spaces and a welcoming first screen: one card per space with its monogram, role and plan, and a dashed card to create another.
  • Team invitations split: A roster beside an invitation form when growing a team; roles and invitations are the organisation’s own only.
  • Team members cards: A people-first directory with role footers and a separate invitation queue, using the organisation’s own members only.
  • Team members panel: The members section of a settings page, in a column about 600 px wide, for 2 to 20 people: role counts, tabs for members and invitations, compact rows; the organisation’s own members only.
  • Team members table: A roster comparing people, roles and invitation states, using the organisation’s own members only.
  • Team presence by team: a larger organisation: one folding group per team with its count and compact rows with each person’s status in words; someone in two teams appears in both; the app’s own statuses only.
  • Team presence columns: a small team, up to about 20 people: three columns (available, away, offline) with their counts, so one sees at a glance whom to reach; the app’s own statuses only.
  • Teams cover cards: a few teams that people browse: a card each with a tinted band from the team’s colour, its members and its current projects.

All 13 workspace blocks