From 7577e65ed55bd4e5a529653275646fd922323d56 Mon Sep 17 00:00:00 2001 From: Patrick Boivin Date: Wed, 24 Apr 2024 10:09:42 -0400 Subject: [PATCH] enh: Support ListPreviewAction with relation managers --- src/Support/Page.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Support/Page.php b/src/Support/Page.php index 687bf4c..edf1dc5 100644 --- a/src/Support/Page.php +++ b/src/Support/Page.php @@ -2,34 +2,36 @@ namespace Pboivin\FilamentPeek\Support; -use Filament\Pages\Page as FilamentPage; +use Livewire\Component; use Pboivin\FilamentPeek\Exceptions\PreviewModalException; class Page { - public static function supportsPreviewModal(FilamentPage $page): bool + public static function supportsPreviewModal(Component $page): bool { return method_exists($page, 'openPreviewModal'); } - public static function ensurePreviewModalSupport(FilamentPage $page): void + public static function ensurePreviewModalSupport(Component $page): void { if (! static::supportsPreviewModal($page)) { - throw new PreviewModalException('Page class is missing the `HasPreviewModal` trait.'); + $basename = class_basename($page); + throw new PreviewModalException("`{$basename}` class is missing the `HasPreviewModal` trait."); } } - public static function supportsBuilderPreview(FilamentPage $page): bool + public static function supportsBuilderPreview(Component $page): bool { return static::supportsPreviewModal($page) && method_exists($page, 'openPreviewModalForBuidler'); } - public static function ensureBuilderPreviewSupport(FilamentPage $page): void + public static function ensureBuilderPreviewSupport(Component $page): void { static::ensurePreviewModalSupport($page); if (! static::supportsBuilderPreview($page)) { - throw new PreviewModalException('Page class is missing the `HasBuilderPreview` trait.'); + $basename = class_basename($page); + throw new PreviewModalException("`{$basename}` class is missing the `HasBuilderPreview` trait."); } } }