Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions resources/views/filament/components/brand.blade.php
Original file line number Diff line number Diff line change
@@ -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

<a @if ($hasSpaMode) wire:navigate @endif href="{{ $dashboardUrl }}">
<div class="fi-logo flex text-xl font-bold leading-5 tracking-tight text-gray-950 dark:text-white">
{{ $appName }}
</div>
</a>
17 changes: 17 additions & 0 deletions resources/views/filament/components/my-settings.blade.php
Original file line number Diff line number Diff line change
@@ -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

<div class="fi-dropdown-list p-1">
<a @if ($hasSpaMode) wire:navigate @endif href="{{ ManageUserSettings::getUrl() }}"
class="fi-dropdown-list-item flex w-full items-center gap-2 whitespace-nowrap rounded-md p-2 text-sm transition-colors duration-75 outline-none disabled:pointer-events-none disabled:opacity-70 hover:bg-gray-50 focus-visible:bg-gray-50 dark:hover:bg-white/5 dark:focus-visible:bg-white/5 fi-dropdown-list-item-color-gray fi-color-gray">
<x-filament::icon class="fi-dropdown-list-item-icon h-5 w-5 text-gray-400 dark:text-gray-500" icon="{{ $navigationIcon }}" />
{{ __($navigationLabel) }}
</a>
</div>
33 changes: 33 additions & 0 deletions resources/views/filament/components/tenant-menu.blade.php
Original file line number Diff line number Diff line change
@@ -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
<x-filament::dropdown placement="bottom-start" size teleport>
<x-slot name="trigger">
<button type="button"
class="fi-tenant-menu-trigger group flex w-full items-center justify-center gap-x-3 rounded-lg p-2 text-sm font-medium outline-none transition duration-75 hover:bg-gray-100 focus-visible:bg-gray-100 dark:hover:bg-white/5 dark:focus-visible:bg-white/5">
<x-filament-panels::avatar.tenant :tenant="$currentTenant" class="shrink-0" />

<x-filament::icon icon="heroicon-m-chevron-down" alias="panels::tenant-menu.toggle-button"
class="ms-auto h-5 w-5 shrink-0 text-gray-400 transition duration-75 group-hover:text-gray-500 group-focus-visible:text-gray-500 dark:text-gray-500 dark:group-hover:text-gray-400 dark:group-focus-visible:text-gray-400" />
</button>
</x-slot>

@if ($canSwitchTenants)
<x-filament::dropdown.list>
@foreach ($tenants as $tenant)
<x-filament::dropdown.list.item :href="route('filament.admin.pages.dashboard', ['tenant' => $tenant])" :image="filament()->getTenantAvatarUrl($tenant)" tag="a">
{{ filament()->getTenantName($tenant) }}
</x-filament::dropdown.list.item>
@endforeach
</x-filament::dropdown.list>
@endif

</x-filament::dropdown>
1 change: 1 addition & 0 deletions src/EclipseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function configurePackage(SpatiePackage|Package $package): void
'telescope',
'themes',
])
->hasViews()
->hasSettings()
->discoversMigrations()
->runsMigrations()
Expand Down
10 changes: 10 additions & 0 deletions src/Filament/Pages/Dashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Eclipse\Core\Filament\Pages;

use Filament\Pages\Dashboard as BasePage;

class Dashboard extends BasePage
{
protected static bool $shouldRegisterNavigation = false;
}
2 changes: 2 additions & 0 deletions src/Filament/Pages/ManageUserSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ManageUserSettings extends SettingsPage

protected static string $settings = UserSettings::class;

protected static bool $shouldRegisterNavigation = false;

public function form(Form $form): Form
{
return $form
Expand Down
39 changes: 29 additions & 10 deletions src/Providers/AdminPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use BezhanSalleh\FilamentShield\Middleware\SyncShieldTenant;
use DutchCodingCompany\FilamentDeveloperLogins\FilamentDeveloperLoginsPlugin;
use Eclipse\Common\Providers\GlobalSearchProvider;
use Eclipse\Core\Filament\Pages\Dashboard;
use Eclipse\Core\Filament\Pages\EditProfile;
use Eclipse\Core\Filament\Pages\Tools\HealthCheckResults;
use Eclipse\Core\Models\Locale;
Expand All @@ -20,7 +21,6 @@
use Filament\Navigation\NavigationGroup;
use Filament\Navigation\NavigationItem;
use Filament\Notifications\Livewire\Notifications;
use Filament\Pages;
use Filament\Panel;
use Filament\PanelProvider;
use Filament\SpatieLaravelTranslatablePlugin;
Expand All @@ -29,6 +29,7 @@
use Filament\Support\Enums\Platform;
use Filament\Support\Enums\VerticalAlignment;
use Filament\Support\Facades\FilamentView;
use Filament\View\PanelsRenderHook;
use Filament\Widgets;
use Hasnayeen\Themes\Http\Middleware\SetTheme;
use Hasnayeen\Themes\ThemesPlugin;
Expand All @@ -41,6 +42,7 @@
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Schema;
use Illuminate\View\Middleware\ShareErrorsFromSession;
use Illuminate\View\View;
use pxlrbt\FilamentEnvironmentIndicator\EnvironmentIndicatorPlugin;
use pxlrbt\FilamentSpotlight\SpotlightPlugin;
use ShuvroRoy\FilamentSpatieLaravelHealth\FilamentSpatieLaravelHealthPlugin;
Expand All @@ -58,6 +60,8 @@ public function panel(Panel $panel): Panel
$localeIds = [config('app.locale', 'en')];
}

$hasTenantMenu = config('eclipse.multi_site', false);

$panel
->default()
->id('admin')
Expand All @@ -71,15 +75,17 @@ 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')
->discoverPages(in: $package_src.'Filament/Pages', for: 'Eclipse\\Core\\Filament\\Pages')
->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)
Expand All @@ -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,
Expand Down Expand Up @@ -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());
Expand Down
Loading