Render comment edit/delete as Filament actions & allow custom actions#107
Open
ItsMalikJones wants to merge 2 commits into
Open
Render comment edit/delete as Filament actions & allow custom actions#107ItsMalikJones wants to merge 2 commits into
ItsMalikJones wants to merge 2 commits into
Conversation
…tions (#25) Converts the hand-rolled edit icon-button and delete modal in comment.blade.php into real Filament Action objects on the Comment Livewire component: - editAction()/deleteAction() defined via a HasCommentActions concern; the delete action uses requiresConfirmation() instead of a bespoke modal. - Visibility is gated by the existing update/delete policy checks. - The Comment component now implements HasActions/HasSchemas. Adds an extension point so host apps can attach their own actions (e.g. an "Activity Logs" action) via Config::registerCommentActions(). Custom actions are cached through Filament's cacheTraitActions() hook so modal-opening actions stay resolvable across requests. The legacy delete() and edit() Livewire methods are retained for backward compatibility. Adds an `edit` translation key across all locales.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #25
Summary
This PR replaces the hand-rolled comment controls (an edit icon-button wired to
wire:click="edit"and a bespoke delete confirmation modal) with first-class FilamentActionobjects on theCommentLivewire component. It also adds an extension point so host applications can attach their own actions to each comment.Changes
HasCommentActionsconcern providingeditAction()anddeleteAction(). The delete action uses Filament'srequiresConfirmation()instead of a custom modal. Visibility is gated by the existingupdate/deletepolicy checks, preserving current permission behavior.Commentcomponent now implementsHasActions/HasSchemas, pulling inInteractsWithActions,InteractsWithSchemas, andResolvesDynamicLivewireProperties.Config::registerCommentActions(fn (Comment $comment) => ...), returning a singleActionor an array. These render after the built-in edit/delete controls. Registered actions are cached through Filament'scacheTraitActions()hook (cacheHasCommentActions()) so that modal-opening actions stay resolvable across Livewire requests.delete()andedit()Livewire methods are retained; the new actions delegate to them.edittranslation key across all bundled locales (ar, en, es, fr, nl, ro).Usage
Tests
tests/Filament/CommentCustomActionsTest.phpcovering custom action registration, rendering, and the modal-caching behavior.tests/Livewire/CommentTest.phpto exercise the new edit/delete actions and their permission gating.tests/TestCase.phpflushes registered comment actions between tests viaConfig::flushCommentActions().