Skip to content

feat(panel-admin): profile tab on UserResource #256#293

Open
Hadzab wants to merge 5 commits into
4.xfrom
feat/256-admin-panel-profile-tab
Open

feat(panel-admin): profile tab on UserResource #256#293
Hadzab wants to merge 5 commits into
4.xfrom
feat/256-admin-panel-profile-tab

Conversation

@Hadzab
Copy link
Copy Markdown

@Hadzab Hadzab commented May 28, 2026

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

  • Criado UserResource no Admin panel com páginas ListUsers, CreateUser e EditUser
  • Adicionada tab "Profile" no UserForm com as seções:
    • Dados Pessoais (nickname, birthdate)
    • Dados Profissionais (headline, seniority_level, years_experience, about)
    • Links Sociais (social_links via Repeater)
    • Disponibilidade (available_for_proposals + start_availability condicional)
  • Save handler chama as domain actions UpsertProfile e ToggleAvailability
  • Profile inexistente é criado on-the-fly via firstOrCreate
  • UserResource registrado no PanelAdminServiceProvider

Testes

  • admin sees profile tab on user resource
  • profile tab loads member data
  • admin can edit member bio
  • validates bio max length
  • toggle availability shows start availability field

Checklist

  • Código vive na camada do Admin panel
  • Pint passou sem erros
  • Testes passando

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

Dependencies & Requirements

  • No new external dependencies.
  • No environment variables or config changes required.
  • Conforms to existing Filament/admin architecture and coding standards; Pint and tests pass.

Contributor Summary

Contributor Lines Added Lines Removed Files Changed
Hadzab 585 0 7

Changes Summary

File Path Change Description
app-modules/panel-admin/src/Filament/Resources/Users/UserResource.php New Filament Resource for User: model binding, form wiring, table columns, pages and navigation metadata
app-modules/panel-admin/src/Filament/Resources/Users/Schemas/UserForm.php New form schema with Tabs: Account and Profile (personal, professional, social links repeater, availability with conditional start field)
app-modules/panel-admin/src/Filament/Resources/Users/Pages/CreateUser.php Filament page for creating users
app-modules/panel-admin/src/Filament/Resources/Users/Pages/EditUser.php Filament page for editing users; hydrates tenant-scoped profile, maps social links, validates duplicates, calls UpsertProfile and ToggleAvailability on save
app-modules/panel-admin/src/Filament/Resources/Users/Pages/ListUsers.php Filament page for listing users with Create action
app-modules/panel-admin/src/PanelAdminServiceProvider.php Registers UserResource in admin panel resources/navigation
app-modules/panel-admin/tests/Feature/Users/UserResourceTest.php Feature tests: profile tab visibility, data loading, editing, validation, and availability toggle behavior

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Warning

Review limit reached

@Hadzab, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro

Run ID: ca1f8cbb-18df-4a96-a055-8191c49104a7

📥 Commits

Reviewing files that changed from the base of the PR and between 43935a9 and 704642d.

📒 Files selected for processing (1)
  • app-modules/panel-admin/src/Filament/Resources/Users/UserResource.php
📝 Walkthrough

Walkthrough

This 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

  • he4rt/heartdevs.com#206: Main PR extends the panel-admin tenant-aware module by modifying PanelAdminServiceProvider to register the new UserResource, building directly on the scaffolding/config/provider added in PR #206.

Suggested reviewers

  • Clintonrocha98
  • thalesmengue
  • gvieira18
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(panel-admin): profile tab on UserResource #256' accurately summarizes the main change—adding a Profile tab to the UserResource in the admin panel.
Linked Issues check ✅ Passed All core objectives from issue #256 are met: Profile tab added to UserResource, form schema includes all specified fields, domain actions (UpsertProfile, ToggleAvailability) are called, profile is created on-the-fly if missing, validations match User panel, and Livewire tests cover required scenarios.
Out of Scope Changes check ✅ Passed All changes are in-scope: UserResource files, related pages, form schema, service provider registration, and tests are all necessary for the Profile tab feature within the Admin panel layer.

✏️ 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
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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between c5c45e0 and 1978b4f.

📒 Files selected for processing (7)
  • app-modules/panel-admin/src/Filament/Resources/Users/Pages/CreateUser.php
  • app-modules/panel-admin/src/Filament/Resources/Users/Pages/EditUser.php
  • app-modules/panel-admin/src/Filament/Resources/Users/Pages/ListUsers.php
  • app-modules/panel-admin/src/Filament/Resources/Users/Schemas/UserForm.php
  • app-modules/panel-admin/src/Filament/Resources/Users/UserResource.php
  • app-modules/panel-admin/src/PanelAdminServiceProvider.php
  • app-modules/panel-admin/tests/Feature/Users/UserResourceTest.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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3167810 and 4fdf956.

📒 Files selected for processing (2)
  • app-modules/panel-admin/src/Filament/Resources/Users/Pages/EditUser.php
  • app-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

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.

feat(panel-admin): profile tab on UserResource

1 participant