diff --git a/resources/views/filament/components/brand.blade.php b/resources/views/filament/components/brand.blade.php new file mode 100644 index 0000000..513bed6 --- /dev/null +++ b/resources/views/filament/components/brand.blade.php @@ -0,0 +1,15 @@ +@php + use Eclipse\Core\Services\Registry; + use Filament\Facades\Filament; + + $appName = Registry::getSite()->name ?? config('app.name'); + $hasSpaMode = Filament::getCurrentPanel()->hasSpaMode(); + + $dashboardUrl = '/' . trim(Filament::getCurrentPanel()->getPath(), '/'); +@endphp + + + + \ No newline at end of file diff --git a/resources/views/filament/components/my-settings.blade.php b/resources/views/filament/components/my-settings.blade.php new file mode 100644 index 0000000..7805951 --- /dev/null +++ b/resources/views/filament/components/my-settings.blade.php @@ -0,0 +1,17 @@ +@php + use Eclipse\Core\Filament\Pages\ManageUserSettings; + use Filament\Facades\Filament; + + $navigationIcon = ManageUserSettings::getNavigationIcon(); + $navigationLabel = ManageUserSettings::getNavigationLabel(); + + $hasSpaMode = Filament::getCurrentPanel()->hasSpaMode(); +@endphp + +
+ + + {{ __($navigationLabel) }} + +
diff --git a/resources/views/filament/components/tenant-menu.blade.php b/resources/views/filament/components/tenant-menu.blade.php new file mode 100644 index 0000000..2df3b0f --- /dev/null +++ b/resources/views/filament/components/tenant-menu.blade.php @@ -0,0 +1,33 @@ +@php + $currentTenant = filament()->getTenant(); + $currentTenantName = filament()->getTenantName($currentTenant); + + $canSwitchTenants = count( + $tenants = array_filter( + filament()->getUserTenants(filament()->auth()->user()), + fn(\Illuminate\Database\Eloquent\Model $tenant): bool => !$tenant->is($currentTenant), + ), + ); +@endphp + + + + + + @if ($canSwitchTenants) + + @foreach ($tenants as $tenant) + + {{ filament()->getTenantName($tenant) }} + + @endforeach + + @endif + + diff --git a/src/EclipseServiceProvider.php b/src/EclipseServiceProvider.php index 1570b56..ffeb8a8 100644 --- a/src/EclipseServiceProvider.php +++ b/src/EclipseServiceProvider.php @@ -59,6 +59,7 @@ public function configurePackage(SpatiePackage|Package $package): void 'telescope', 'themes', ]) + ->hasViews() ->hasSettings() ->discoversMigrations() ->runsMigrations() diff --git a/src/Filament/Pages/Dashboard.php b/src/Filament/Pages/Dashboard.php new file mode 100644 index 0000000..370ec88 --- /dev/null +++ b/src/Filament/Pages/Dashboard.php @@ -0,0 +1,10 @@ +default() ->id('admin') @@ -71,7 +75,9 @@ public function panel(Panel $panel): Panel 'gray' => Color::Slate, ]) ->topNavigation() - ->brandName(fn () => Registry::getSite()->name) + ->brandLogo( + fn (): View => view('eclipse::filament.components.brand') + ) ->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources') ->discoverResources(in: $package_src.'Filament/Resources', for: 'Eclipse\\Core\\Filament\\Resources') ->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages') @@ -79,7 +85,7 @@ public function panel(Panel $panel): Panel ->discoverClusters(in: app_path('Filament/Clusters'), for: 'App\\Filament\\Clusters') ->discoverClusters(in: $package_src.'Filament/Clusters', for: 'Eclipse\\Core\\Filament\\Clusters') ->pages([ - Pages\Dashboard::class, + Dashboard::class, ]) ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets') ->globalSearch(GlobalSearchProvider::class) @@ -95,7 +101,8 @@ public function panel(Panel $panel): Panel SyncShieldTenant::class, SetTheme::class, ], isPersistent: true) - ->tenantMenu(config('eclipse.multi_site', false)) + // ->tenantMenu(config('eclipse.multi_site', false)) + ->tenantMenu(false) ->widgets([ Widgets\AccountWidget::class, Widgets\FilamentInfoWidget::class, @@ -156,16 +163,28 @@ public function panel(Panel $panel): Panel ->hidden(fn (): bool => ! config('log-viewer.enabled', false) || ! auth()->user()->hasRole('super_admin')), ]) ->databaseNotifications() - ->unsavedChangesAlerts(); + ->unsavedChangesAlerts() + ->renderHook( + PanelsRenderHook::USER_MENU_PROFILE_AFTER, + fn () => view('eclipse::filament.components.my-settings') + ); + + if ($hasTenantMenu) { + $panel->renderHook( + PanelsRenderHook::GLOBAL_SEARCH_END, + fn () => view('eclipse::filament.components.tenant-menu') + ); + } // If the Pro version of the Spotlight plugin is installed, use that, otherwise use the free version if (class_exists(\pxlrbt\FilamentSpotlightPro\SpotlightPlugin::class)) { /** @noinspection PhpFullyQualifiedNameUsageInspection */ - $panel->plugin(\pxlrbt\FilamentSpotlightPro\SpotlightPlugin::make() - ->registerItems([ - \pxlrbt\FilamentSpotlightPro\SpotlightProviders\RegisterResources::make(), - ]) - ->hotkeys(['¸']) + $panel->plugin( + \pxlrbt\FilamentSpotlightPro\SpotlightPlugin::make() + ->registerItems([ + \pxlrbt\FilamentSpotlightPro\SpotlightProviders\RegisterResources::make(), + ]) + ->hotkeys(['¸']) ); } else { $panel->plugin(SpotlightPlugin::make());