Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
arduinomaster22 committed Jan 9, 2025
1 parent 50df9cb commit d6e03f9
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 36 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ return [
'resources' => [
'mail' => \App\Filament\Resources\MailResource::class,
'event' => \App\Filament\Resources\EventResource::class,
'suppressions' => \App\Filament\Resources\SuppressionResource::class
],
];
```
Expand Down
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"php": "^8.1",
"filament/filament": "^3.0",
"spatie/laravel-package-tools": "^1.15.0",
"vormkracht10/laravel-mails": "^1.0"
"vormkracht10/laravel-mails": "dev-feature/suppressions-list"
},
"require-dev": {
"laravel/pint": "^1.0",
Expand Down Expand Up @@ -74,5 +74,11 @@
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
"prefer-stable": true,
"repositories": {
"laravel-mails": {
"type": "path",
"url": "/var/www/laravel-mails"
}
}
}
2 changes: 2 additions & 0 deletions config/filament-mails.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

use Vormkracht10\FilamentMails\Resources\EventResource;
use Vormkracht10\FilamentMails\Resources\MailResource;
use Vormkracht10\FilamentMails\Resources\SuppressionResource;

return [
'resources' => [
'mail' => MailResource::class,
'event' => EventResource::class,
'suppressions' => SuppressionResource::class
],
];
1 change: 1 addition & 0 deletions src/FilamentMailsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function register(Panel $panel): void
->resources([
config('filament-mails.resources.mail'),
config('filament-mails.resources.event'),
config('filament-mails.resources.suppressions'),
]);
}

Expand Down
10 changes: 5 additions & 5 deletions src/Resources/EventResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static function infolist(Infolist $infolist): Infolist
TextEntry::make('type')
->label(__('Type'))
->badge()
->color(fn (EventType $state): string => match ($state) {
->color(fn(EventType $state): string => match ($state) {
EventType::DELIVERED => 'success',
EventType::CLICKED => 'clicked',
EventType::OPENED => 'info',
Expand Down Expand Up @@ -121,7 +121,7 @@ public static function infolist(Infolist $infolist): Infolist
->default(__('Unknown'))
->label(__('User Agent'))
->limit(50)
->tooltip(fn ($state) => $state),
->tooltip(fn($state) => $state),
]),
]),
Section::make(__('Location'))
Expand Down Expand Up @@ -150,7 +150,7 @@ public static function infolist(Infolist $infolist): Infolist
->default(__('Unknown'))
->label(__('Link'))
->limit(50)
->url(fn ($state) => $state)
->url(fn($state) => $state)
->openUrlInNewTab(),
TextEntry::make('tag')
->default(__('Unknown'))
Expand Down Expand Up @@ -199,7 +199,7 @@ public static function table(Table $table): Table
->label(__('Type'))
->sortable()
->badge()
->color(fn (EventType $state): string => match ($state) {
->color(fn(EventType $state): string => match ($state) {
EventType::DELIVERED => 'success',
EventType::CLICKED => 'clicked',
EventType::OPENED => 'info',
Expand All @@ -220,7 +220,7 @@ public static function table(Table $table): Table
->label(__('Occurred At'))
->dateTime('d-m-Y H:i')
->since()
->tooltip(fn (MailEvent $record) => $record->occurred_at->format('d-m-Y H:i'))
->tooltip(fn(MailEvent $record) => $record->occurred_at->format('d-m-Y H:i'))
->sortable()
->searchable(),
])
Expand Down
43 changes: 26 additions & 17 deletions src/Resources/SuppressionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace Vormkracht10\FilamentMails\Resources;

use Filament\Infolists\Infolist;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Vormkracht10\FilamentMails\Resources\SuppressionResource\Pages\ListSuppressions;
use Vormkracht10\FilamentMails\Resources\SuppressionResource\Pages\ViewSuppression;
use Vormkracht10\Mails\Enums\EventType;
Expand Down Expand Up @@ -55,50 +57,57 @@ public static function getNavigationIcon(): string
return 'heroicon-o-no-symbol';
}

public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->where('type', EventType::HARD_BOUNCED)
->whereNull('unsuppressed_at')
->orWhere('unsuppressed_at', '')
->latest('occurred_at')
->orderBy('occurred_at', 'desc');
}

public static function table(Table $table): Table
{
return $table
->recordAction('view')
->recordUrl(null)
->defaultSort('created_at', 'desc')
->defaultSort('occurred_at', 'desc')
->columns([
Tables\Columns\TextColumn::make('mail.to')
->label(__('Email address'))
->formatStateUsing(fn (MailEvent $record) => key($record->mail->to))
->formatStateUsing(fn(MailEvent $record) => key($record->mail->to))
->searchable(['to']),

Tables\Columns\TextColumn::make('occurred_at')
->badge()
->label(__('Suppressed At'))
->dateTime('d-m-Y H:i')
->since()
->tooltip(fn (MailEvent $record) => $record->occurred_at->format('d-m-Y H:i'))
->tooltip(fn(MailEvent $record) => $record->occurred_at->format('d-m-Y H:i'))
->sortable()
->searchable(),
])
->modifyQueryUsing(fn ($query) => $query->where('type', EventType::HARD_BOUNCED))
->filters([
//
])
->actions([
Tables\Actions\Action::make('unsupress')
->action(function (MailEvent $record) {
$record->unsuppressed_at = now();
$record->save();
}),

Tables\Actions\ViewAction::make()
->url(null)
->modal()
->slideOver()
->label(__('View'))
->hiddenLabel()
->tooltip(__('View')),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
->tooltip(__('View'))
->infolist(fn(Infolist $infolist) => EventResource::infolist($infolist)),
]);
}

public static function getPages(): array
{
return [
'index' => ListSuppressions::route('/'),
'view' => ViewSuppression::route('/{record}/view'),
'index' => ListSuppressions::route('/')
];
}
}
11 changes: 0 additions & 11 deletions src/Resources/SuppressionResource/Pages/ViewSuppression.php

This file was deleted.

0 comments on commit d6e03f9

Please sign in to comment.