mirror of
https://github.com/pelican-dev/panel.git
synced 2025-11-03 07:36:51 +01:00
feat: Add mixed navigation type with admin-configurable defaults (#1850)
This commit is contained in:
parent
0214b127e4
commit
605fcbe61a
@ -18,7 +18,7 @@ enum CustomizationKey: string
|
|||||||
self::ConsoleFont => 'monospace',
|
self::ConsoleFont => 'monospace',
|
||||||
self::ConsoleFontSize => 14,
|
self::ConsoleFontSize => 14,
|
||||||
self::ConsoleGraphPeriod => 30,
|
self::ConsoleGraphPeriod => 30,
|
||||||
self::TopNavigation => false,
|
self::TopNavigation => config('panel.filament.default-navigation', 'sidebar'),
|
||||||
self::DashboardLayout => 'grid',
|
self::DashboardLayout => 'grid',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -203,6 +203,15 @@ class Settings extends Page implements HasSchemas
|
|||||||
])
|
])
|
||||||
->stateCast(new BooleanStateCast(false, true))
|
->stateCast(new BooleanStateCast(false, true))
|
||||||
->default(env('PANEL_USE_BINARY_PREFIX', config('panel.use_binary_prefix'))),
|
->default(env('PANEL_USE_BINARY_PREFIX', config('panel.use_binary_prefix'))),
|
||||||
|
ToggleButtons::make('FILAMENT_DEFAULT_NAVIGATION')
|
||||||
|
->label(trans('admin/setting.general.default_navigation'))
|
||||||
|
->inline()
|
||||||
|
->options([
|
||||||
|
'sidebar' => trans('admin/setting.general.sidebar'),
|
||||||
|
'topbar' => trans('admin/setting.general.topbar'),
|
||||||
|
'mixed' => trans('admin/setting.general.mixed'),
|
||||||
|
])
|
||||||
|
->default(env('FILAMENT_DEFAULT_NAVIGATION', config('panel.filament.default-navigation'))),
|
||||||
ToggleButtons::make('APP_2FA_REQUIRED')
|
ToggleButtons::make('APP_2FA_REQUIRED')
|
||||||
->label(trans('admin/setting.general.2fa_requirement'))
|
->label(trans('admin/setting.general.2fa_requirement'))
|
||||||
->inline()
|
->inline()
|
||||||
|
|||||||
@ -34,7 +34,6 @@ use Filament\Schemas\Components\Actions;
|
|||||||
use Filament\Schemas\Components\Grid;
|
use Filament\Schemas\Components\Grid;
|
||||||
use Filament\Schemas\Components\Group;
|
use Filament\Schemas\Components\Group;
|
||||||
use Filament\Schemas\Components\Section;
|
use Filament\Schemas\Components\Section;
|
||||||
use Filament\Schemas\Components\StateCasts\BooleanStateCast;
|
|
||||||
use Filament\Schemas\Components\Tabs;
|
use Filament\Schemas\Components\Tabs;
|
||||||
use Filament\Schemas\Components\Tabs\Tab;
|
use Filament\Schemas\Components\Tabs\Tab;
|
||||||
use Filament\Schemas\Components\Utilities\Get;
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
@ -440,10 +439,10 @@ class EditProfile extends BaseEditProfile
|
|||||||
->label(trans('profile.navigation'))
|
->label(trans('profile.navigation'))
|
||||||
->inline()
|
->inline()
|
||||||
->options([
|
->options([
|
||||||
1 => trans('profile.top'),
|
'sidebar' => trans('profile.sidebar'),
|
||||||
0 => trans('profile.side'),
|
'topbar' => trans('profile.topbar'),
|
||||||
])
|
'mixed' => trans('profile.mixed'),
|
||||||
->stateCast(new BooleanStateCast(false, true)),
|
]),
|
||||||
]),
|
]),
|
||||||
Section::make(trans('profile.console'))
|
Section::make(trans('profile.console'))
|
||||||
->collapsible()
|
->collapsible()
|
||||||
@ -583,7 +582,14 @@ class EditProfile extends BaseEditProfile
|
|||||||
$data['console_rows'] = (int) $this->getUser()->getCustomization(CustomizationKey::ConsoleRows);
|
$data['console_rows'] = (int) $this->getUser()->getCustomization(CustomizationKey::ConsoleRows);
|
||||||
$data['console_graph_period'] = (int) $this->getUser()->getCustomization(CustomizationKey::ConsoleGraphPeriod);
|
$data['console_graph_period'] = (int) $this->getUser()->getCustomization(CustomizationKey::ConsoleGraphPeriod);
|
||||||
$data['dashboard_layout'] = $this->getUser()->getCustomization(CustomizationKey::DashboardLayout);
|
$data['dashboard_layout'] = $this->getUser()->getCustomization(CustomizationKey::DashboardLayout);
|
||||||
$data['top_navigation'] = (bool) $this->getUser()->getCustomization(CustomizationKey::TopNavigation);
|
|
||||||
|
// Handle migration from boolean to string navigation types
|
||||||
|
$topNavigation = $this->getUser()->getCustomization(CustomizationKey::TopNavigation);
|
||||||
|
if (is_bool($topNavigation)) {
|
||||||
|
$data['top_navigation'] = $topNavigation ? 'topbar' : 'sidebar';
|
||||||
|
} else {
|
||||||
|
$data['top_navigation'] = $topNavigation;
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,8 +34,16 @@ abstract class PanelProvider extends BasePanelProvider
|
|||||||
->brandLogo(config('app.logo'))
|
->brandLogo(config('app.logo'))
|
||||||
->brandLogoHeight('2rem')
|
->brandLogoHeight('2rem')
|
||||||
->favicon(config('app.favicon', '/pelican.ico'))
|
->favicon(config('app.favicon', '/pelican.ico'))
|
||||||
->topNavigation(fn () => user()?->getCustomization(CustomizationKey::TopNavigation))
|
->topNavigation(function () {
|
||||||
->topbar(fn () => user()?->getCustomization(CustomizationKey::TopNavigation))
|
$navigationType = user()?->getCustomization(CustomizationKey::TopNavigation);
|
||||||
|
|
||||||
|
return $navigationType === 'topbar' || $navigationType === true;
|
||||||
|
})
|
||||||
|
->topbar(function () {
|
||||||
|
$navigationType = user()?->getCustomization(CustomizationKey::TopNavigation);
|
||||||
|
|
||||||
|
return $navigationType === 'topbar' || $navigationType === 'mixed' || $navigationType === true;
|
||||||
|
})
|
||||||
->maxContentWidth(config('panel.filament.display-width', 'screen-2xl'))
|
->maxContentWidth(config('panel.filament.display-width', 'screen-2xl'))
|
||||||
->profile(EditProfile::class, false)
|
->profile(EditProfile::class, false)
|
||||||
->userMenuItems([
|
->userMenuItems([
|
||||||
|
|||||||
@ -53,6 +53,7 @@ return [
|
|||||||
'display-width' => env('FILAMENT_WIDTH', 'screen-2xl'),
|
'display-width' => env('FILAMENT_WIDTH', 'screen-2xl'),
|
||||||
'avatar-provider' => env('FILAMENT_AVATAR_PROVIDER', 'gravatar'),
|
'avatar-provider' => env('FILAMENT_AVATAR_PROVIDER', 'gravatar'),
|
||||||
'uploadable-avatars' => env('FILAMENT_UPLOADABLE_AVATARS', false),
|
'uploadable-avatars' => env('FILAMENT_UPLOADABLE_AVATARS', false),
|
||||||
|
'default-navigation' => env('FILAMENT_DEFAULT_NAVIGATION', 'sidebar'),
|
||||||
],
|
],
|
||||||
|
|
||||||
'use_binary_prefix' => env('PANEL_USE_BINARY_PREFIX', true),
|
'use_binary_prefix' => env('PANEL_USE_BINARY_PREFIX', true),
|
||||||
|
|||||||
@ -20,8 +20,10 @@ return [
|
|||||||
'app_favicon_help' => 'Favicon should be placed in the public folder located in the root panel directory.',
|
'app_favicon_help' => 'Favicon should be placed in the public folder located in the root panel directory.',
|
||||||
'debug_mode' => 'Debug Mode',
|
'debug_mode' => 'Debug Mode',
|
||||||
'navigation' => 'Navigation',
|
'navigation' => 'Navigation',
|
||||||
|
'default_navigation' => 'Default Navigation Type',
|
||||||
'sidebar' => 'Sidebar',
|
'sidebar' => 'Sidebar',
|
||||||
'topbar' => 'Topbar',
|
'topbar' => 'Topbar',
|
||||||
|
'mixed' => 'Mixed',
|
||||||
'unit_prefix' => 'Unit Prefix',
|
'unit_prefix' => 'Unit Prefix',
|
||||||
'decimal_prefix' => 'Decimal Prefix (MB/GB)',
|
'decimal_prefix' => 'Decimal Prefix (MB/GB)',
|
||||||
'binary_prefix' => 'Binary Prefix (MiB/GiB)',
|
'binary_prefix' => 'Binary Prefix (MiB/GiB)',
|
||||||
|
|||||||
@ -61,8 +61,9 @@ return [
|
|||||||
'graph_period' => 'Graph Period',
|
'graph_period' => 'Graph Period',
|
||||||
'graph_period_helper' => 'The amount of data points, seconds, shown on the console graphs.',
|
'graph_period_helper' => 'The amount of data points, seconds, shown on the console graphs.',
|
||||||
'navigation' => 'Navigation Type',
|
'navigation' => 'Navigation Type',
|
||||||
'top' => 'Topbar',
|
'sidebar' => 'Sidebar',
|
||||||
'side' => 'Sidebar',
|
'topbar' => 'Topbar',
|
||||||
|
'mixed' => 'Mixed',
|
||||||
'no_oauth' => 'No Accounts Linked',
|
'no_oauth' => 'No Accounts Linked',
|
||||||
'no_api_keys' => 'No API Keys',
|
'no_api_keys' => 'No API Keys',
|
||||||
'no_ssh_keys' => 'No SSH Keys',
|
'no_ssh_keys' => 'No SSH Keys',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user