From b884acf558c7436160a45f3db257ccc2fecf8a17 Mon Sep 17 00:00:00 2001 From: O2theC <93496386+O2theC@users.noreply.github.com> Date: Wed, 20 May 2026 16:00:47 -0400 Subject: [PATCH 1/5] draft of new settings ui stuff --- app/Filament/Admin/Pages/Settings.php | 287 ++++++++++++++++++++------ 1 file changed, 227 insertions(+), 60 deletions(-) diff --git a/app/Filament/Admin/Pages/Settings.php b/app/Filament/Admin/Pages/Settings.php index 424b4a7957..89d27a40ac 100644 --- a/app/Filament/Admin/Pages/Settings.php +++ b/app/Filament/Admin/Pages/Settings.php @@ -32,7 +32,9 @@ use Filament\Schemas\Components\Actions; use Filament\Schemas\Components\Component; use Filament\Schemas\Components\Group; +use Filament\Schemas\Components\Fieldset; use Filament\Schemas\Components\Section; +use Filament\Schemas\Components\Text; use Filament\Schemas\Components\StateCasts\BooleanStateCast; use Filament\Schemas\Components\Tabs; use Filament\Schemas\Components\Tabs\Tab; @@ -110,7 +112,7 @@ protected function getFormSchema(): array Tabs::make('Tabs') ->columns() ->persistTabInQueryString() - ->disabled(fn () => !user()?->can('update settings')) + ->disabled(fn() => !user()?->can('update settings')) ->tabs($this->getTabs()), ]; } @@ -234,8 +236,8 @@ private function generalSettings(): array 1 => trans('admin/setting.general.admins_only'), 2 => trans('admin/setting.general.all_users'), ]) - ->formatStateUsing(fn ($state): int => (int) $state) - ->afterStateUpdated(fn ($state, Set $set) => $set('APP_2FA_REQUIRED', (int) $state)) + ->formatStateUsing(fn($state): int => (int) $state) + ->afterStateUpdated(fn($state, Set $set) => $set('APP_2FA_REQUIRED', (int) $state)) ->default(env('APP_2FA_REQUIRED', config('panel.auth.2fa_required'))), Select::make('FILAMENT_WIDTH') ->label(trans('admin/setting.general.display_width')) @@ -254,12 +256,12 @@ private function generalSettings(): array ->color('danger') ->icon(TablerIcon::Trash) ->requiresConfirmation() - ->authorize(fn () => user()?->can('update settings')) - ->action(fn (Set $set) => $set('TRUSTED_PROXIES', [])), + ->authorize(fn() => user()?->can('update settings')) + ->action(fn(Set $set) => $set('TRUSTED_PROXIES', [])), Action::make('hint_cloudflare') ->label(trans('admin/setting.general.set_to_cf')) ->icon(TablerIcon::BrandCloudflare) - ->authorize(fn () => user()?->can('update settings')) + ->authorize(fn() => user()?->can('update settings')) ->action(function (Factory $client, Set $set) { $ips = collect(); @@ -301,7 +303,7 @@ private function captchaSettings(): array $formFields[] = Section::make($schema->getName()) ->columns(5) ->icon($schema->getIcon() ?? TablerIcon::Shield) - ->collapsed(fn () => !$schema->isEnabled()) + ->collapsed(fn() => !$schema->isEnabled()) ->collapsible() ->schema([ Hidden::make("CAPTCHA_{$id}_ENABLED") @@ -309,20 +311,20 @@ private function captchaSettings(): array ->default(env("CAPTCHA_{$id}_ENABLED")), Actions::make([ Action::make("disable_captcha_$id") - ->visible(fn (Get $get) => $get("CAPTCHA_{$id}_ENABLED")) - ->disabled(fn () => !user()?->can('update settings')) + ->visible(fn(Get $get) => $get("CAPTCHA_{$id}_ENABLED")) + ->disabled(fn() => !user()?->can('update settings')) ->label(trans('admin/setting.captcha.disable')) ->color('danger') - ->action(fn (Set $set) => $set("CAPTCHA_{$id}_ENABLED", false)), + ->action(fn(Set $set) => $set("CAPTCHA_{$id}_ENABLED", false)), Action::make("enable_captcha_$id") - ->visible(fn (Get $get) => !$get("CAPTCHA_{$id}_ENABLED")) - ->disabled(fn () => !user()?->can('update settings')) + ->visible(fn(Get $get) => !$get("CAPTCHA_{$id}_ENABLED")) + ->disabled(fn() => !user()?->can('update settings')) ->label(trans('admin/setting.captcha.enable')) ->color('success') - ->action(fn (Set $set) => $set("CAPTCHA_{$id}_ENABLED", true)), + ->action(fn(Set $set) => $set("CAPTCHA_{$id}_ENABLED", true)), ])->columnSpan(1), Group::make($schema->getSettingsForm()) - ->visible(fn (Get $get) => $get("CAPTCHA_{$id}_ENABLED")) + ->visible(fn(Get $get) => $get("CAPTCHA_{$id}_ENABLED")) ->columns(4) ->columnSpan(4), ]); @@ -357,8 +359,8 @@ private function mailSettings(): array Action::make('hint_test') ->label(trans('admin/setting.mail.test_mail')) ->icon(TablerIcon::Send) - ->hidden(fn (Get $get) => $get('MAIL_MAILER') === 'log') - ->authorize(fn () => user()?->can('update settings')) + ->hidden(fn(Get $get) => $get('MAIL_MAILER') === 'log') + ->authorize(fn() => user()?->can('update settings')) ->action(function (Get $get) { // Store original mail configuration $originalConfig = [ @@ -427,7 +429,7 @@ private function mailSettings(): array Section::make(trans('admin/setting.mail.smtp.smtp_title')) ->columns() ->columnSpanFull() - ->visible(fn (Get $get) => $get('MAIL_MAILER') === 'smtp') + ->visible(fn(Get $get) => $get('MAIL_MAILER') === 'smtp') ->schema([ TextInput::make('MAIL_HOST') ->label(trans('admin/setting.mail.smtp.host')) @@ -464,7 +466,7 @@ private function mailSettings(): array Section::make(trans('admin/setting.mail.mailgun.mailgun_title')) ->columns() ->columnSpanFull() - ->visible(fn (Get $get) => $get('MAIL_MAILER') === 'mailgun') + ->visible(fn(Get $get) => $get('MAIL_MAILER') === 'mailgun') ->schema([ TextInput::make('MAILGUN_DOMAIN') ->label(trans('admin/setting.mail.mailgun.domain')) @@ -521,7 +523,7 @@ private function backupSettings(): array ]), Section::make(trans('admin/setting.backup.s3.s3_title')) ->columns() - ->visible(fn (Get $get) => $get('APP_BACKUP_DRIVER') === Backup::ADAPTER_AWS_S3) + ->visible(fn(Get $get) => $get('APP_BACKUP_DRIVER') === Backup::ADAPTER_AWS_S3) ->schema([ TextInput::make('AWS_DEFAULT_REGION') ->label(trans('admin/setting.backup.s3.default_region')) @@ -582,7 +584,7 @@ private function oauthSettings(): array $formFields[] = Section::make($schema->getName()) ->columns(5) ->icon($icon ?? TablerIcon::BrandOauth) - ->collapsed(fn () => !$schema->isEnabled()) + ->collapsed(fn() => !$schema->isEnabled()) ->collapsible() ->schema([ Hidden::make($key) @@ -590,14 +592,14 @@ private function oauthSettings(): array ->default($schema->isEnabled()), Actions::make([ Action::make('disable_oauth_' . $schema->getId()) - ->visible(fn (Get $get) => $get($key)) - ->disabled(fn () => !user()?->can('update settings')) + ->visible(fn(Get $get) => $get($key)) + ->disabled(fn() => !user()?->can('update settings')) ->label(trans('admin/setting.oauth.disable')) ->color('danger') - ->action(fn (Set $set) => $set($key, false)), + ->action(fn(Set $set) => $set($key, false)), Action::make('enable_oauth_' . $schema->getId()) - ->visible(fn (Get $get) => !$get($key)) - ->disabled(fn () => !user()?->can('update settings')) + ->visible(fn(Get $get) => !$get($key)) + ->disabled(fn() => !user()?->can('update settings')) ->label(trans('admin/setting.oauth.enable')) ->color('success') ->steps($schema->getSetupSteps()) @@ -615,7 +617,7 @@ private function oauthSettings(): array }), ])->columnSpan(1), Group::make($schema->getSettingsForm()) - ->visible(fn (Get $get) => $get($key)) + ->visible(fn(Get $get) => $get($key)) ->columns(4) ->columnSpan(4), ]); @@ -657,7 +659,7 @@ private function miscSettings(): array ->offColor('danger') ->live() ->columnSpanFull() - ->visible(fn (Get $get) => $get('PANEL_CLIENT_ALLOCATIONS_ENABLED')) + ->visible(fn(Get $get) => $get('PANEL_CLIENT_ALLOCATIONS_ENABLED')) ->stateCast(new BooleanStateCast(false)) ->default(env('PANEL_CLIENT_ALLOCATIONS_CREATE_NEW', config('panel.client_features.allocations.create_new'))), TextInput::make('PANEL_CLIENT_ALLOCATIONS_RANGE_START') @@ -666,7 +668,7 @@ private function miscSettings(): array ->numeric() ->minValue(1024) ->maxValue(65535) - ->visible(fn (Get $get) => $get('PANEL_CLIENT_ALLOCATIONS_ENABLED')) + ->visible(fn(Get $get) => $get('PANEL_CLIENT_ALLOCATIONS_ENABLED')) ->default(env('PANEL_CLIENT_ALLOCATIONS_RANGE_START')), TextInput::make('PANEL_CLIENT_ALLOCATIONS_RANGE_END') ->label(trans('admin/setting.misc.auto_allocation.end')) @@ -674,7 +676,7 @@ private function miscSettings(): array ->numeric() ->minValue(1024) ->maxValue(65535) - ->visible(fn (Get $get) => $get('PANEL_CLIENT_ALLOCATIONS_ENABLED')) + ->visible(fn(Get $get) => $get('PANEL_CLIENT_ALLOCATIONS_ENABLED')) ->default(env('PANEL_CLIENT_ALLOCATIONS_RANGE_END')), ]), Section::make(trans('admin/setting.misc.mail_notifications.title')) @@ -690,8 +692,8 @@ private function miscSettings(): array ->onColor('success') ->offColor('danger') ->live() - ->formatStateUsing(fn ($state): bool => (bool) $state) - ->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_ACCOUNT_CREATED_NOTIFICATION', (bool) $state)) + ->formatStateUsing(fn($state): bool => (bool) $state) + ->afterStateUpdated(fn($state, Set $set) => $set('PANEL_SEND_ACCOUNT_CREATED_NOTIFICATION', (bool) $state)) ->default(env('PANEL_SEND_ACCOUNT_CREATED_NOTIFICATION', config('panel.email.send_account_created_notification'))), Toggle::make('PANEL_SEND_ADDED_TO_SERVER_NOTIFICATION') ->label(trans('admin/setting.misc.mail_notifications.added_to_server')) @@ -700,8 +702,8 @@ private function miscSettings(): array ->onColor('success') ->offColor('danger') ->live() - ->formatStateUsing(fn ($state): bool => (bool) $state) - ->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_ADDED_TO_SERVER_NOTIFICATION', (bool) $state)) + ->formatStateUsing(fn($state): bool => (bool) $state) + ->afterStateUpdated(fn($state, Set $set) => $set('PANEL_SEND_ADDED_TO_SERVER_NOTIFICATION', (bool) $state)) ->default(env('PANEL_SEND_ADDED_TO_SERVER_NOTIFICATION', config('panel.email.send_added_to_server_notification'))), Toggle::make('PANEL_SEND_REMOVED_FROM_SERVER_NOTIFICATION') ->label(trans('admin/setting.misc.mail_notifications.removed_from_server')) @@ -710,8 +712,8 @@ private function miscSettings(): array ->onColor('success') ->offColor('danger') ->live() - ->formatStateUsing(fn ($state): bool => (bool) $state) - ->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_REMOVED_FROM_SERVER_NOTIFICATION', (bool) $state)) + ->formatStateUsing(fn($state): bool => (bool) $state) + ->afterStateUpdated(fn($state, Set $set) => $set('PANEL_SEND_REMOVED_FROM_SERVER_NOTIFICATION', (bool) $state)) ->default(env('PANEL_SEND_REMOVED_FROM_SERVER_NOTIFICATION', config('panel.email.send_removed_from_server_notification'))), Toggle::make('PANEL_SEND_INSTALL_NOTIFICATION') ->label(trans('admin/setting.misc.mail_notifications.server_installed')) @@ -720,8 +722,8 @@ private function miscSettings(): array ->onColor('success') ->offColor('danger') ->live() - ->formatStateUsing(fn ($state): bool => (bool) $state) - ->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_INSTALL_NOTIFICATION', (bool) $state)) + ->formatStateUsing(fn($state): bool => (bool) $state) + ->afterStateUpdated(fn($state, Set $set) => $set('PANEL_SEND_INSTALL_NOTIFICATION', (bool) $state)) ->default(env('PANEL_SEND_INSTALL_NOTIFICATION', config('panel.email.send_install_notification'))), Toggle::make('PANEL_SEND_REINSTALL_NOTIFICATION') ->label(trans('admin/setting.misc.mail_notifications.server_reinstalled')) @@ -730,8 +732,8 @@ private function miscSettings(): array ->onColor('success') ->offColor('danger') ->live() - ->formatStateUsing(fn ($state): bool => (bool) $state) - ->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_REINSTALL_NOTIFICATION', (bool) $state)) + ->formatStateUsing(fn($state): bool => (bool) $state) + ->afterStateUpdated(fn($state, Set $set) => $set('PANEL_SEND_REINSTALL_NOTIFICATION', (bool) $state)) ->default(env('PANEL_SEND_REINSTALL_NOTIFICATION', config('panel.email.send_reinstall_notification'))), Toggle::make('PANEL_SEND_BACKUP_COMPLETED_NOTIFICATION') ->label(trans('admin/setting.misc.mail_notifications.backup_completed')) @@ -740,8 +742,8 @@ private function miscSettings(): array ->onColor('success') ->offColor('danger') ->live() - ->formatStateUsing(fn ($state): bool => (bool) $state) - ->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_BACKUP_COMPLETED_NOTIFICATION', (bool) $state)) + ->formatStateUsing(fn($state): bool => (bool) $state) + ->afterStateUpdated(fn($state, Set $set) => $set('PANEL_SEND_BACKUP_COMPLETED_NOTIFICATION', (bool) $state)) ->default(env('PANEL_SEND_BACKUP_COMPLETED_NOTIFICATION', config('panel.email.send_backup_completed_notification'))), ]), Section::make(trans('admin/setting.misc.connections.title')) @@ -794,24 +796,190 @@ private function miscSettings(): array ]), Section::make(trans('admin/setting.misc.api.title')) ->description(trans('admin/setting.misc.api.helper')) - ->columns() + ->columns(1) ->collapsible() ->collapsed() ->schema([ - TextInput::make('APP_API_CLIENT_RATELIMIT') - ->label(trans('admin/setting.misc.api.client_rate')) - ->required() - ->numeric() - ->minValue(1) - ->suffix(trans('admin/setting.misc.api.rpm')) - ->default(env('APP_API_CLIENT_RATELIMIT', config('http.rate_limit.client'))), - TextInput::make('APP_API_APPLICATION_RATELIMIT') - ->label(trans('admin/setting.misc.api.app_rate')) - ->required() - ->numeric() - ->minValue(1) - ->suffix(trans('admin/setting.misc.api.rpm')) - ->default(env('APP_API_APPLICATION_RATELIMIT', config('http.rate_limit.application'))), + Fieldset::make() + ->label('Client API Ratelimit') + ->schema([ + TextInput::make('APP_API_CLIENT_RATELIMIT') + ->label("Requests Per Period") + ->required() + ->numeric() + ->minValue(1) + ->suffix("Requests")->default(env('APP_API_CLIENT_RATELIMIT', config('http.rate_limit.client'))), + + TextInput::make('APP_API_CLIENT_RATELIMIT_PERIOD') + ->label("Period Length") + ->required() + ->numeric() + ->minValue(1) + ->suffix('Minutes')->default(env('APP_API_CLIENT_RATELIMIT_PERIOD', config('http.rate_limit.client_period'))), + Text::make("Ratelimit is per user, or IP if there is no user") + ]), + Fieldset::make() + ->label('Application API Ratelimit') + ->schema([ + TextInput::make('APP_API_APPLICATION_RATELIMIT') + ->label("Requests Per Period") + ->required() + ->numeric() + ->minValue(1) + ->suffix("Requests")->default(env('APP_API_APPLICATION_RATELIMIT', config('http.rate_limit.application'))), + + TextInput::make('APP_API_APPLICATION_RATELIMIT_PERIOD') + ->label("Period Length") + ->required() + ->numeric() + ->minValue(1) + ->suffix('Minutes')->default(env('APP_API_APPLICATION_RATELIMIT_PERIOD', config('http.rate_limit.application_period'))), + Text::make("Ratelimit is per user, or IP if there is no user") + ]), + Fieldset::make() + ->label('Auth Ratelimit') + ->schema([ + TextInput::make('APP_API_AUTH_RATELIMIT') + ->label("Requests Per Period") + ->required() + ->numeric() + ->minValue(1) + ->suffix("Requests")->default(env('APP_API_AUTH_RATELIMIT', config('http.rate_limit.auth'))), + + TextInput::make('APP_API_AUTH_RATELIMIT_PERIOD') + ->label("Period Length") + ->required() + ->numeric() + ->minValue(1) + ->suffix('Minutes')->default(env('APP_API_AUTH_RATELIMIT_PERIOD', config('http.rate_limit.auth_period'))), + Text::make("Ratelimit is instance wide") + ]), + Fieldset::make() + ->label('Password Reset Ratelimit') + ->schema([ + TextInput::make('APP_API_PASSWORD_RESET_RATELIMIT') + ->label("Requests Per Period") + ->required() + ->numeric() + ->minValue(1) + ->suffix("Requests")->default(env('APP_API_PASSWORD_RESET_RATELIMIT', config('http.rate_limit.password_reset'))), + + TextInput::make('APP_API_PASSWORD_RESET_RATELIMIT_PERIOD') + ->label("Period Length") + ->required() + ->numeric() + ->minValue(1) + ->suffix('Minutes')->default(env('APP_API_PASSWORD_RESET_RATELIMIT_PERIOD', config('http.rate_limit.password_reset_period'))), + Text::make("Ratelimit is per IP") + ]), + Fieldset::make() + ->label('Websocket Ratelimit') + ->schema([ + TextInput::make('APP_API_WEBSOCKET_RATELIMIT') + ->label("Requests Per Period") + ->required() + ->numeric() + ->minValue(1) + ->suffix("Requests")->default(env('APP_API_WEBSOCKET_RATELIMIT', config('http.rate_limit.websocket'))), + + TextInput::make('APP_API_WEBSOCKET_RATELIMIT_PERIOD') + ->label("Period Length") + ->required() + ->numeric() + ->minValue(1) + ->suffix('Minutes')->default(env('APP_API_WEBSOCKET_RATELIMIT_PERIOD', config('http.rate_limit.websocket_period'))), + Text::make("Ratelimit is per server") + ]), + Fieldset::make() + ->label('Backup and Restore Ratelimit') + ->schema([ + TextInput::make('APP_API_BACKUP_RESTORE_RATELIMIT') + ->label("Requests Per Period") + ->required() + ->numeric() + ->minValue(1) + ->suffix("Requests")->default(env('APP_API_BACKUP_RESTORE_RATELIMIT', config('http.rate_limit.backup_restore'))), + + TextInput::make('APP_API_BACKUP_RESTORE_RATELIMIT_PERIOD') + ->label("Period Length") + ->required() + ->numeric() + ->minValue(1) + ->suffix('Minutes')->default(env('APP_API_BACKUP_RESTORE_RATELIMIT_PERIOD', config('http.rate_limit.backup_restore_period'))), + Text::make("Ratelimit is per server") + ]), + Fieldset::make() + ->label('Database Create Ratelimit') + ->schema([ + TextInput::make('APP_API_DATABASE_CREATE_RATELIMIT') + ->label("Requests Per Period") + ->required() + ->numeric() + ->minValue(1) + ->suffix("Requests")->default(env('APP_API_DATABASE_CREATE_RATELIMIT', config('http.rate_limit.database_create'))), + + TextInput::make('APP_API_DATABASE_CREATE_RATELIMIT_PERIOD') + ->label("Period Length") + ->required() + ->numeric() + ->minValue(1) + ->suffix('Minutes')->default(env('APP_API_DATABASE_CREATE_RATELIMIT_PERIOD', config('http.rate_limit.database_create_period'))), + Text::make("Ratelimit is per server") + ]), + Fieldset::make() + ->label('Subuser Create Ratelimit') + ->schema([ + TextInput::make('APP_API_SUBUSER_CREATE_RATELIMIT') + ->label("Requests Per Period") + ->required() + ->numeric() + ->minValue(1) + ->suffix("Requests")->default(env('APP_API_SUBUSER_CREATE_RATELIMIT', config('http.rate_limit.subuser_create'))), + + TextInput::make('APP_API_SUBUSER_CREATE_RATELIMIT_PERIOD') + ->label("Period Length") + ->required() + ->numeric() + ->minValue(1) + ->suffix('Minutes')->default(env('APP_API_SUBUSER_CREATE_RATELIMIT_PERIOD', config('http.rate_limit.subuser_create_period'))), + Text::make("Ratelimit is per server") + ]), + Fieldset::make() + ->label('File Pull Ratelimit') + ->schema([ + TextInput::make('APP_API_FILE_PULL_RATELIMIT') + ->label("Requests Per Period") + ->required() + ->numeric() + ->minValue(1) + ->suffix("Requests")->default(env('APP_API_FILE_PULL_RATELIMIT', config('http.rate_limit.file_pull'))), + + TextInput::make('APP_API_FILE_PULL_RATELIMIT_PERIOD') + ->label("Period Length") + ->required() + ->numeric() + ->minValue(1) + ->suffix('Minutes')->default(env('APP_API_FILE_PULL_RATELIMIT_PERIOD', config('http.rate_limit.file_pull_period'))), + Text::make("Ratelimit is per server") + ]), + Fieldset::make() + ->label('Default Ratelimit') + ->schema([ + TextInput::make('APP_API_DEFAULT_RATELIMIT') + ->label("Requests Per Period") + ->required() + ->numeric() + ->minValue(1) + ->suffix("Requests")->default(env('APP_API_DEFAULT_RATELIMIT', config('http.rate_limit.default'))), + + TextInput::make('APP_API_DEFAULT_RATELIMIT_PERIOD') + ->label("Period Length") + ->required() + ->numeric() + ->minValue(1) + ->suffix('Minutes')->default(env('APP_API_DEFAULT_RATELIMIT_PERIOD', config('http.rate_limit.default_period'))), + Text::make("Ratelimit is per server") + ]), ]), Section::make(trans('admin/setting.misc.server.title')) ->description(trans('admin/setting.misc.server.helper')) @@ -827,8 +995,8 @@ private function miscSettings(): array ->offColor('danger') ->live() ->columnSpan(1) - ->formatStateUsing(fn ($state): bool => (bool) $state) - ->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_EDITABLE_SERVER_DESCRIPTIONS', (bool) $state)) + ->formatStateUsing(fn($state): bool => (bool) $state) + ->afterStateUpdated(fn($state, Set $set) => $set('PANEL_EDITABLE_SERVER_DESCRIPTIONS', (bool) $state)) ->default(env('PANEL_EDITABLE_SERVER_DESCRIPTIONS', config('panel.editable_server_descriptions'))), FileUpload::make('ConsoleFonts') ->hint(trans('admin/setting.misc.server.console_font_hint')) @@ -910,9 +1078,8 @@ protected function getDefaultHeaderActions(): array ->icon(TablerIcon::DeviceFloppy) ->action('save') ->tooltip(trans('filament-panels::resources/pages/edit-record.form.actions.save.label')) - ->authorize(fn () => user()?->can('update settings')) + ->authorize(fn() => user()?->can('update settings')) ->keyBindings(['mod+s']), ]; - } } From b5ec6031b770bb6c49b04822ecf1b86cdf5f68ca Mon Sep 17 00:00:00 2001 From: O2theC <93496386+O2theC@users.noreply.github.com> Date: Wed, 20 May 2026 16:11:12 -0400 Subject: [PATCH 2/5] change " to ' - pint be helpful --- app/Filament/Admin/Pages/Settings.php | 172 +++++++++++++------------- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/app/Filament/Admin/Pages/Settings.php b/app/Filament/Admin/Pages/Settings.php index 89d27a40ac..f9b2ea73d2 100644 --- a/app/Filament/Admin/Pages/Settings.php +++ b/app/Filament/Admin/Pages/Settings.php @@ -31,13 +31,13 @@ use Filament\Pages\Page; use Filament\Schemas\Components\Actions; use Filament\Schemas\Components\Component; -use Filament\Schemas\Components\Group; use Filament\Schemas\Components\Fieldset; +use Filament\Schemas\Components\Group; use Filament\Schemas\Components\Section; -use Filament\Schemas\Components\Text; use Filament\Schemas\Components\StateCasts\BooleanStateCast; use Filament\Schemas\Components\Tabs; use Filament\Schemas\Components\Tabs\Tab; +use Filament\Schemas\Components\Text; use Filament\Schemas\Components\Utilities\Get; use Filament\Schemas\Components\Utilities\Set; use Filament\Schemas\Contracts\HasSchemas; @@ -112,7 +112,7 @@ protected function getFormSchema(): array Tabs::make('Tabs') ->columns() ->persistTabInQueryString() - ->disabled(fn() => !user()?->can('update settings')) + ->disabled(fn () => !user()?->can('update settings')) ->tabs($this->getTabs()), ]; } @@ -236,8 +236,8 @@ private function generalSettings(): array 1 => trans('admin/setting.general.admins_only'), 2 => trans('admin/setting.general.all_users'), ]) - ->formatStateUsing(fn($state): int => (int) $state) - ->afterStateUpdated(fn($state, Set $set) => $set('APP_2FA_REQUIRED', (int) $state)) + ->formatStateUsing(fn ($state): int => (int) $state) + ->afterStateUpdated(fn ($state, Set $set) => $set('APP_2FA_REQUIRED', (int) $state)) ->default(env('APP_2FA_REQUIRED', config('panel.auth.2fa_required'))), Select::make('FILAMENT_WIDTH') ->label(trans('admin/setting.general.display_width')) @@ -256,12 +256,12 @@ private function generalSettings(): array ->color('danger') ->icon(TablerIcon::Trash) ->requiresConfirmation() - ->authorize(fn() => user()?->can('update settings')) - ->action(fn(Set $set) => $set('TRUSTED_PROXIES', [])), + ->authorize(fn () => user()?->can('update settings')) + ->action(fn (Set $set) => $set('TRUSTED_PROXIES', [])), Action::make('hint_cloudflare') ->label(trans('admin/setting.general.set_to_cf')) ->icon(TablerIcon::BrandCloudflare) - ->authorize(fn() => user()?->can('update settings')) + ->authorize(fn () => user()?->can('update settings')) ->action(function (Factory $client, Set $set) { $ips = collect(); @@ -303,7 +303,7 @@ private function captchaSettings(): array $formFields[] = Section::make($schema->getName()) ->columns(5) ->icon($schema->getIcon() ?? TablerIcon::Shield) - ->collapsed(fn() => !$schema->isEnabled()) + ->collapsed(fn () => !$schema->isEnabled()) ->collapsible() ->schema([ Hidden::make("CAPTCHA_{$id}_ENABLED") @@ -311,20 +311,20 @@ private function captchaSettings(): array ->default(env("CAPTCHA_{$id}_ENABLED")), Actions::make([ Action::make("disable_captcha_$id") - ->visible(fn(Get $get) => $get("CAPTCHA_{$id}_ENABLED")) - ->disabled(fn() => !user()?->can('update settings')) + ->visible(fn (Get $get) => $get("CAPTCHA_{$id}_ENABLED")) + ->disabled(fn () => !user()?->can('update settings')) ->label(trans('admin/setting.captcha.disable')) ->color('danger') - ->action(fn(Set $set) => $set("CAPTCHA_{$id}_ENABLED", false)), + ->action(fn (Set $set) => $set("CAPTCHA_{$id}_ENABLED", false)), Action::make("enable_captcha_$id") - ->visible(fn(Get $get) => !$get("CAPTCHA_{$id}_ENABLED")) - ->disabled(fn() => !user()?->can('update settings')) + ->visible(fn (Get $get) => !$get("CAPTCHA_{$id}_ENABLED")) + ->disabled(fn () => !user()?->can('update settings')) ->label(trans('admin/setting.captcha.enable')) ->color('success') - ->action(fn(Set $set) => $set("CAPTCHA_{$id}_ENABLED", true)), + ->action(fn (Set $set) => $set("CAPTCHA_{$id}_ENABLED", true)), ])->columnSpan(1), Group::make($schema->getSettingsForm()) - ->visible(fn(Get $get) => $get("CAPTCHA_{$id}_ENABLED")) + ->visible(fn (Get $get) => $get("CAPTCHA_{$id}_ENABLED")) ->columns(4) ->columnSpan(4), ]); @@ -359,8 +359,8 @@ private function mailSettings(): array Action::make('hint_test') ->label(trans('admin/setting.mail.test_mail')) ->icon(TablerIcon::Send) - ->hidden(fn(Get $get) => $get('MAIL_MAILER') === 'log') - ->authorize(fn() => user()?->can('update settings')) + ->hidden(fn (Get $get) => $get('MAIL_MAILER') === 'log') + ->authorize(fn () => user()?->can('update settings')) ->action(function (Get $get) { // Store original mail configuration $originalConfig = [ @@ -429,7 +429,7 @@ private function mailSettings(): array Section::make(trans('admin/setting.mail.smtp.smtp_title')) ->columns() ->columnSpanFull() - ->visible(fn(Get $get) => $get('MAIL_MAILER') === 'smtp') + ->visible(fn (Get $get) => $get('MAIL_MAILER') === 'smtp') ->schema([ TextInput::make('MAIL_HOST') ->label(trans('admin/setting.mail.smtp.host')) @@ -466,7 +466,7 @@ private function mailSettings(): array Section::make(trans('admin/setting.mail.mailgun.mailgun_title')) ->columns() ->columnSpanFull() - ->visible(fn(Get $get) => $get('MAIL_MAILER') === 'mailgun') + ->visible(fn (Get $get) => $get('MAIL_MAILER') === 'mailgun') ->schema([ TextInput::make('MAILGUN_DOMAIN') ->label(trans('admin/setting.mail.mailgun.domain')) @@ -523,7 +523,7 @@ private function backupSettings(): array ]), Section::make(trans('admin/setting.backup.s3.s3_title')) ->columns() - ->visible(fn(Get $get) => $get('APP_BACKUP_DRIVER') === Backup::ADAPTER_AWS_S3) + ->visible(fn (Get $get) => $get('APP_BACKUP_DRIVER') === Backup::ADAPTER_AWS_S3) ->schema([ TextInput::make('AWS_DEFAULT_REGION') ->label(trans('admin/setting.backup.s3.default_region')) @@ -584,7 +584,7 @@ private function oauthSettings(): array $formFields[] = Section::make($schema->getName()) ->columns(5) ->icon($icon ?? TablerIcon::BrandOauth) - ->collapsed(fn() => !$schema->isEnabled()) + ->collapsed(fn () => !$schema->isEnabled()) ->collapsible() ->schema([ Hidden::make($key) @@ -592,14 +592,14 @@ private function oauthSettings(): array ->default($schema->isEnabled()), Actions::make([ Action::make('disable_oauth_' . $schema->getId()) - ->visible(fn(Get $get) => $get($key)) - ->disabled(fn() => !user()?->can('update settings')) + ->visible(fn (Get $get) => $get($key)) + ->disabled(fn () => !user()?->can('update settings')) ->label(trans('admin/setting.oauth.disable')) ->color('danger') - ->action(fn(Set $set) => $set($key, false)), + ->action(fn (Set $set) => $set($key, false)), Action::make('enable_oauth_' . $schema->getId()) - ->visible(fn(Get $get) => !$get($key)) - ->disabled(fn() => !user()?->can('update settings')) + ->visible(fn (Get $get) => !$get($key)) + ->disabled(fn () => !user()?->can('update settings')) ->label(trans('admin/setting.oauth.enable')) ->color('success') ->steps($schema->getSetupSteps()) @@ -617,7 +617,7 @@ private function oauthSettings(): array }), ])->columnSpan(1), Group::make($schema->getSettingsForm()) - ->visible(fn(Get $get) => $get($key)) + ->visible(fn (Get $get) => $get($key)) ->columns(4) ->columnSpan(4), ]); @@ -659,7 +659,7 @@ private function miscSettings(): array ->offColor('danger') ->live() ->columnSpanFull() - ->visible(fn(Get $get) => $get('PANEL_CLIENT_ALLOCATIONS_ENABLED')) + ->visible(fn (Get $get) => $get('PANEL_CLIENT_ALLOCATIONS_ENABLED')) ->stateCast(new BooleanStateCast(false)) ->default(env('PANEL_CLIENT_ALLOCATIONS_CREATE_NEW', config('panel.client_features.allocations.create_new'))), TextInput::make('PANEL_CLIENT_ALLOCATIONS_RANGE_START') @@ -668,7 +668,7 @@ private function miscSettings(): array ->numeric() ->minValue(1024) ->maxValue(65535) - ->visible(fn(Get $get) => $get('PANEL_CLIENT_ALLOCATIONS_ENABLED')) + ->visible(fn (Get $get) => $get('PANEL_CLIENT_ALLOCATIONS_ENABLED')) ->default(env('PANEL_CLIENT_ALLOCATIONS_RANGE_START')), TextInput::make('PANEL_CLIENT_ALLOCATIONS_RANGE_END') ->label(trans('admin/setting.misc.auto_allocation.end')) @@ -676,7 +676,7 @@ private function miscSettings(): array ->numeric() ->minValue(1024) ->maxValue(65535) - ->visible(fn(Get $get) => $get('PANEL_CLIENT_ALLOCATIONS_ENABLED')) + ->visible(fn (Get $get) => $get('PANEL_CLIENT_ALLOCATIONS_ENABLED')) ->default(env('PANEL_CLIENT_ALLOCATIONS_RANGE_END')), ]), Section::make(trans('admin/setting.misc.mail_notifications.title')) @@ -692,8 +692,8 @@ private function miscSettings(): array ->onColor('success') ->offColor('danger') ->live() - ->formatStateUsing(fn($state): bool => (bool) $state) - ->afterStateUpdated(fn($state, Set $set) => $set('PANEL_SEND_ACCOUNT_CREATED_NOTIFICATION', (bool) $state)) + ->formatStateUsing(fn ($state): bool => (bool) $state) + ->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_ACCOUNT_CREATED_NOTIFICATION', (bool) $state)) ->default(env('PANEL_SEND_ACCOUNT_CREATED_NOTIFICATION', config('panel.email.send_account_created_notification'))), Toggle::make('PANEL_SEND_ADDED_TO_SERVER_NOTIFICATION') ->label(trans('admin/setting.misc.mail_notifications.added_to_server')) @@ -702,8 +702,8 @@ private function miscSettings(): array ->onColor('success') ->offColor('danger') ->live() - ->formatStateUsing(fn($state): bool => (bool) $state) - ->afterStateUpdated(fn($state, Set $set) => $set('PANEL_SEND_ADDED_TO_SERVER_NOTIFICATION', (bool) $state)) + ->formatStateUsing(fn ($state): bool => (bool) $state) + ->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_ADDED_TO_SERVER_NOTIFICATION', (bool) $state)) ->default(env('PANEL_SEND_ADDED_TO_SERVER_NOTIFICATION', config('panel.email.send_added_to_server_notification'))), Toggle::make('PANEL_SEND_REMOVED_FROM_SERVER_NOTIFICATION') ->label(trans('admin/setting.misc.mail_notifications.removed_from_server')) @@ -712,8 +712,8 @@ private function miscSettings(): array ->onColor('success') ->offColor('danger') ->live() - ->formatStateUsing(fn($state): bool => (bool) $state) - ->afterStateUpdated(fn($state, Set $set) => $set('PANEL_SEND_REMOVED_FROM_SERVER_NOTIFICATION', (bool) $state)) + ->formatStateUsing(fn ($state): bool => (bool) $state) + ->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_REMOVED_FROM_SERVER_NOTIFICATION', (bool) $state)) ->default(env('PANEL_SEND_REMOVED_FROM_SERVER_NOTIFICATION', config('panel.email.send_removed_from_server_notification'))), Toggle::make('PANEL_SEND_INSTALL_NOTIFICATION') ->label(trans('admin/setting.misc.mail_notifications.server_installed')) @@ -722,8 +722,8 @@ private function miscSettings(): array ->onColor('success') ->offColor('danger') ->live() - ->formatStateUsing(fn($state): bool => (bool) $state) - ->afterStateUpdated(fn($state, Set $set) => $set('PANEL_SEND_INSTALL_NOTIFICATION', (bool) $state)) + ->formatStateUsing(fn ($state): bool => (bool) $state) + ->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_INSTALL_NOTIFICATION', (bool) $state)) ->default(env('PANEL_SEND_INSTALL_NOTIFICATION', config('panel.email.send_install_notification'))), Toggle::make('PANEL_SEND_REINSTALL_NOTIFICATION') ->label(trans('admin/setting.misc.mail_notifications.server_reinstalled')) @@ -732,8 +732,8 @@ private function miscSettings(): array ->onColor('success') ->offColor('danger') ->live() - ->formatStateUsing(fn($state): bool => (bool) $state) - ->afterStateUpdated(fn($state, Set $set) => $set('PANEL_SEND_REINSTALL_NOTIFICATION', (bool) $state)) + ->formatStateUsing(fn ($state): bool => (bool) $state) + ->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_REINSTALL_NOTIFICATION', (bool) $state)) ->default(env('PANEL_SEND_REINSTALL_NOTIFICATION', config('panel.email.send_reinstall_notification'))), Toggle::make('PANEL_SEND_BACKUP_COMPLETED_NOTIFICATION') ->label(trans('admin/setting.misc.mail_notifications.backup_completed')) @@ -742,8 +742,8 @@ private function miscSettings(): array ->onColor('success') ->offColor('danger') ->live() - ->formatStateUsing(fn($state): bool => (bool) $state) - ->afterStateUpdated(fn($state, Set $set) => $set('PANEL_SEND_BACKUP_COMPLETED_NOTIFICATION', (bool) $state)) + ->formatStateUsing(fn ($state): bool => (bool) $state) + ->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_BACKUP_COMPLETED_NOTIFICATION', (bool) $state)) ->default(env('PANEL_SEND_BACKUP_COMPLETED_NOTIFICATION', config('panel.email.send_backup_completed_notification'))), ]), Section::make(trans('admin/setting.misc.connections.title')) @@ -804,181 +804,181 @@ private function miscSettings(): array ->label('Client API Ratelimit') ->schema([ TextInput::make('APP_API_CLIENT_RATELIMIT') - ->label("Requests Per Period") + ->label('Requests Per Period') ->required() ->numeric() ->minValue(1) - ->suffix("Requests")->default(env('APP_API_CLIENT_RATELIMIT', config('http.rate_limit.client'))), + ->suffix('Requests')->default(env('APP_API_CLIENT_RATELIMIT', config('http.rate_limit.client'))), TextInput::make('APP_API_CLIENT_RATELIMIT_PERIOD') - ->label("Period Length") + ->label('Period Length') ->required() ->numeric() ->minValue(1) ->suffix('Minutes')->default(env('APP_API_CLIENT_RATELIMIT_PERIOD', config('http.rate_limit.client_period'))), - Text::make("Ratelimit is per user, or IP if there is no user") + Text::make('Ratelimit is per user, or IP if there is no user'), ]), Fieldset::make() ->label('Application API Ratelimit') ->schema([ TextInput::make('APP_API_APPLICATION_RATELIMIT') - ->label("Requests Per Period") + ->label('Requests Per Period') ->required() ->numeric() ->minValue(1) - ->suffix("Requests")->default(env('APP_API_APPLICATION_RATELIMIT', config('http.rate_limit.application'))), + ->suffix('Requests')->default(env('APP_API_APPLICATION_RATELIMIT', config('http.rate_limit.application'))), TextInput::make('APP_API_APPLICATION_RATELIMIT_PERIOD') - ->label("Period Length") + ->label('Period Length') ->required() ->numeric() ->minValue(1) ->suffix('Minutes')->default(env('APP_API_APPLICATION_RATELIMIT_PERIOD', config('http.rate_limit.application_period'))), - Text::make("Ratelimit is per user, or IP if there is no user") + Text::make('Ratelimit is per user, or IP if there is no user'), ]), Fieldset::make() ->label('Auth Ratelimit') ->schema([ TextInput::make('APP_API_AUTH_RATELIMIT') - ->label("Requests Per Period") + ->label('Requests Per Period') ->required() ->numeric() ->minValue(1) - ->suffix("Requests")->default(env('APP_API_AUTH_RATELIMIT', config('http.rate_limit.auth'))), + ->suffix('Requests')->default(env('APP_API_AUTH_RATELIMIT', config('http.rate_limit.auth'))), TextInput::make('APP_API_AUTH_RATELIMIT_PERIOD') - ->label("Period Length") + ->label('Period Length') ->required() ->numeric() ->minValue(1) ->suffix('Minutes')->default(env('APP_API_AUTH_RATELIMIT_PERIOD', config('http.rate_limit.auth_period'))), - Text::make("Ratelimit is instance wide") + Text::make('Ratelimit is instance wide'), ]), Fieldset::make() ->label('Password Reset Ratelimit') ->schema([ TextInput::make('APP_API_PASSWORD_RESET_RATELIMIT') - ->label("Requests Per Period") + ->label('Requests Per Period') ->required() ->numeric() ->minValue(1) - ->suffix("Requests")->default(env('APP_API_PASSWORD_RESET_RATELIMIT', config('http.rate_limit.password_reset'))), + ->suffix('Requests')->default(env('APP_API_PASSWORD_RESET_RATELIMIT', config('http.rate_limit.password_reset'))), TextInput::make('APP_API_PASSWORD_RESET_RATELIMIT_PERIOD') - ->label("Period Length") + ->label('Period Length') ->required() ->numeric() ->minValue(1) ->suffix('Minutes')->default(env('APP_API_PASSWORD_RESET_RATELIMIT_PERIOD', config('http.rate_limit.password_reset_period'))), - Text::make("Ratelimit is per IP") + Text::make('Ratelimit is per IP'), ]), Fieldset::make() ->label('Websocket Ratelimit') ->schema([ TextInput::make('APP_API_WEBSOCKET_RATELIMIT') - ->label("Requests Per Period") + ->label('Requests Per Period') ->required() ->numeric() ->minValue(1) - ->suffix("Requests")->default(env('APP_API_WEBSOCKET_RATELIMIT', config('http.rate_limit.websocket'))), + ->suffix('Requests')->default(env('APP_API_WEBSOCKET_RATELIMIT', config('http.rate_limit.websocket'))), TextInput::make('APP_API_WEBSOCKET_RATELIMIT_PERIOD') - ->label("Period Length") + ->label('Period Length') ->required() ->numeric() ->minValue(1) ->suffix('Minutes')->default(env('APP_API_WEBSOCKET_RATELIMIT_PERIOD', config('http.rate_limit.websocket_period'))), - Text::make("Ratelimit is per server") + Text::make('Ratelimit is per server'), ]), Fieldset::make() ->label('Backup and Restore Ratelimit') ->schema([ TextInput::make('APP_API_BACKUP_RESTORE_RATELIMIT') - ->label("Requests Per Period") + ->label('Requests Per Period') ->required() ->numeric() ->minValue(1) - ->suffix("Requests")->default(env('APP_API_BACKUP_RESTORE_RATELIMIT', config('http.rate_limit.backup_restore'))), + ->suffix('Requests')->default(env('APP_API_BACKUP_RESTORE_RATELIMIT', config('http.rate_limit.backup_restore'))), TextInput::make('APP_API_BACKUP_RESTORE_RATELIMIT_PERIOD') - ->label("Period Length") + ->label('Period Length') ->required() ->numeric() ->minValue(1) ->suffix('Minutes')->default(env('APP_API_BACKUP_RESTORE_RATELIMIT_PERIOD', config('http.rate_limit.backup_restore_period'))), - Text::make("Ratelimit is per server") + Text::make('Ratelimit is per server'), ]), Fieldset::make() ->label('Database Create Ratelimit') ->schema([ TextInput::make('APP_API_DATABASE_CREATE_RATELIMIT') - ->label("Requests Per Period") + ->label('Requests Per Period') ->required() ->numeric() ->minValue(1) - ->suffix("Requests")->default(env('APP_API_DATABASE_CREATE_RATELIMIT', config('http.rate_limit.database_create'))), + ->suffix('Requests')->default(env('APP_API_DATABASE_CREATE_RATELIMIT', config('http.rate_limit.database_create'))), TextInput::make('APP_API_DATABASE_CREATE_RATELIMIT_PERIOD') - ->label("Period Length") + ->label('Period Length') ->required() ->numeric() ->minValue(1) ->suffix('Minutes')->default(env('APP_API_DATABASE_CREATE_RATELIMIT_PERIOD', config('http.rate_limit.database_create_period'))), - Text::make("Ratelimit is per server") + Text::make('Ratelimit is per server'), ]), Fieldset::make() ->label('Subuser Create Ratelimit') ->schema([ TextInput::make('APP_API_SUBUSER_CREATE_RATELIMIT') - ->label("Requests Per Period") + ->label('Requests Per Period') ->required() ->numeric() ->minValue(1) - ->suffix("Requests")->default(env('APP_API_SUBUSER_CREATE_RATELIMIT', config('http.rate_limit.subuser_create'))), + ->suffix('Requests')->default(env('APP_API_SUBUSER_CREATE_RATELIMIT', config('http.rate_limit.subuser_create'))), TextInput::make('APP_API_SUBUSER_CREATE_RATELIMIT_PERIOD') - ->label("Period Length") + ->label('Period Length') ->required() ->numeric() ->minValue(1) ->suffix('Minutes')->default(env('APP_API_SUBUSER_CREATE_RATELIMIT_PERIOD', config('http.rate_limit.subuser_create_period'))), - Text::make("Ratelimit is per server") + Text::make('Ratelimit is per server'), ]), Fieldset::make() ->label('File Pull Ratelimit') ->schema([ TextInput::make('APP_API_FILE_PULL_RATELIMIT') - ->label("Requests Per Period") + ->label('Requests Per Period') ->required() ->numeric() ->minValue(1) - ->suffix("Requests")->default(env('APP_API_FILE_PULL_RATELIMIT', config('http.rate_limit.file_pull'))), + ->suffix('Requests')->default(env('APP_API_FILE_PULL_RATELIMIT', config('http.rate_limit.file_pull'))), TextInput::make('APP_API_FILE_PULL_RATELIMIT_PERIOD') - ->label("Period Length") + ->label('Period Length') ->required() ->numeric() ->minValue(1) ->suffix('Minutes')->default(env('APP_API_FILE_PULL_RATELIMIT_PERIOD', config('http.rate_limit.file_pull_period'))), - Text::make("Ratelimit is per server") + Text::make('Ratelimit is per server'), ]), Fieldset::make() ->label('Default Ratelimit') ->schema([ TextInput::make('APP_API_DEFAULT_RATELIMIT') - ->label("Requests Per Period") + ->label('Requests Per Period') ->required() ->numeric() ->minValue(1) - ->suffix("Requests")->default(env('APP_API_DEFAULT_RATELIMIT', config('http.rate_limit.default'))), + ->suffix('Requests')->default(env('APP_API_DEFAULT_RATELIMIT', config('http.rate_limit.default'))), TextInput::make('APP_API_DEFAULT_RATELIMIT_PERIOD') - ->label("Period Length") + ->label('Period Length') ->required() ->numeric() ->minValue(1) ->suffix('Minutes')->default(env('APP_API_DEFAULT_RATELIMIT_PERIOD', config('http.rate_limit.default_period'))), - Text::make("Ratelimit is per server") + Text::make('Ratelimit is per server'), ]), ]), Section::make(trans('admin/setting.misc.server.title')) @@ -995,8 +995,8 @@ private function miscSettings(): array ->offColor('danger') ->live() ->columnSpan(1) - ->formatStateUsing(fn($state): bool => (bool) $state) - ->afterStateUpdated(fn($state, Set $set) => $set('PANEL_EDITABLE_SERVER_DESCRIPTIONS', (bool) $state)) + ->formatStateUsing(fn ($state): bool => (bool) $state) + ->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_EDITABLE_SERVER_DESCRIPTIONS', (bool) $state)) ->default(env('PANEL_EDITABLE_SERVER_DESCRIPTIONS', config('panel.editable_server_descriptions'))), FileUpload::make('ConsoleFonts') ->hint(trans('admin/setting.misc.server.console_font_hint')) @@ -1078,7 +1078,7 @@ protected function getDefaultHeaderActions(): array ->icon(TablerIcon::DeviceFloppy) ->action('save') ->tooltip(trans('filament-panels::resources/pages/edit-record.form.actions.save.label')) - ->authorize(fn() => user()?->can('update settings')) + ->authorize(fn () => user()?->can('update settings')) ->keyBindings(['mod+s']), ]; } From dbb349f421f16355f915841ea328d39ce42698fd Mon Sep 17 00:00:00 2001 From: O2theC <93496386+O2theC@users.noreply.github.com> Date: Fri, 22 May 2026 12:41:51 -0400 Subject: [PATCH 3/5] remove auth ratelimit due to not being used anymore --- app/Filament/Admin/Pages/Settings.php | 18 ------------------ app/Providers/RouteServiceProvider.php | 2 -- config/http.php | 3 --- 3 files changed, 23 deletions(-) diff --git a/app/Filament/Admin/Pages/Settings.php b/app/Filament/Admin/Pages/Settings.php index f9b2ea73d2..c2d7f8ba62 100644 --- a/app/Filament/Admin/Pages/Settings.php +++ b/app/Filament/Admin/Pages/Settings.php @@ -836,24 +836,6 @@ private function miscSettings(): array ->suffix('Minutes')->default(env('APP_API_APPLICATION_RATELIMIT_PERIOD', config('http.rate_limit.application_period'))), Text::make('Ratelimit is per user, or IP if there is no user'), ]), - Fieldset::make() - ->label('Auth Ratelimit') - ->schema([ - TextInput::make('APP_API_AUTH_RATELIMIT') - ->label('Requests Per Period') - ->required() - ->numeric() - ->minValue(1) - ->suffix('Requests')->default(env('APP_API_AUTH_RATELIMIT', config('http.rate_limit.auth'))), - - TextInput::make('APP_API_AUTH_RATELIMIT_PERIOD') - ->label('Period Length') - ->required() - ->numeric() - ->minValue(1) - ->suffix('Minutes')->default(env('APP_API_AUTH_RATELIMIT_PERIOD', config('http.rate_limit.auth_period'))), - Text::make('Ratelimit is instance wide'), - ]), Fieldset::make() ->label('Password Reset Ratelimit') ->schema([ diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 9246795276..2d59b6552c 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -72,8 +72,6 @@ protected function configureRateLimiting(): void if ($request->route()->named('auth.post.forgot-password')) { return Limit::perMinutes(config('http.rate_limit.password_reset_period'), config('http.rate_limit.password_reset'))->by($request->ip()); } - - return Limit::perMinutes(config('http.rate_limit.auth_period'), config('http.rate_limit.auth')); }); // Configure the throttles for both the application and client APIs below. diff --git a/config/http.php b/config/http.php index 10171fc3fc..47a481a822 100644 --- a/config/http.php +++ b/config/http.php @@ -17,9 +17,6 @@ 'application_period' => env('APP_API_APPLICATION_RATELIMIT_PERIOD', 1), 'application' => env('APP_API_APPLICATION_RATELIMIT', 256), - 'auth_period' => env('APP_API_AUTH_RATELIMIT_PERIOD', 1), - 'auth' => env('APP_API_AUTH_RATELIMIT', 10), - 'password_reset_period' => env('APP_API_PASSWORD_RESET_RATELIMIT_PERIOD', 1), 'password_reset' => env('APP_API_PASSWORD_RESET_RATELIMIT', 2), From b98192781978f843b8f193e09666ab98c9951965 Mon Sep 17 00:00:00 2001 From: O2theC <93496386+O2theC@users.noreply.github.com> Date: Sun, 31 May 2026 10:59:29 -0400 Subject: [PATCH 4/5] moved various hardcoded strings to using translation keys --- app/Filament/Admin/Pages/Settings.php | 108 +++++++++++++------------- lang/en/admin/setting.php | 25 +++++- 2 files changed, 76 insertions(+), 57 deletions(-) diff --git a/app/Filament/Admin/Pages/Settings.php b/app/Filament/Admin/Pages/Settings.php index c2d7f8ba62..cd112334bb 100644 --- a/app/Filament/Admin/Pages/Settings.php +++ b/app/Filament/Admin/Pages/Settings.php @@ -801,166 +801,166 @@ private function miscSettings(): array ->collapsed() ->schema([ Fieldset::make() - ->label('Client API Ratelimit') + ->label(trans('admin/setting.misc.api.client_title')) ->schema([ TextInput::make('APP_API_CLIENT_RATELIMIT') - ->label('Requests Per Period') + ->label(trans('admin/setting.misc.api.requests_per_period')) ->required() ->numeric() ->minValue(1) - ->suffix('Requests')->default(env('APP_API_CLIENT_RATELIMIT', config('http.rate_limit.client'))), + ->suffix(trans('admin/setting.misc.api.requests'))->default(env('APP_API_CLIENT_RATELIMIT', config('http.rate_limit.client'))), TextInput::make('APP_API_CLIENT_RATELIMIT_PERIOD') - ->label('Period Length') + ->label(trans('admin/setting.misc.api.period_length')) ->required() ->numeric() ->minValue(1) - ->suffix('Minutes')->default(env('APP_API_CLIENT_RATELIMIT_PERIOD', config('http.rate_limit.client_period'))), - Text::make('Ratelimit is per user, or IP if there is no user'), + ->suffix(trans('admin/setting.misc.api.minutes'))->default(env('APP_API_CLIENT_RATELIMIT_PERIOD', config('http.rate_limit.client_period'))), + Text::make(trans('admin/setting.misc.api.client_helper')), ]), Fieldset::make() - ->label('Application API Ratelimit') + ->label(trans('admin/setting.misc.api.application_title')) ->schema([ TextInput::make('APP_API_APPLICATION_RATELIMIT') - ->label('Requests Per Period') + ->label(trans('admin/setting.misc.api.requests_per_period')) ->required() ->numeric() ->minValue(1) - ->suffix('Requests')->default(env('APP_API_APPLICATION_RATELIMIT', config('http.rate_limit.application'))), + ->suffix(trans('admin/setting.misc.api.requests'))->default(env('APP_API_APPLICATION_RATELIMIT', config('http.rate_limit.application'))), TextInput::make('APP_API_APPLICATION_RATELIMIT_PERIOD') - ->label('Period Length') + ->label(trans('admin/setting.misc.api.period_length')) ->required() ->numeric() ->minValue(1) - ->suffix('Minutes')->default(env('APP_API_APPLICATION_RATELIMIT_PERIOD', config('http.rate_limit.application_period'))), - Text::make('Ratelimit is per user, or IP if there is no user'), + ->suffix(trans('admin/setting.misc.api.minutes'))->default(env('APP_API_APPLICATION_RATELIMIT_PERIOD', config('http.rate_limit.application_period'))), + Text::make(trans('admin/setting.misc.api.application_helper')), ]), Fieldset::make() - ->label('Password Reset Ratelimit') + ->label(trans('admin/setting.misc.api.password_reset_title')) ->schema([ TextInput::make('APP_API_PASSWORD_RESET_RATELIMIT') - ->label('Requests Per Period') + ->label(trans('admin/setting.misc.api.requests_per_period')) ->required() ->numeric() ->minValue(1) - ->suffix('Requests')->default(env('APP_API_PASSWORD_RESET_RATELIMIT', config('http.rate_limit.password_reset'))), + ->suffix(trans('admin/setting.misc.api.requests'))->default(env('APP_API_PASSWORD_RESET_RATELIMIT', config('http.rate_limit.password_reset'))), TextInput::make('APP_API_PASSWORD_RESET_RATELIMIT_PERIOD') - ->label('Period Length') + ->label(trans('admin/setting.misc.api.period_length')) ->required() ->numeric() ->minValue(1) - ->suffix('Minutes')->default(env('APP_API_PASSWORD_RESET_RATELIMIT_PERIOD', config('http.rate_limit.password_reset_period'))), - Text::make('Ratelimit is per IP'), + ->suffix(trans('admin/setting.misc.api.minutes'))->default(env('APP_API_PASSWORD_RESET_RATELIMIT_PERIOD', config('http.rate_limit.password_reset_period'))), + Text::make(trans('admin/setting.misc.api.password_reset_helper')), ]), Fieldset::make() - ->label('Websocket Ratelimit') + ->label(trans('admin/setting.misc.api.websocket_title')) ->schema([ TextInput::make('APP_API_WEBSOCKET_RATELIMIT') - ->label('Requests Per Period') + ->label(trans('admin/setting.misc.api.requests_per_period')) ->required() ->numeric() ->minValue(1) - ->suffix('Requests')->default(env('APP_API_WEBSOCKET_RATELIMIT', config('http.rate_limit.websocket'))), + ->suffix(trans('admin/setting.misc.api.requests'))->default(env('APP_API_WEBSOCKET_RATELIMIT', config('http.rate_limit.websocket'))), TextInput::make('APP_API_WEBSOCKET_RATELIMIT_PERIOD') - ->label('Period Length') + ->label(trans('admin/setting.misc.api.period_length')) ->required() ->numeric() ->minValue(1) - ->suffix('Minutes')->default(env('APP_API_WEBSOCKET_RATELIMIT_PERIOD', config('http.rate_limit.websocket_period'))), - Text::make('Ratelimit is per server'), + ->suffix(trans('admin/setting.misc.api.minutes'))->default(env('APP_API_WEBSOCKET_RATELIMIT_PERIOD', config('http.rate_limit.websocket_period'))), + Text::make(trans('admin/setting.misc.api.websocket_helper')), ]), Fieldset::make() - ->label('Backup and Restore Ratelimit') + ->label(trans('admin/setting.misc.api.backup_restore_title')) ->schema([ TextInput::make('APP_API_BACKUP_RESTORE_RATELIMIT') - ->label('Requests Per Period') + ->label(trans('admin/setting.misc.api.requests_per_period')) ->required() ->numeric() ->minValue(1) - ->suffix('Requests')->default(env('APP_API_BACKUP_RESTORE_RATELIMIT', config('http.rate_limit.backup_restore'))), + ->suffix(trans('admin/setting.misc.api.requests'))->default(env('APP_API_BACKUP_RESTORE_RATELIMIT', config('http.rate_limit.backup_restore'))), TextInput::make('APP_API_BACKUP_RESTORE_RATELIMIT_PERIOD') - ->label('Period Length') + ->label(trans('admin/setting.misc.api.period_length')) ->required() ->numeric() ->minValue(1) - ->suffix('Minutes')->default(env('APP_API_BACKUP_RESTORE_RATELIMIT_PERIOD', config('http.rate_limit.backup_restore_period'))), - Text::make('Ratelimit is per server'), + ->suffix(trans('admin/setting.misc.api.minutes'))->default(env('APP_API_BACKUP_RESTORE_RATELIMIT_PERIOD', config('http.rate_limit.backup_restore_period'))), + Text::make(trans('admin/setting.misc.api.backup_restore_helper')), ]), Fieldset::make() - ->label('Database Create Ratelimit') + ->label(trans('admin/setting.misc.api.database_create_title')) ->schema([ TextInput::make('APP_API_DATABASE_CREATE_RATELIMIT') - ->label('Requests Per Period') + ->label(trans('admin/setting.misc.api.requests_per_period')) ->required() ->numeric() ->minValue(1) - ->suffix('Requests')->default(env('APP_API_DATABASE_CREATE_RATELIMIT', config('http.rate_limit.database_create'))), + ->suffix(trans('admin/setting.misc.api.requests'))->default(env('APP_API_DATABASE_CREATE_RATELIMIT', config('http.rate_limit.database_create'))), TextInput::make('APP_API_DATABASE_CREATE_RATELIMIT_PERIOD') - ->label('Period Length') + ->label(trans('admin/setting.misc.api.period_length')) ->required() ->numeric() ->minValue(1) - ->suffix('Minutes')->default(env('APP_API_DATABASE_CREATE_RATELIMIT_PERIOD', config('http.rate_limit.database_create_period'))), - Text::make('Ratelimit is per server'), + ->suffix(trans('admin/setting.misc.api.minutes'))->default(env('APP_API_DATABASE_CREATE_RATELIMIT_PERIOD', config('http.rate_limit.database_create_period'))), + Text::make(trans('admin/setting.misc.api.database_create_helper')), ]), Fieldset::make() - ->label('Subuser Create Ratelimit') + ->label(trans('admin/setting.misc.api.subuser_create_title')) ->schema([ TextInput::make('APP_API_SUBUSER_CREATE_RATELIMIT') - ->label('Requests Per Period') + ->label(trans('admin/setting.misc.api.requests_per_period')) ->required() ->numeric() ->minValue(1) - ->suffix('Requests')->default(env('APP_API_SUBUSER_CREATE_RATELIMIT', config('http.rate_limit.subuser_create'))), + ->suffix(trans('admin/setting.misc.api.requests'))->default(env('APP_API_SUBUSER_CREATE_RATELIMIT', config('http.rate_limit.subuser_create'))), TextInput::make('APP_API_SUBUSER_CREATE_RATELIMIT_PERIOD') - ->label('Period Length') + ->label(trans('admin/setting.misc.api.period_length')) ->required() ->numeric() ->minValue(1) - ->suffix('Minutes')->default(env('APP_API_SUBUSER_CREATE_RATELIMIT_PERIOD', config('http.rate_limit.subuser_create_period'))), - Text::make('Ratelimit is per server'), + ->suffix(trans('admin/setting.misc.api.minutes'))->default(env('APP_API_SUBUSER_CREATE_RATELIMIT_PERIOD', config('http.rate_limit.subuser_create_period'))), + Text::make(trans('admin/setting.misc.api.subuser_create_helper')), ]), Fieldset::make() - ->label('File Pull Ratelimit') + ->label(trans('admin/setting.misc.api.file_pull_title')) ->schema([ TextInput::make('APP_API_FILE_PULL_RATELIMIT') - ->label('Requests Per Period') + ->label(trans('admin/setting.misc.api.requests_per_period')) ->required() ->numeric() ->minValue(1) - ->suffix('Requests')->default(env('APP_API_FILE_PULL_RATELIMIT', config('http.rate_limit.file_pull'))), + ->suffix(trans('admin/setting.misc.api.requests'))->default(env('APP_API_FILE_PULL_RATELIMIT', config('http.rate_limit.file_pull'))), TextInput::make('APP_API_FILE_PULL_RATELIMIT_PERIOD') - ->label('Period Length') + ->label(trans('admin/setting.misc.api.period_length')) ->required() ->numeric() ->minValue(1) - ->suffix('Minutes')->default(env('APP_API_FILE_PULL_RATELIMIT_PERIOD', config('http.rate_limit.file_pull_period'))), - Text::make('Ratelimit is per server'), + ->suffix(trans('admin/setting.misc.api.minutes'))->default(env('APP_API_FILE_PULL_RATELIMIT_PERIOD', config('http.rate_limit.file_pull_period'))), + Text::make(trans('admin/setting.misc.api.file_pull_helper')), ]), Fieldset::make() - ->label('Default Ratelimit') + ->label(trans('admin/setting.misc.api.default_title')) ->schema([ TextInput::make('APP_API_DEFAULT_RATELIMIT') - ->label('Requests Per Period') + ->label(trans('admin/setting.misc.api.requests_per_period')) ->required() ->numeric() ->minValue(1) - ->suffix('Requests')->default(env('APP_API_DEFAULT_RATELIMIT', config('http.rate_limit.default'))), + ->suffix(trans('admin/setting.misc.api.requests'))->default(env('APP_API_DEFAULT_RATELIMIT', config('http.rate_limit.default'))), TextInput::make('APP_API_DEFAULT_RATELIMIT_PERIOD') - ->label('Period Length') + ->label(trans('admin/setting.misc.api.period_length')) ->required() ->numeric() ->minValue(1) - ->suffix('Minutes')->default(env('APP_API_DEFAULT_RATELIMIT_PERIOD', config('http.rate_limit.default_period'))), - Text::make('Ratelimit is per server'), + ->suffix(trans('admin/setting.misc.api.minutes'))->default(env('APP_API_DEFAULT_RATELIMIT_PERIOD', config('http.rate_limit.default_period'))), + Text::make(trans('admin/setting.misc.api.default_helper')), ]), ]), Section::make(trans('admin/setting.misc.server.title')) diff --git a/lang/en/admin/setting.php b/lang/en/admin/setting.php index b7a278dfa4..6a1f0f5049 100644 --- a/lang/en/admin/setting.php +++ b/lang/en/admin/setting.php @@ -140,9 +140,28 @@ 'api' => [ 'title' => 'API', 'helper' => 'Defines the rate limit for the number of requests per minute that can be executed.', - 'client_rate' => 'Client API Rate Limit', - 'app_rate' => 'Application API Rate Limit', - 'rpm' => 'Requests per Minute', + 'requests_per_period' => 'Requests Per Period', + 'requests' => 'Requests', + 'minutes' => 'Minutes', + 'period_length' => 'Period Length', + 'client_title' => 'Client API Ratelimit', + 'client_helper' => 'Ratelimit is per user, or IP if there is no user', + 'application_title' => 'Application API Ratelimit', + 'application_helper' => 'Ratelimit is per user, or IP if there is no user', + 'password_reset_title' => 'Password Reset Ratelimit', + 'password_reset_helper' => 'Ratelimit is per IP', + 'websocket_title' => 'Websocket Ratelimit', + 'websocket_helper' => 'Ratelimit is per server', + 'backup_restore_title' => 'Backup and Restore Ratelimit', + 'backup_restore_helper' => 'Ratelimit is per server', + 'database_create_title' => 'Database Create Ratelimit', + 'database_create_helper' => 'Ratelimit is per server', + 'subuser_create_title' => 'Subuser Create Ratelimit', + 'subuser_create_helper' => 'Ratelimit is per server', + 'file_pull_title' => 'File Pull Ratelimit', + 'file_pull_helper' => 'Ratelimit is per server', + 'default_title' => 'Default Ratelimit', + 'default_helper' => 'Ratelimit is per server', ], 'server' => [ 'title' => 'Servers', From a90b527e3b82de0ba3320e5c354a6fff65f8af77 Mon Sep 17 00:00:00 2001 From: O2theC <93496386+O2theC@users.noreply.github.com> Date: Sun, 31 May 2026 11:05:55 -0400 Subject: [PATCH 5/5] rewording api helper text based on suggestion from code rabbit ai --- lang/en/admin/setting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/en/admin/setting.php b/lang/en/admin/setting.php index 6a1f0f5049..65585e7c8a 100644 --- a/lang/en/admin/setting.php +++ b/lang/en/admin/setting.php @@ -139,7 +139,7 @@ ], 'api' => [ 'title' => 'API', - 'helper' => 'Defines the rate limit for the number of requests per minute that can be executed.', + 'helper' => 'Defines the rate limit for the number of requests that can be executed per configured period.', 'requests_per_period' => 'Requests Per Period', 'requests' => 'Requests', 'minutes' => 'Minutes',