Skip to content

Commit

Permalink
Merge pull request #129 from pboivin/enh/list-preview-relation-manager
Browse files Browse the repository at this point in the history
enh: Support ListPreviewAction with relation managers
  • Loading branch information
pboivin authored Apr 24, 2024
2 parents 02e6864 + 7577e65 commit edf6c2e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Support/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}
}

0 comments on commit edf6c2e

Please sign in to comment.