migrating tests (Application, Console and Cronjob)

This commit is contained in:
Saeed Vaziry
2024-10-08 22:15:50 +02:00
parent 974af959f1
commit 0da21f40bd
39 changed files with 254 additions and 2684 deletions

View File

@ -20,9 +20,9 @@ class Index extends Page
protected $listeners = ['$refresh'];
public static function canAccess(): bool
public function mount(): void
{
return auth()->user()?->can('viewAny', [CronJob::class, static::getServerFromRoute()]) ?? false;
$this->authorize('viewAny', [CronJob::class, $this->server]);
}
public function getWidgets(): array

View File

@ -3,6 +3,8 @@
namespace App\Web\Pages\Servers\CronJobs\Widgets;
use App\Actions\CronJob\DeleteCronJob;
use App\Actions\CronJob\DisableCronJob;
use App\Actions\CronJob\EnableCronJob;
use App\Models\CronJob;
use App\Models\Server;
use Filament\Notifications\Notification;
@ -33,6 +35,17 @@ protected function getTableColumns(): array
->tooltip(fn (CronJob $cronJob) => $cronJob->command)
->searchable()
->copyable(),
TextColumn::make('frequency')
->formatStateUsing(fn (CronJob $cronJob) => $cronJob->frequencyLabel())
->searchable()
->sortable()
->copyable(),
TextColumn::make('status')
->label('Status')
->badge()
->color(fn (CronJob $record) => CronJob::$statusColors[$record->status])
->searchable()
->sortable(),
TextColumn::make('created_at')
->formatStateUsing(fn (CronJob $cronJob) => $cronJob->created_at_by_timezone)
->sortable(),
@ -43,6 +56,30 @@ public function getTable(): Table
{
return $this->table
->actions([
Action::make('enable')
->hiddenLabel()
->tooltip('Enable')
->icon('heroicon-o-play')
->requiresConfirmation()
->authorize(fn (CronJob $record) => auth()->user()->can('update', [$record, $this->server]))
->visible(fn (CronJob $record) => $record->isDisabled())
->action(function (CronJob $record) {
run_action($this, function () use ($record) {
app(EnableCronJob::class)->enable($this->server, $record);
});
}),
Action::make('disable')
->hiddenLabel()
->tooltip('Disable')
->icon('heroicon-o-stop')
->requiresConfirmation()
->authorize(fn (CronJob $record) => auth()->user()->can('update', [$record, $this->server]))
->visible(fn (CronJob $record) => $record->isEnabled())
->action(function (CronJob $record) {
run_action($this, function () use ($record) {
app(DisableCronJob::class)->disable($this->server, $record);
});
}),
Action::make('delete')
->icon('heroicon-o-trash')
->tooltip('Delete')