mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 21:04:44 +02:00
29 lines
742 B
PHP
29 lines
742 B
PHP
<?php
|
|
|
|
namespace App\Filament\Components\Forms\Actions;
|
|
|
|
use App\Models\Server;
|
|
use App\Services\Servers\StartupCommandService;
|
|
use Filament\Forms\Components\Actions\Action;
|
|
use Filament\Forms\Get;
|
|
use Filament\Forms\Set;
|
|
|
|
class PreviewStartupAction extends Action
|
|
{
|
|
public static function getDefaultName(): ?string
|
|
{
|
|
return 'preview';
|
|
}
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->action(function (Get $get, Set $set, Server $server) {
|
|
$active = $get('previewing');
|
|
$set('previewing', !$active);
|
|
$set('startup', $active ? $server->startup : fn (Server $server, StartupCommandService $service) => $service->handle($server));
|
|
});
|
|
}
|
|
}
|