mirror of
https://github.com/pelican-dev/panel.git
synced 2025-06-28 08:41:07 +02:00
Schedule task improvements (#1468)
This commit is contained in:
parent
68f72b9b4d
commit
4d0aabe91e
@ -6,6 +6,7 @@ use App\Facades\Activity;
|
|||||||
use App\Models\Schedule;
|
use App\Models\Schedule;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Filament\Forms\Components\Field;
|
use Filament\Forms\Components\Field;
|
||||||
|
use Filament\Forms\Set;
|
||||||
use Filament\Tables\Actions\DeleteAction;
|
use Filament\Tables\Actions\DeleteAction;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\Textarea;
|
use Filament\Forms\Components\Textarea;
|
||||||
@ -45,10 +46,11 @@ class TasksRelationManager extends RelationManager
|
|||||||
Select::make('action')
|
Select::make('action')
|
||||||
->required()
|
->required()
|
||||||
->live()
|
->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())
|
->options($this->getActionOptions())
|
||||||
->selectablePlaceholder(false)
|
->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')
|
Textarea::make('payload')
|
||||||
->hidden(fn (Get $get) => $get('action') === Task::ACTION_POWER)
|
->hidden(fn (Get $get) => $get('action') === Task::ACTION_POWER)
|
||||||
->label(fn (Get $get) => $this->getActionOptions(false)[$get('action')] ?? 'Payload'),
|
->label(fn (Get $get) => $this->getActionOptions(false)[$get('action')] ?? 'Payload'),
|
||||||
@ -81,7 +83,8 @@ class TasksRelationManager extends RelationManager
|
|||||||
$schedule = $this->getOwnerRecord();
|
$schedule = $this->getOwnerRecord();
|
||||||
|
|
||||||
return $table
|
return $table
|
||||||
->reorderable('sequence_id', true)
|
->reorderable('sequence_id')
|
||||||
|
->defaultSort('sequence_id')
|
||||||
->columns([
|
->columns([
|
||||||
TextColumn::make('action')
|
TextColumn::make('action')
|
||||||
->state(fn (Task $task) => $this->getActionOptions()[$task->action] ?? $task->action),
|
->state(fn (Task $task) => $this->getActionOptions()[$task->action] ?? $task->action),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user