Skip to content

Admin crud logging - #2571

Open
lancepioch wants to merge 1 commit into
mainfrom
w6/admin-crud-logging
Open

Admin crud logging#2571
lancepioch wants to merge 1 commit into
mainfrom
w6/admin-crud-logging

Conversation

@lancepioch

@lancepioch lancepioch commented Sep 12, 2026

Copy link
Copy Markdown
Member

First half of admin CRUD audit logging, built on the existing activity-log system. Adds LogsAdminActivity (event keys aligned with role permission models, identifying-fields-only payloads for create/delete, redacted old-to-new diffs for updates), BaseAdminCreateRecord/BaseAdminEditRecord with after-hooks, and LoggedDeleteAction, then reparents Nodes, Eggs, Mounts, Users, and Servers onto them. Secrets (password, *token*, *_secret, *_key, ...) are masked at write time; no-op saves log nothing; every event attaches the record as subject since the admin panel isn't tenant-scoped.

EditServer's custom delete/force-delete actions log inline, EditNode/EditServer afterSave now call parent, and Mount joins the enforced morph map. English labels added to lang/en/activity.php; other locales sync via the translation workflow.

Covered by trait unit tests plus create/update/delete smoke tests per resource. Pairs with the viewer in #2569.
mount update event with old-to-new diff

Adds LogsAdminActivity (event key map, identifying fields, redacted diffs),
BaseAdminCreateRecord/BaseAdminEditRecord after-hooks, and LoggedDeleteAction,
then reparents the five blocker resources onto them. EditServer's custom
delete actions log inline; EditNode/EditServer afterSave now call parent.
Mount joins the enforced morph map so it can be an activity subject.
@lancepioch
lancepioch added this pull request to stack #2573 September 12, 2026 19:22
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 556fc9cd-ae67-452d-ace6-b8f122d334b0

📥 Commits

Reviewing files that changed from the base of the PR and between fdb519e and 53d63e0.

📒 Files selected for processing (18)
  • app/Filament/Admin/Pages/BaseAdminCreateRecord.php
  • app/Filament/Admin/Pages/BaseAdminEditRecord.php
  • app/Filament/Admin/Resources/Eggs/Pages/CreateEgg.php
  • app/Filament/Admin/Resources/Eggs/Pages/EditEgg.php
  • app/Filament/Admin/Resources/Mounts/Pages/CreateMount.php
  • app/Filament/Admin/Resources/Mounts/Pages/EditMount.php
  • app/Filament/Admin/Resources/Nodes/Pages/CreateNode.php
  • app/Filament/Admin/Resources/Nodes/Pages/EditNode.php
  • app/Filament/Admin/Resources/Servers/Pages/CreateServer.php
  • app/Filament/Admin/Resources/Servers/Pages/EditServer.php
  • app/Filament/Admin/Resources/Users/Pages/CreateUser.php
  • app/Filament/Admin/Resources/Users/Pages/EditUser.php
  • app/Filament/Components/Actions/LoggedDeleteAction.php
  • app/Providers/AppServiceProvider.php
  • app/Traits/Filament/LogsAdminActivity.php
  • lang/en/activity.php
  • tests/Filament/Admin/AdminActivityLoggingTest.php
  • tests/Unit/Traits/LogsAdminActivityTest.php

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The change adds shared admin activity logging for create, update, and delete operations. Admin resource pages adopt common base classes and logged delete actions. Activity translations, polymorphic mapping, and unit and integration tests are added.

Changes

Admin activity logging

Layer / File(s) Summary
Activity logging contracts
app/Traits/Filament/LogsAdminActivity.php, app/Filament/Admin/Pages/BaseAdminCreateRecord.php, app/Filament/Admin/Pages/BaseAdminEditRecord.php, app/Filament/Components/Actions/LoggedDeleteAction.php
Shared logging handles activity keys, identifying attributes, cast-aware diffs, and secret redaction. Create, update, and delete lifecycle hooks write activity events.
Admin page integration
app/Filament/Admin/Resources/*/Pages/*, app/Providers/AppServiceProvider.php
Admin create and edit pages use the shared base classes. Delete actions use logged actions or explicit logging. The mount morph-map alias is registered.
Activity translations and validation
lang/en/activity.php, tests/Filament/Admin/AdminActivityLoggingTest.php, tests/Unit/Traits/LogsAdminActivityTest.php
Translations cover resource activity events. Tests verify lifecycle logging, diffs, redaction, no-op updates, and deletion behavior.

Sequence Diagram(s)

sequenceDiagram
  participant AdminPage
  participant LogsAdminActivity
  participant Activity
  AdminPage->>LogsAdminActivity: logAdminActivity(action, record)
  LogsAdminActivity->>LogsAdminActivity: identify and redact properties
  LogsAdminActivity->>Activity: record event with subject and properties
Loading

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 53d63

Admin create, update, and delete activity logging paths are ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 18 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: adding admin CRUD logging across the listed resources. It is concise and related to the pull request.
Description check ✅ Passed The description directly explains the logging trait, lifecycle hooks, delete action, resource changes, redaction behavior, translations, and test coverage.
  • Fix all pre-merge checks with AI

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.

@lancepioch lancepioch changed the title w6/admin crud logging Admin crud logging Sep 12, 2026
@lancepioch lancepioch self-assigned this Sep 12, 2026
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.

1 participant