mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 14:06:53 +01:00 
			
		
		
		
	 1fdc428f3e
			
		
	
	
		1fdc428f3e
		
			
		
	
	
	
	
		
			
			* Replace `string` with `enum` * Add title * Allow sendCommand on `Starting` or `Running` servers * refactor: Use Filament interfaces * Use `getLabel` instead of `str->headline` Co-authored-by: Boy132 <Boy132@users.noreply.github.com> --------- Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Enums;
 | |
| 
 | |
| use Filament\Support\Contracts\HasColor;
 | |
| use Filament\Support\Contracts\HasIcon;
 | |
| use Filament\Support\Contracts\HasLabel;
 | |
| 
 | |
| enum ServerState: string implements HasColor, HasIcon, HasLabel
 | |
| {
 | |
|     case Normal = 'normal';
 | |
|     case Installing = 'installing';
 | |
|     case InstallFailed = 'install_failed';
 | |
|     case ReinstallFailed = 'reinstall_failed';
 | |
|     case Suspended = 'suspended';
 | |
|     case RestoringBackup = 'restoring_backup';
 | |
| 
 | |
|     public function getIcon(): string
 | |
|     {
 | |
|         return match ($this) {
 | |
|             self::Normal => 'tabler-heart',
 | |
|             self::Installing => 'tabler-heart-bolt',
 | |
|             self::InstallFailed => 'tabler-heart-x',
 | |
|             self::ReinstallFailed => 'tabler-heart-x',
 | |
|             self::Suspended => 'tabler-heart-cancel',
 | |
|             self::RestoringBackup => 'tabler-heart-up',
 | |
|         };
 | |
|     }
 | |
| 
 | |
|     public function getColor(): string
 | |
|     {
 | |
|         return match ($this) {
 | |
|             self::Normal => 'primary',
 | |
|             self::Installing => 'primary',
 | |
|             self::InstallFailed => 'danger',
 | |
|             self::ReinstallFailed => 'danger',
 | |
|             self::Suspended => 'warning',
 | |
|             self::RestoringBackup => 'primary',
 | |
|         };
 | |
|     }
 | |
| 
 | |
|     public function getLabel(): string
 | |
|     {
 | |
|         return str($this->value)->headline();
 | |
|     }
 | |
| }
 |