Skip to content

Commit

Permalink
Configure Jetstream classes in providers and separate panels into Adm…
Browse files Browse the repository at this point in the history
…in and App
  • Loading branch information
curtisdelicata committed Jun 28, 2024
1 parent 1ec5426 commit ae04e6a
Show file tree
Hide file tree
Showing 30 changed files with 1 addition and 55 deletions.
File renamed without changes.
56 changes: 1 addition & 55 deletions app/Providers/Filament/AdminPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Providers\Filament;

use App\Filament\Admin\Pages;
use App\Filament\Admin\Pages\EditProfile;
use App\Http\Middleware\TeamsPermission;
use App\Listeners\CreatePersonalTeam;
use App\Listeners\SwitchTeam;
Expand Down Expand Up @@ -43,26 +42,16 @@ public function panel(Panel $panel): Panel
->id('admin')
->path('admin')
->login([AuthenticatedSessionController::class, 'create'])
->registration([RegisteredUserController::class, 'create'])
->passwordReset()
->emailVerification()
->viteTheme('resources/css/Filament/Admin/theme.css')
->colors([
'primary' => Color::Gray,
])
->userMenuItems([
MenuItem::make()
->label('Profile')
->icon('heroicon-o-user-circle')
->url(fn () => $this->shouldRegisterMenuItem()
? url(EditProfile::getUrl())
: url($panel->getPath())),
])
->discoverResources(in: app_path('Filament/Admin/Resources'), for: 'App\\Filament\\Admin\\Resources')
->discoverPages(in: app_path('Filament/Admin/Pages'), for: 'App\\Filament\\Admin\\Pages')
->pages([
FilamentPage\Dashboard::class,
Pages\EditProfile::class,
Filament\Page\Dashboard::class,
])
->discoverWidgets(in: app_path('Filament/Admin/Widgets/Home'), for: 'App\\Filament\\Admin\\Widgets\\Home')
->widgets([
Expand All @@ -82,39 +71,11 @@ public function panel(Panel $panel): Panel
])
->authMiddleware([
Authenticate::class,
TeamsPermission::class,
])
->plugins([
\BezhanSalleh\FilamentShield\FilamentShieldPlugin::make()
]);

if (Features::hasApiFeatures()) {
$panel->userMenuItems([
MenuItem::make()
->label('API Tokens')
->icon('heroicon-o-key')
->url(fn () => $this->shouldRegisterMenuItem()
? url(Pages\ApiTokenManagerPage::getUrl())
: url($panel->getPath())),
]);
}

if (Features::hasTeamFeatures()) {
$panel
->tenant(Team::class, ownershipRelationship: 'team')
->tenantRegistration(Pages\CreateTeam::class)
->tenantProfile(Pages\EditTeam::class)
->userMenuItems([
MenuItem::make()
->label('Team Settings')
->icon('heroicon-o-cog-6-tooth')
->url(fn () => $this->shouldRegisterMenuItem()
? url(Pages\EditTeam::getUrl())
: url($panel->getPath())),
]);
}

return $panel;
}

public function boot()
Expand All @@ -129,21 +90,6 @@ public function boot()
*/
Jetstream::$registersRoutes = false;

/**
* Listen and create personal team for new accounts.
*/
Event::listen(
Registered::class,
CreatePersonalTeam::class,
);

/**
* Listen and switch team if tenant was changed.
*/
Event::listen(
TenantSet::class,
SwitchTeam::class,
);
}

public function shouldRegisterMenuItem(): bool
Expand Down

0 comments on commit ae04e6a

Please sign in to comment.