mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 06:56:52 +01:00 
			
		
		
		
	Fix table view power actions (#1490)
This commit is contained in:
		
							parent
							
								
									556551b4f3
								
							
						
					
					
						commit
						f8e802afcd
					
				| @ -110,7 +110,7 @@ class ListServers extends ListRecords | ||||
|             ->poll('15s') | ||||
|             ->columns($usingGrid ? $this->gridColumns() : $this->tableColumns()) | ||||
|             ->recordUrl(!$usingGrid ? (fn (Server $server) => Console::getUrl(panel: 'server', tenant: $server)) : null) | ||||
|             ->actions(!$usingGrid ? ActionGroup::make(static::getPowerActions()) : []) | ||||
|             ->actions(!$usingGrid ? ActionGroup::make(static::getPowerActions(view: 'table')) : []) | ||||
|             ->actionsAlignment(Alignment::Center->value) | ||||
|             ->contentGrid($usingGrid ? ['default' => 1, 'md' => 2] : null) | ||||
|             ->emptyStateIcon('tabler-brand-docker') | ||||
| @ -221,10 +221,9 @@ class ListServers extends ListRecords | ||||
|     } | ||||
| 
 | ||||
|     /** @return Action[]|ActionGroup[] */ | ||||
|     public static function getPowerActions(): array | ||||
|     public static function getPowerActions(string $view): array | ||||
|     { | ||||
|         return [ | ||||
|             ActionGroup::make([ | ||||
|         $actions = [ | ||||
|             Action::make('start') | ||||
|                 ->color('primary') | ||||
|                 ->icon('tabler-player-play-filled') | ||||
| @ -250,11 +249,18 @@ class ListServers extends ListRecords | ||||
|                 ->authorize(fn (Server $server) => auth()->user()->can(Permission::ACTION_CONTROL_STOP, $server)) | ||||
|                 ->visible(fn (Server $server) => !$server->isInConflictState() & $server->retrieveStatus()->isKillable()) | ||||
|                 ->dispatch('powerAction', fn (Server $server) => ['server' => $server, 'action' => 'kill']), | ||||
|             ]) | ||||
|         ]; | ||||
| 
 | ||||
|         if ($view === 'table') { | ||||
|             return $actions; | ||||
|         } else { | ||||
|             return [ | ||||
|                 ActionGroup::make($actions) | ||||
|                     ->icon(fn (Server $server) => $server->condition->getIcon()) | ||||
|                     ->color(fn (Server $server) => $server->condition->getColor()) | ||||
|                     ->tooltip(fn (Server $server) => $server->condition->getLabel()) | ||||
|                     ->iconSize(IconSize::Large), | ||||
|             ]; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -11,7 +11,7 @@ | ||||
|             <div class="end-0" x-on:click.stop> | ||||
|                 <div class="flex-1 dark:bg-gray-800 dark:text-white rounded-b-lg overflow-hidden p-1"> | ||||
|                     <x-filament-tables::actions | ||||
|                         :actions="\App\Filament\App\Resources\ServerResource\Pages\ListServers::getPowerActions()" | ||||
|                         :actions="\App\Filament\App\Resources\ServerResource\Pages\ListServers::getPowerActions(view: 'grid')" | ||||
|                         :alignment="\Filament\Support\Enums\Alignment::Center" | ||||
|                         :record="$server" | ||||
|                     /> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Charles
						Charles