Schedule task improvements (#1468)

This commit is contained in:
Boy132 2025-06-26 17:00:37 +02:00 committed by GitHub
parent 68f72b9b4d
commit 4d0aabe91e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,6 +6,7 @@ use App\Facades\Activity;
use App\Models\Schedule;
use App\Models\Task;
use Filament\Forms\Components\Field;
use Filament\Forms\Set;
use Filament\Tables\Actions\DeleteAction;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
@ -45,10 +46,11 @@ class TasksRelationManager extends RelationManager
Select::make('action')
->required()
->live()
->disableOptionWhen(fn (string $value): bool => $value === Task::ACTION_BACKUP && $schedule->server->backup_limit === 0)
->disableOptionWhen(fn (string $value) => $value === Task::ACTION_BACKUP && $schedule->server->backup_limit === 0)
->options($this->getActionOptions())
->selectablePlaceholder(false)
->default(Task::ACTION_POWER),
->default(Task::ACTION_POWER)
->afterStateUpdated(fn ($state, Set $set) => $set('payload', $state === Task::ACTION_POWER ? 'restart' : null)),
Textarea::make('payload')
->hidden(fn (Get $get) => $get('action') === Task::ACTION_POWER)
->label(fn (Get $get) => $this->getActionOptions(false)[$get('action')] ?? 'Payload'),
@ -81,7 +83,8 @@ class TasksRelationManager extends RelationManager
$schedule = $this->getOwnerRecord();
return $table
->reorderable('sequence_id', true)
->reorderable('sequence_id')
->defaultSort('sequence_id')
->columns([
TextColumn::make('action')
->state(fn (Task $task) => $this->getActionOptions()[$task->action] ?? $task->action),