Skip to content

Allow to add translation prefix to custom subuser permissions#2265

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

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

Conversation

@Boy132
Copy link
Copy Markdown
Member

@Boy132 Boy132 commented Feb 24, 2026

Closes #2069
Supersedes #2185

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

coderabbitai bot commented Feb 24, 2026

📝 Walkthrough

Walkthrough

Adds dynamic, prefix-based translation key handling for subuser permission labels/descriptions and extends the Subuser model to register and emit a translation_prefix for permission groups; also adds many English permission translation entries.

Changes

Cohort / File(s) Summary
Permission Data Model
app/Models/Subuser.php
Added BackedEnum import; changed registerCustomPermissions signature to accept optional $translationPrefix; widened stored icon type and added translation_prefix to $customPermissions; allPermissionData now includes translation_prefix and uses 'server/user.permissions' as default.
UI Localization (Resource)
app/Filament/Server/Resources/Subusers/SubuserResource.php
Replaced hard-coded translation keys for permission descriptions, tab titles, and section descriptions with dynamic resolution using each group's translation_prefix (pattern: translation_prefix + '.' + name + ...).
Translation Entries
lang/en/server/user.php
Added multiple new permission category titles and individual permission keys/descriptions (Activity, Startup, Settings, Control, User, File, Allocation, Database, Backup, Schedule, 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.

📝 Coding Plan
  • Generate coding plan for human review comments

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
Copy Markdown

@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

Comment thread app/Models/Subuser.php
Copy link
Copy Markdown

@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.

♻️ Duplicate comments (1)
app/Models/Subuser.php (1)

52-52: ⚠️ Potential issue | 🟠 Major

Public API break from inserted positional parameter.

Line 52 inserts $translationPrefix before $icon and $hidden, which breaks existing positional calls to registerCustomPermissions(...) (including potential enum icon callers). This is the same unresolved compatibility issue previously flagged.

💡 Backward-compatible signature adjustment
- public static function registerCustomPermissions(string $name, array $permissions, ?string $translationPrefix = null, null|string|BackedEnum $icon = null, ?bool $hidden = null): void
+ public static function registerCustomPermissions(string $name, array $permissions, null|string|BackedEnum $icon = null, ?bool $hidden = null, ?string $translationPrefix = null): void
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/Models/Subuser.php` at line 52, The new positional parameter breaks the
public API of Subuser::registerCustomPermissions; revert to a
backward-compatible signature by moving $translationPrefix to the end as an
optional parameter (keep types: string|null and existing union for $icon:
null|string|BackedEnum) so existing callers using positional $icon/$hidden
continue to work; update the function declaration for registerCustomPermissions
and adjust internal usages to read the moved parameter, and add a short
docblock/deprecation note if desired for the old ordering.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@app/Models/Subuser.php`:
- Line 52: The new positional parameter breaks the public API of
Subuser::registerCustomPermissions; revert to a backward-compatible signature by
moving $translationPrefix to the end as an optional parameter (keep types:
string|null and existing union for $icon: null|string|BackedEnum) so existing
callers using positional $icon/$hidden continue to work; update the function
declaration for registerCustomPermissions and adjust internal usages to read the
moved parameter, and add a short docblock/deprecation note if desired for the
old ordering.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 964b3566-3535-478d-92c4-255f7d462e09

📥 Commits

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

📒 Files selected for processing (1)
  • app/Models/Subuser.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