mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 15:06:52 +01:00 
			
		
		
		
	Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com> Co-authored-by: Boy132 <Boy132@users.noreply.github.com> Co-authored-by: Lance Pioch <git@lance.sh>
		
			
				
	
	
		
			34 lines
		
	
	
		
			865 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			865 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Filament\Components\Actions;
 | 
						|
 | 
						|
use App\Models\Server;
 | 
						|
use App\Services\Servers\StartupCommandService;
 | 
						|
use Filament\Actions\Action;
 | 
						|
use Filament\Schemas\Components\Utilities\Get;
 | 
						|
use Filament\Schemas\Components\Utilities\Set;
 | 
						|
 | 
						|
class PreviewStartupAction extends Action
 | 
						|
{
 | 
						|
    public static function getDefaultName(): ?string
 | 
						|
    {
 | 
						|
        return 'preview';
 | 
						|
    }
 | 
						|
 | 
						|
    public function getLabel(): string
 | 
						|
    {
 | 
						|
        return trans('server/startup.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));
 | 
						|
        });
 | 
						|
    }
 | 
						|
}
 |