feat(panel-admin): profile tab on UserResource #256#293
Conversation
|
Warning Review limit reached
More reviews will be available in 5 minutes and 15 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds a Filament UserResource with a tabbed UserForm (account and profile sections), list/create/edit pages (ListUsers, CreateUser, EditUser), and EditUser logic to load tenant-scoped Profile data, map social links to/from a repeater, upsert profile via UpsertProfile, toggle availability via ToggleAvailability, and show success notifications. The resource is registered in PanelAdminServiceProvider and a Pest test suite verifies EditUser behaviors. Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app-modules/panel-admin/src/Filament/Resources/Users/Pages/EditUser.php`:
- Around line 49-57: The code coerces an empty social links repeater to null,
preventing UpsertProfileDTO/UpsertProfile from persisting a cleared list; in the
UpsertProfileDTO creation (the $dto assignment using UpsertProfileDTO::fromArray
and the 'social_links' key) stop converting [] to null — pass $socialLinks
directly (i.e. 'social_links' => $socialLinks) so an explicit empty array will
be persisted as “no links” instead of being ignored.
- Around line 91-103: The helper methods socialLinksToRepeater and
repeaterToSocialLinks lack precise array value-type annotations, causing phpstan
iterable value-type errors; add explicit docblock types: for
socialLinksToRepeater accept ?array<string,string> and return
array<int,array{platform:string,handle:string}> (i.e. `@param`
?array<string,string> $socialLinks and `@return`
array<int,array{platform:string,handle:string}>), and for repeaterToSocialLinks
accept array<int,array{platform:string,handle:string}> and return
array<string,string> (i.e. `@param`
array<int,array{platform:string,handle:string}> $repeaterData and `@return`
array<string,string>), leaving runtime signatures unchanged but satisfying
static analysis for the functions socialLinksToRepeater and
repeaterToSocialLinks.
- Around line 42-77: handleRecordUpdate currently updates only the profile and
availability and ignores user account fields from $data, so edits to name/email
are lost; update handleRecordUpdate to extract the account data from $data (e.g.
$data['account'] or top-level keys used in the form), set them on the $record
(the User model) and persist before returning (use $record->fill(...) and
$record->save() or $record->update(...)), while keeping the existing calls to
UpsertProfile::handle($profile, $dto) and ToggleAvailability::handle($profile,
$available, $startAvailability).
- Around line 107-114: The loop in EditUser.php that builds $links from
$repeaterData can silently overwrite entries when the same platform appears
twice; before assigning $links[$key] = (string) $handle check if $key already
exists and, if so, raise a validation error (e.g. throw
Illuminate\Validation\ValidationException or
ValidationException::withMessages([...]) for the social links field) or
otherwise mark the record invalid so the user gets feedback; reference the loop
variables $repeaterData, $platform, $handle, $links and the SocialPlatform enum
to locate and update the logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: he4rt/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 448c6372-355b-4fb3-81ef-ab5fb4a2771a
📒 Files selected for processing (7)
app-modules/panel-admin/src/Filament/Resources/Users/Pages/CreateUser.phpapp-modules/panel-admin/src/Filament/Resources/Users/Pages/EditUser.phpapp-modules/panel-admin/src/Filament/Resources/Users/Pages/ListUsers.phpapp-modules/panel-admin/src/Filament/Resources/Users/Schemas/UserForm.phpapp-modules/panel-admin/src/Filament/Resources/Users/UserResource.phpapp-modules/panel-admin/src/PanelAdminServiceProvider.phpapp-modules/panel-admin/tests/Feature/Users/UserResourceTest.php
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app-modules/panel-admin/src/Filament/Resources/Users/Pages/EditUser.php`:
- Around line 78-81: The PHPStan errors are caused by using the generic Model
type for $record while accessing User-specific properties (name/email) in
EditUser::mutateFormDataUsing; fix by importing App\Models\User and narrowing
the type: either change the method param to User $record or add a docblock like
`@param` User $record (or add an inline assertion /** `@var` User $record */ or
assert($record instanceof User) before using $record) so accesses to
$record->name and $record->email are recognized as valid.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Pro
Run ID: f7470b8d-8533-49f0-974e-70b3f0caba71
📒 Files selected for processing (2)
app-modules/panel-admin/src/Filament/Resources/Users/Pages/EditUser.phpapp-modules/panel-admin/src/Filament/Resources/Users/UserResource.php
🚧 Files skipped from review as they are similar to previous changes (1)
- app-modules/panel-admin/src/Filament/Resources/Users/UserResource.php
Closes #256
Contexto
Parte da PRD #250 — Módulo Profile Fase 1.
O admin precisa visualizar e editar o perfil de qualquer membro para fins de moderação. Em vez de criar um ProfileResource separado, foi adicionada uma tab "Profile" dentro do UserResource existente.
O que foi feito
UserResourceno Admin panel com páginasListUsers,CreateUsereEditUserUserFormcom as seções:UpsertProfileeToggleAvailabilityfirstOrCreateUserResourceregistrado noPanelAdminServiceProviderTestes
admin sees profile tab on user resourceprofile tab loads member dataadmin can edit member biovalidates bio max lengthtoggle availability shows start availability fieldChecklist
Description
Adds a "Profile" tab to the Admin UserResource so admins can view/edit tenant-scoped member profiles (personal, professional, social links, availability). Implements List/Create/Edit user pages, a tabbed UserForm schema with conditional availability, and save handlers that call UpsertProfile and ToggleAvailability, creating missing profiles on-the-fly.
References
#250— Módulo Profile Fase 1#256— feat(panel-admin): profile tab on UserResourceDependencies & Requirements
Contributor Summary
Changes Summary