Skip to content

Allow to add translation prefix to custom subuser permissions#2265

Open
Boy132 wants to merge 2 commits intomainfrom
boy132/translatable-subuser-permissions
Open

Allow to add translation prefix to custom subuser permissions#2265
Boy132 wants to merge 2 commits intomainfrom
boy132/translatable-subuser-permissions

Conversation

@Boy132
Copy link
Member

@Boy132 Boy132 commented Feb 24, 2026

Closes #2069
Supersedes #2185

@Boy132 Boy132 self-assigned this Feb 24, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

📝 Walkthrough

Walkthrough

Changes introduce dynamic, prefix-based translation key resolution for subuser permissions. The Subuser model now supports custom translation prefixes via an updated registerCustomPermissions method signature, and corresponding translation entries are added for permission categories and individual permission keys.

Changes

Cohort / File(s) Summary
Permission Data Model
app/Models/Subuser.php
Added BackedEnum import and modified registerCustomPermissions signature to accept optional $translationPrefix parameter. Updated $customPermissions structure and allPermissionData return type to include translation_prefix field and allow icon as null|string|BackedEnum. Injects default translation prefix ('server/user.permissions') for all permission groups.
UI Localization
app/Filament/Server/Resources/Subusers/SubuserResource.php
Replaced hard-coded translation keys with dynamic, prefix-based key resolution for permission descriptions, tab titles, and section descriptions. Uses pattern: translation_prefix + dot + data name + [underscore + sanitized permission / _title / _desc].
Translation Entries
lang/en/server/user.php
Added 31 new translation lines with permission category titles (Activity, Startup, Settings, Control, User, File, Allocation, Database, Backup, Schedule) and corresponding individual permission keys (e.g., activity_read, control_console, user_create, file_read_content, database_view_password, etc.).
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the primary change: allowing translation prefixes to be added to custom subuser permissions, which is reflected throughout the code changes.
Description check ✅ Passed The description relates to the changeset by referencing linked issues #2069 and PR #2185 that the changes address, though it lacks detailed explanation of implementation.
Linked Issues check ✅ Passed The pull request successfully implements translation prefix support for custom subuser permissions across the Subuser model, SubuserResource, and language files, meeting the requirements of issue #2069.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing translation prefix functionality for subuser permissions and enum support for icons, with no extraneous modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/Models/Subuser.php`:
- Line 41: The new parameter $translationPrefix was inserted as the 3rd
positional argument in Subuser::registerCustomPermissions which shifts $icon and
$hidden and breaks existing callers; restore backward compatibility by moving
$translationPrefix to the end of the parameter list (e.g. keep
registerCustomPermissions(string $name, array $permissions,
null|string|BackedEnum $icon = null, ?bool $hidden = null, ?string
$translationPrefix = null)), update the method signature in
Subuser::registerCustomPermissions and any internal calls accordingly so
existing positional calls continue to work.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e35ce1e and b96b290.

📒 Files selected for processing (3)
  • app/Filament/Server/Resources/Subusers/SubuserResource.php
  • app/Models/Subuser.php
  • lang/en/server/user.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Translations for custom subuser permissions

1 participant