Skip to content

Commit

Permalink
Merge pull request #429 from awcodes/fix/dont-load-on-auth-pages
Browse files Browse the repository at this point in the history
Fix: Don't load panel on auth pages
  • Loading branch information
awcodes authored Jan 31, 2024
2 parents 6aba446 + f07b835 commit 5b6cf2c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
15 changes: 13 additions & 2 deletions src/CuratorPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

use Closure;
use Filament\Contracts\Plugin;
use Filament\Facades\Filament;
use Filament\Panel;
use Filament\Support\Concerns\EvaluatesClosures;
use Filament\Support\Facades\FilamentView;
use Illuminate\Contracts\View\View;

class CuratorPlugin implements Plugin
{
Expand Down Expand Up @@ -36,19 +39,27 @@ public function register(Panel $panel): void
->resources([
$this->getResource(),
]);

if (! is_panel_auth_route()) {
$panel
->renderHook(
'panels::body.end',
fn (): View => view('curator::components.modals.modal')
);
}
}

public function boot(Panel $panel): void
{
//

}

public static function make(): static
{
return app(static::class);
}

public static function get(): static
public static function get(): Plugin
{
return filament(app(static::class)->getId());
}
Expand Down
7 changes: 0 additions & 7 deletions src/CuratorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,5 @@ public function packageBooted(): void
AlpineComponent::make('curation', __DIR__ . '/../resources/dist/curation.js'),
Css::make('curator', __DIR__ . '/../resources/dist/curator.css')->loadedOnRequest(),
], 'awcodes/curator');

if (Filament::getCurrentPanel() && Filament::getCurrentPanel()->hasPlugin('awcodes/curator')) {
FilamentView::registerRenderHook(
'panels::body.end',
fn (): View => view('curator::components.modals.modal')
);
}
}
}
17 changes: 17 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use Awcodes\Curator\Models\Media;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;

if (!function_exists('is_media_resizable')) {
function is_media_resizable(string $ext): bool
Expand Down Expand Up @@ -36,3 +39,17 @@ function get_media_items(array|Media|int $ids): Collection|array
return [];
}
}

if(!function_exists('is_panel_auth_route')) {
function is_panel_auth_route(): bool
{
$authRoutes = [
'/login',
'/password-reset',
'/register',
'/email-verification',
];

return Str::of(Request::path())->contains($authRoutes);
}
}

0 comments on commit 5b6cf2c

Please sign in to comment.