-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Database Notifications - Customizable "Mark All as Read" Action #14157
Open
leandrocfe
wants to merge
8
commits into
filamentphp:4.x
Choose a base branch
from
leandrocfe:db-notifications-mark-all-as-read
base: 4.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6d278e3
docs
leandrocfe a554061
These changes introduce the databaseNotificationsMarkAllAsReadAction(…
leandrocfe 364d1c8
Mark All as Read action within the database notifications modal.
leandrocfe ccbf56d
chore: fix code style
leandrocfe e89eae3
rename action
leandrocfe 122dc14
chore: fix code style
leandrocfe d71eb2d
render the action in the view
leandrocfe 5dca5ed
chore: fix code style
leandrocfe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 3 additions & 9 deletions
12
packages/notifications/resources/views/components/database/modal/actions.blade.php
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
namespace Filament\Notifications\Livewire; | ||
|
||
use Carbon\CarbonInterface; | ||
use Filament\Actions\Action; | ||
use Filament\Notifications\Notification; | ||
use Illuminate\Contracts\Auth\Authenticatable; | ||
use Illuminate\Contracts\Pagination\Paginator; | ||
|
@@ -28,6 +29,8 @@ class DatabaseNotifications extends Component | |
|
||
public static ?string $authGuard = null; | ||
|
||
public static ?Action $markAllNotificationsAsReadAction = null; | ||
|
||
#[On('databaseNotificationsSent')] | ||
public function refresh(): void {} | ||
|
||
|
@@ -113,6 +116,19 @@ public function getTrigger(): ?View | |
return view($viewPath); | ||
} | ||
|
||
public function getMarkAllNotificationsAsReadAction(): Action | ||
{ | ||
if ($action = static::$markAllNotificationsAsReadAction) { | ||
return $action; | ||
} | ||
|
||
Comment on lines
+127
to
+130
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this |
||
return Action::make('markAllNotificationsAsRead') | ||
->link() | ||
->label(__('filament-notifications::database.modal.actions.mark_all_as_read.label')) | ||
->extraAttributes(['tabindex' => '-1']) | ||
->action('markAllNotificationsAsRead'); | ||
} | ||
|
||
public function getUser(): Model | Authenticatable | null | ||
{ | ||
return auth(static::$authGuard)->user(); | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of storing the action, please add
HasActions
andInteractsWithActions
to this component, and then renamegetMarkAllNotificationsAsReadAction
tomarkAllNotificationsAsReadAction
. Then you can use$this->markAllNotificationsAsReadAction
to renderThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You won't need this line anymore