Modules

Team and roles

Members, seats, invitations and roles with a permission matrix and role editing.

pages/account/roles.vue
View in the demo

/account/roles has two tabs synced with ?tab=: members and roles. Roles come from useRoles() and checks from useCan(); the permission model is explained in Roles and permissions.

Files

File
Role
pages/account/roles.vueThe page with both tabs.
composables/useRoles.tsRoles, system role names and role CRUD.
mocks/roles.mock.tsRoles and team members.
config/team.config.tsViews, inactivity and invitation windows, role icons, colours and templates.
utils/team.tsMember state, seats and permission toggles, unit tested.
components/pages/account/AccountSeatsCard, AccountMemberRoleMenu, AccountRolesPanel, AccountPermissionMatrix, AccountMembersTable, AccountRoleFormPanel, AccountInvitePanel.

Permissions

The page needs roles.view.

Configuration

TEAM_VIEWS

Member views: all, active, invited and inactive.

config/team.config.ts
const TEAM_VIEWS: TeamView[]

TEAM_INACTIVE_DAYS

Days without signing in before a member is inactive.

config/team.config.ts
const TEAM_INACTIVE_DAYS: 30

TEAM_INVITE_DAYS

Days before an invitation expires.

config/team.config.ts
const TEAM_INVITE_DAYS: 7

ROLE_TEMPLATES

Templates a new role starts from.

config/team.config.ts
const ROLE_TEMPLATES: readonly ["blank", "viewer", "editor", "admin"]

ROLE_ICONS

Icons a role can take.

config/team.config.ts
const ROLE_ICONS: string[]

ROLE_COLORS

Colours a role can take.

config/team.config.ts
const ROLE_COLORS: string[]

Rules

Pure functions in utils/, unit tested in tests/unit/. Statuses and segments are derived from the stored data, never stored themselves.

memberState()

Member state.

utils/team.ts
memberState(member: Pick<TeamMember, 'status' | 'lastActiveAt'>, now: Date): TeamMemberState

seatUsage()

Seat usage.

utils/team.ts
seatUsage(members: Pick<TeamMember, 'status'>[], seats: number): { active: number; invited: number; used: number; free: number; }
Returnsactiveinvitedusedfree

togglePermission()

Toggle a permission; View is implied.

utils/team.ts
togglePermission(permissions: Permission[], module: PermissionModule, action: PermissionAction): ("dashboard.view" | "dashboard.create" | "dashboard.update" | "dashboard.delete" | "orders.view" | "orders.create" | "orders.update" | "orders.delete" | "customers.view" | ... 22 …

permissionSummary()

A readable summary.

utils/team.ts
permissionSummary(permissions: Permission[]): Record<"view" | "create" | "update" | "delete", number>

How it works

  • Members show seat usage (AccountSeatsCard, a BaseSegmentBar over the plan seats plus members without 2FA), views, an inline role menu (AccountMemberRoleMenu) and invitations with inviter and expiry.
  • Roles (AccountRolesPanel) lists roles and shows the selected one’s read-only AccountPermissionMatrix. System roles cannot be edited, only duplicated; “View as this role” switches the demo role.
  • Editing is a BaseForm inside BaseFormPanel: start from a template, pick icon and colour with BaseSwatchPicker, and set the grid with select-all per column and row. Any action of a module implies View. The footer’s #actions-start shows the permissionSummary.
© 2026 melsami UI.
Developer documentation for melsami UI.