mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 01:44:45 +02:00
Add Edit/Delete on Tasks (#826)
This commit is contained in:
parent
d09227659e
commit
663b097d22
@ -5,11 +5,13 @@ namespace App\Filament\Server\Resources\ScheduleResource\RelationManagers;
|
||||
use App\Facades\Activity;
|
||||
use App\Models\Schedule;
|
||||
use App\Models\Task;
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Tables\Actions\CreateAction;
|
||||
@ -42,6 +44,49 @@ class TasksRelationManager extends RelationManager
|
||||
IconColumn::make('continue_on_failure')
|
||||
->boolean(),
|
||||
])
|
||||
->actions([
|
||||
EditAction::make()
|
||||
->form([
|
||||
Select::make('action')
|
||||
->required()
|
||||
->live()
|
||||
->disableOptionWhen(fn (string $value): bool => $value === Task::ACTION_BACKUP && $schedule->server->backup_limit === 0)
|
||||
->options([
|
||||
Task::ACTION_POWER => 'Send power action',
|
||||
Task::ACTION_COMMAND => 'Send command',
|
||||
Task::ACTION_BACKUP => 'Create backup',
|
||||
Task::ACTION_DELETE_FILES => 'Delete files',
|
||||
]),
|
||||
Textarea::make('payload')
|
||||
->hidden(fn (Get $get) => $get('action') === Task::ACTION_POWER)
|
||||
->label(fn (Get $get) => match ($get('action')) {
|
||||
Task::ACTION_POWER => 'Power action',
|
||||
Task::ACTION_COMMAND => 'Command',
|
||||
Task::ACTION_BACKUP => 'Files to ignore',
|
||||
Task::ACTION_DELETE_FILES => 'Files to delete',
|
||||
default => 'Payload'
|
||||
}),
|
||||
Select::make('payload')
|
||||
->visible(fn (Get $get) => $get('action') === Task::ACTION_POWER)
|
||||
->label('Power Action')
|
||||
->required()
|
||||
->options([
|
||||
'start' => 'Start',
|
||||
'restart' => 'Restart',
|
||||
'stop' => 'Stop',
|
||||
'Kill' => 'Kill',
|
||||
]),
|
||||
TextInput::make('time_offset')
|
||||
->hidden(fn (Get $get) => config('queue.default') === 'sync' || $get('sequence_id') === 1)
|
||||
->default(0)
|
||||
->numeric()
|
||||
->minValue(0)
|
||||
->maxValue(900)
|
||||
->suffix('Seconds'),
|
||||
Toggle::make('continue_on_failure'),
|
||||
]),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make()
|
||||
->createAnother(false)
|
||||
|
Loading…
x
Reference in New Issue
Block a user