Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
markvaneijk committed Sep 6, 2024
2 parents 1a510f6 + 17605b1 commit 059bff4
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.6.0
uses: dependabot/fetch-metadata@v2.2.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

Expand Down
1 change: 1 addition & 0 deletions src/Controllers/MailDownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class MailDownloadController extends Controller
{
public function __invoke(Request $request)
{
/** @var MailAttachment $attachment */
$attachment = MailAttachment::find($request->attachment);

$file = Storage::disk($attachment->disk)->get($attachment->uuid);
Expand Down
1 change: 1 addition & 0 deletions src/Controllers/MailPreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class MailPreviewController extends Controller
{
public function __invoke(Request $request)
{
/** @var Mail $mail */
$mail = Mail::find($request->mail);

return response($mail->html);
Expand Down
14 changes: 10 additions & 4 deletions src/Resources/EventResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public static function getLabel(): ?string
return __('Events');
}

public static function getPluralModelLabel(): string
{
return __('Events');
}

public static function getNavigationIcon(): string
{
return 'heroicon-o-calendar';
Expand Down Expand Up @@ -75,7 +80,6 @@ public static function infolist(Infolist $infolist): Infolist
WebhookEventType::OPEN => 'success',
WebhookEventType::BOUNCE => 'danger',
WebhookEventType::COMPLAINT => 'danger',
default => 'gray',
})
->formatStateUsing(function (WebhookEventType $state) {
return ucfirst($state->value);
Expand Down Expand Up @@ -195,21 +199,23 @@ public static function table(Table $table): Table
WebhookEventType::OPEN => 'success',
WebhookEventType::BOUNCE => 'danger',
WebhookEventType::COMPLAINT => 'danger',
default => 'gray',
})
->formatStateUsing(function (WebhookEventType $state) {
return ucfirst($state->value);
})
->searchable(),
Tables\Columns\TextColumn::make('mail.subject')
->url(fn (MailEvent $record) => route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.view', $record->mail))
->url(fn (MailEvent $record) => route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.view', [
'record' => $record->mail,
'tenant' => filament()->getTenant()?->id,

Check failure on line 210 in src/Resources/EventResource.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property Illuminate\Database\Eloquent\Model::$id.
]))
->label(__('Subject'))
->searchable(['subject', 'payload']),
Tables\Columns\TextColumn::make('occurred_at')
->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
20 changes: 14 additions & 6 deletions src/Resources/MailResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
use Illuminate\View\View;
use Vormkracht10\FilamentMails\Models\Mail;
use Vormkracht10\FilamentMails\Resources\MailResource\Pages\ListMails;
use Vormkracht10\Mails\Actions\ResendMail;
use Vormkracht10\Mails\Enums\WebhookEventType;
use Vormkracht10\Mails\Jobs\ResendMailJob;
use Vormkracht10\Mails\Models\MailEvent;

class MailResource extends Resource
Expand Down Expand Up @@ -149,20 +149,25 @@ public static function infolist(Infolist $infolist): Infolist
TextEntry::make('type')
->label(__('Type'))
->badge()
->url(fn (MailEvent $record) => route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.events.view', $record))
->url(fn (MailEvent $record) => route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.events.view', [
'record' => $record,
'tenant' => filament()->getTenant()?->id,

Check failure on line 154 in src/Resources/MailResource.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property Illuminate\Database\Eloquent\Model::$id.
]))
->color(fn (WebhookEventType $state): string => match ($state) {
WebhookEventType::DELIVERY => 'success',
WebhookEventType::CLICK => 'clicked',
WebhookEventType::OPEN => 'success',
WebhookEventType::BOUNCE => 'danger',
WebhookEventType::COMPLAINT => 'danger',
default => 'gray',
})
->formatStateUsing(function (WebhookEventType $state) {
return ucfirst($state->value);
}),
TextEntry::make('occurred_at')
->url(fn (MailEvent $record) => route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.events.view', $record))
->url(fn (MailEvent $record) => route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.events.view', [
'record' => $record,
'tenant' => filament()->getTenant()?->id,

Check failure on line 169 in src/Resources/MailResource.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property Illuminate\Database\Eloquent\Model::$id.
]))
->since()
->dateTimeTooltip('d-m-Y H:i')
->label(__('Occurred At')),
Expand Down Expand Up @@ -341,8 +346,11 @@ public static function table(Table $table): Table
];
})
->action(function (Mail $record, array $data) {
$to = explode(',', $data['to']);
$cc = explode(',', $data['cc']);
$bcc = explode(',', $data['bcc']);

ResendMailJob::dispatch($record, $to, $cc, $bcc);
(new ResendMail)->handle($record, $to, $cc, $bcc);

Notification::make()
->title(__('Mail will be resent in the background'))
Expand All @@ -364,7 +372,7 @@ public static function table(Table $table): Table
$to = json_decode($record->to, true) ?? [];
$cc = json_decode($record->cc, true) ?? [];
$bcc = json_decode($record->bcc, true) ?? [];
ResendMailJob::dispatch($record, $to, $cc, $bcc);
(new ResendMail)->handle($record, $to, $cc, $bcc);
}

Notification::make()
Expand Down
10 changes: 8 additions & 2 deletions src/Widgets/MailStatsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ protected function getStats(): array
->label(__('Opened'))
->description($openedMails . ' ' . __('of') . ' ' . $mailCount . ' ' . __('emails'))
->color('success')
->url(route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.index', ['activeTab' => 'opened']));
->url(route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.index', [
'activeTab' => 'opened',
'tenant' => filament()->getTenant()?->id,

Check failure on line 37 in src/Widgets/MailStatsWidget.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property Illuminate\Database\Eloquent\Model::$id.
]));

$widgets[] = Stat::make(__('Clicked'), number_format(($clickedMails / $mailCount) * 100, 1) . '%')
->label(__('Clicked'))
Expand All @@ -43,7 +46,10 @@ protected function getStats(): array
->label(__('Bounced'))
->description($bouncedMails . ' ' . __('of') . ' ' . $mailCount . ' ' . __('emails'))
->color('danger')
->url(route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.index', ['activeTab' => 'bounced']));
->url(route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.index', [
'activeTab' => 'bounced',
'tenant' => filament()->getTenant()?->id,

Check failure on line 51 in src/Widgets/MailStatsWidget.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property Illuminate\Database\Eloquent\Model::$id.
]));

return $widgets;
}
Expand Down

0 comments on commit 059bff4

Please sign in to comment.