mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 00:34:44 +02:00
Add back behind_proxy
to ui (#1263)
* add back `behind_proxy` to ui * combine `scheme` and `behind_proxy` into one component * remove debug stuff * update translations * make bulky
This commit is contained in:
parent
03745eb4be
commit
a6326f64fb
@ -7,6 +7,7 @@ use App\Models\Node;
|
|||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Components\Actions\Action;
|
use Filament\Forms\Components\Actions\Action;
|
||||||
use Filament\Forms\Components\Grid;
|
use Filament\Forms\Components\Grid;
|
||||||
|
use Filament\Forms\Components\Hidden;
|
||||||
use Filament\Forms\Components\TagsInput;
|
use Filament\Forms\Components\TagsInput;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Components\ToggleButtons;
|
use Filament\Forms\Components\ToggleButtons;
|
||||||
@ -149,14 +150,15 @@ class CreateNode extends CreateRecord
|
|||||||
->required()
|
->required()
|
||||||
->maxLength(100),
|
->maxLength(100),
|
||||||
|
|
||||||
ToggleButtons::make('scheme')
|
Hidden::make('scheme')
|
||||||
|
->default(fn () => request()->isSecure() ? 'https' : 'http'),
|
||||||
|
|
||||||
|
Hidden::make('behind_proxy')
|
||||||
|
->default(false),
|
||||||
|
|
||||||
|
ToggleButtons::make('connection')
|
||||||
->label(trans('admin/node.ssl'))
|
->label(trans('admin/node.ssl'))
|
||||||
->columnSpan([
|
->columnSpan(1)
|
||||||
'default' => 1,
|
|
||||||
'sm' => 1,
|
|
||||||
'md' => 1,
|
|
||||||
'lg' => 1,
|
|
||||||
])
|
|
||||||
->inline()
|
->inline()
|
||||||
->helperText(function (Get $get) {
|
->helperText(function (Get $get) {
|
||||||
if (request()->isSecure()) {
|
if (request()->isSecure()) {
|
||||||
@ -169,20 +171,29 @@ class CreateNode extends CreateRecord
|
|||||||
|
|
||||||
return '';
|
return '';
|
||||||
})
|
})
|
||||||
->disableOptionWhen(fn (string $value): bool => $value === 'http' && request()->isSecure())
|
->disableOptionWhen(fn (string $value) => $value === 'http' && request()->isSecure())
|
||||||
->options([
|
->options([
|
||||||
'http' => 'HTTP',
|
'http' => 'HTTP',
|
||||||
'https' => 'HTTPS (SSL)',
|
'https' => 'HTTPS (SSL)',
|
||||||
|
'https_proxy' => 'HTTPS with (reverse) proxy',
|
||||||
])
|
])
|
||||||
->colors([
|
->colors([
|
||||||
'http' => 'warning',
|
'http' => 'warning',
|
||||||
'https' => 'success',
|
'https' => 'success',
|
||||||
|
'https_proxy' => 'success',
|
||||||
])
|
])
|
||||||
->icons([
|
->icons([
|
||||||
'http' => 'tabler-lock-open-off',
|
'http' => 'tabler-lock-open-off',
|
||||||
'https' => 'tabler-lock',
|
'https' => 'tabler-lock',
|
||||||
|
'https_proxy' => 'tabler-shield-lock',
|
||||||
])
|
])
|
||||||
->default(fn () => request()->isSecure() ? 'https' : 'http'),
|
->default(fn () => request()->isSecure() ? 'https' : 'http')
|
||||||
|
->live()
|
||||||
|
->dehydrated(false)
|
||||||
|
->afterStateUpdated(function ($state, Set $set) {
|
||||||
|
$set('scheme', $state === 'http' ? 'http' : 'https');
|
||||||
|
$set('behind_proxy', $state === 'https_proxy');
|
||||||
|
}),
|
||||||
]),
|
]),
|
||||||
Step::make('advanced')
|
Step::make('advanced')
|
||||||
->label(trans('admin/node.tabs.advanced_settings'))
|
->label(trans('admin/node.tabs.advanced_settings'))
|
||||||
|
@ -14,6 +14,7 @@ use Filament\Forms;
|
|||||||
use Filament\Forms\Components\Actions as FormActions;
|
use Filament\Forms\Components\Actions as FormActions;
|
||||||
use Filament\Forms\Components\Fieldset;
|
use Filament\Forms\Components\Fieldset;
|
||||||
use Filament\Forms\Components\Grid;
|
use Filament\Forms\Components\Grid;
|
||||||
|
use Filament\Forms\Components\Hidden;
|
||||||
use Filament\Forms\Components\Placeholder;
|
use Filament\Forms\Components\Placeholder;
|
||||||
use Filament\Forms\Components\Tabs;
|
use Filament\Forms\Components\Tabs;
|
||||||
use Filament\Forms\Components\Tabs\Tab;
|
use Filament\Forms\Components\Tabs\Tab;
|
||||||
@ -199,7 +200,9 @@ class EditNode extends EditRecord
|
|||||||
])
|
])
|
||||||
->required()
|
->required()
|
||||||
->maxLength(100),
|
->maxLength(100),
|
||||||
ToggleButtons::make('scheme')
|
Hidden::make('scheme'),
|
||||||
|
Hidden::make('behind_proxy'),
|
||||||
|
ToggleButtons::make('connection')
|
||||||
->label(trans('admin/node.ssl'))
|
->label(trans('admin/node.ssl'))
|
||||||
->columnSpan(1)
|
->columnSpan(1)
|
||||||
->inline()
|
->inline()
|
||||||
@ -214,20 +217,30 @@ class EditNode extends EditRecord
|
|||||||
|
|
||||||
return '';
|
return '';
|
||||||
})
|
})
|
||||||
->disableOptionWhen(fn (string $value): bool => $value === 'http' && request()->isSecure())
|
->disableOptionWhen(fn (string $value) => $value === 'http' && request()->isSecure())
|
||||||
->options([
|
->options([
|
||||||
'http' => 'HTTP',
|
'http' => 'HTTP',
|
||||||
'https' => 'HTTPS (SSL)',
|
'https' => 'HTTPS (SSL)',
|
||||||
|
'https_proxy' => 'HTTPS with (reverse) proxy',
|
||||||
])
|
])
|
||||||
->colors([
|
->colors([
|
||||||
'http' => 'warning',
|
'http' => 'warning',
|
||||||
'https' => 'success',
|
'https' => 'success',
|
||||||
|
'https_proxy' => 'success',
|
||||||
])
|
])
|
||||||
->icons([
|
->icons([
|
||||||
'http' => 'tabler-lock-open-off',
|
'http' => 'tabler-lock-open-off',
|
||||||
'https' => 'tabler-lock',
|
'https' => 'tabler-lock',
|
||||||
|
'https_proxy' => 'tabler-shield-lock',
|
||||||
])
|
])
|
||||||
->default(fn () => request()->isSecure() ? 'https' : 'http'), ]),
|
->formatStateUsing(fn (Get $get) => $get('scheme') === 'http' ? 'http' : ($get('behind_proxy') ? 'https_proxy' : 'https'))
|
||||||
|
->live()
|
||||||
|
->dehydrated(false)
|
||||||
|
->afterStateUpdated(function ($state, Set $set) {
|
||||||
|
$set('scheme', $state === 'http' ? 'http' : 'https');
|
||||||
|
$set('behind_proxy', $state === 'https_proxy');
|
||||||
|
}),
|
||||||
|
]),
|
||||||
Tab::make('adv')
|
Tab::make('adv')
|
||||||
->label(trans('admin/node.tabs.advanced_settings'))
|
->label(trans('admin/node.tabs.advanced_settings'))
|
||||||
->columns([
|
->columns([
|
||||||
|
@ -216,7 +216,7 @@ class Node extends Model implements Validatable
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
'allowed_mounts' => $this->mounts->pluck('source')->toArray(),
|
'allowed_mounts' => $this->mounts->pluck('source')->toArray(),
|
||||||
'remote' => route('filament.app.resources...index'),
|
'remote' => config('app.url'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user