feat(rbac): human labels + descriptions for all 50 permissions

- Add Permissions::permissionLabels() mapping every slug to a
  human-readable RO label (e.g. 'clients.view_all' → 'Vezi toți
  clienții').
- RoleResource permission checkboxes now show translated labels
  as titles + technical slug as description (so admins see both
  the meaning and the key).
- PermissionOverridesRelationManager Select 'permission_id' now
  shows 'Human label (technical.slug)' format, plus helper text
  explaining GRANT/DENY. Same format on the display column.
- +57 translations (50 permission labels in RU/EN + role page
  supporting keys + module labels).

All 306 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-18 11:16:21 +00:00
parent af0327d27d
commit 49b491a7bd
4 changed files with 185 additions and 7 deletions
@@ -35,7 +35,14 @@ class PermissionOverridesRelationManager extends RelationManager
->label(__('Drept'))
->required()
->searchable()
->options(fn () => Permission::orderBy('name')->pluck('name', 'id'))
->options(function () {
$labels = Permissions::permissionLabels();
return Permission::orderBy('name')->get()
->mapWithKeys(fn ($p) => [
$p->id => ($labels[$p->name] ? __($labels[$p->name]) . " ({$p->name})" : $p->name),
])->all();
})
->helperText(__('Alege dreptul concret pe care vrei să-l acorzi (GRANT) sau să-l refuzi (DENY) pentru acest utilizator, indiferent de rolul lui.'))
->columnSpanFull(),
Forms\Components\Select::make('mode')
->required()
@@ -61,7 +68,11 @@ class PermissionOverridesRelationManager extends RelationManager
Tables\Columns\TextColumn::make('permission.name')
->label(__('Drept'))
->searchable()
->sortable(),
->sortable()
->formatStateUsing(function ($state) {
$labels = Permissions::permissionLabels();
return isset($labels[$state]) ? __($labels[$state]) . " ({$state})" : $state;
}),
Tables\Columns\TextColumn::make('mode')
->badge()
->colors(['success' => 'grant', 'danger' => 'deny'])