Skip to content

Commit

Permalink
Add Edit/Delete on Tasks (#826)
Browse files Browse the repository at this point in the history
  • Loading branch information
notAreYouScared authored Dec 12, 2024
1 parent d092276 commit 663b097
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
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;
Expand Down Expand Up @@ -42,6 +44,49 @@ public function table(Table $table): Table
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)
Expand Down

0 comments on commit 663b097

Please sign in to comment.