mirror of
https://github.com/pelican-dev/panel.git
synced 2025-12-19 18:01:20 +01:00
Fix schedule actions (#1992)
This commit is contained in:
parent
9449d78144
commit
fdd9faaaa3
@ -123,7 +123,7 @@ class ListLogs extends BaseListLogs
|
||||
}
|
||||
}),
|
||||
DeleteAction::make()
|
||||
->icon('tabler-trash')->iconSize(IconSize::Medium)->iconButton(),
|
||||
->iconSize(IconSize::Medium)->iconButton(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ class ViewLogs extends BaseViewLog
|
||||
BackAction::make()
|
||||
->icon('tabler-arrow-left')->iconSize(IconSize::ExtraLarge)->iconButton(),
|
||||
DeleteAction::make(withTooltip: true)
|
||||
->icon('tabler-trash')->iconSize(IconSize::ExtraLarge)->iconButton(),
|
||||
->iconSize(IconSize::ExtraLarge)->iconButton(),
|
||||
DownloadAction::make(withTooltip: true)
|
||||
->icon('tabler-file-download')->iconSize(IconSize::ExtraLarge)->iconButton(),
|
||||
Action::make('uploadLogs')
|
||||
|
||||
@ -24,7 +24,7 @@ class ExportEggAction extends Action
|
||||
|
||||
$this->iconButton();
|
||||
|
||||
$this->icon('tabler-file-export');
|
||||
$this->icon('tabler-download');
|
||||
|
||||
$this->tableIcon('tabler-download');
|
||||
|
||||
|
||||
@ -2,15 +2,19 @@
|
||||
|
||||
namespace App\Filament\Server\Resources\Schedules\Pages;
|
||||
|
||||
use App\Enums\ScheduleStatus;
|
||||
use App\Enums\SubuserPermission;
|
||||
use App\Facades\Activity;
|
||||
use App\Filament\Components\Actions\ExportScheduleAction;
|
||||
use App\Filament\Server\Resources\Schedules\ScheduleResource;
|
||||
use App\Models\Schedule;
|
||||
use App\Services\Schedules\ProcessScheduleService;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Filament\Support\Enums\IconSize;
|
||||
|
||||
@ -49,22 +53,36 @@ class EditSchedule extends EditRecord
|
||||
{
|
||||
return [
|
||||
DeleteAction::make()
|
||||
->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
|
||||
->hiddenLabel()
|
||||
->iconButton()->iconSize(IconSize::ExtraLarge)
|
||||
->tooltip(trans('server/schedule.delete'))
|
||||
->after(function ($record) {
|
||||
Activity::event('server:schedule.delete')
|
||||
->property('name', $record->name)
|
||||
->log();
|
||||
}),
|
||||
Action::make('run_now')
|
||||
->iconButton()->iconSize(IconSize::ExtraLarge)
|
||||
->icon('tabler-run')
|
||||
->authorize(fn () => user()?->can(SubuserPermission::ScheduleUpdate, Filament::getTenant()))
|
||||
->tooltip(fn (Schedule $schedule) => $schedule->tasks->count() === 0 ? trans('server/schedule.no_tasks') : ($schedule->status === ScheduleStatus::Processing ? ScheduleStatus::Processing->getLabel() : trans('server/schedule.run_now')))
|
||||
->color(fn (Schedule $schedule) => $schedule->tasks->count() === 0 || $schedule->status === ScheduleStatus::Processing ? 'warning' : 'primary')
|
||||
->disabled(fn (Schedule $schedule) => $schedule->tasks->count() === 0 || $schedule->status === ScheduleStatus::Processing)
|
||||
->action(function (ProcessScheduleService $service, Schedule $schedule) {
|
||||
$service->handle($schedule, true);
|
||||
|
||||
Activity::event('server:schedule.execute')
|
||||
->subject($schedule)
|
||||
->property('name', $schedule->name)
|
||||
->log();
|
||||
|
||||
$this->fillForm();
|
||||
}),
|
||||
ExportScheduleAction::make(),
|
||||
$this->getSaveFormAction()->formId('form')
|
||||
->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
|
||||
->icon('tabler-device-floppy')
|
||||
->tooltip(trans('server/schedule.save')),
|
||||
$this->getCancelFormAction()->formId('form')
|
||||
->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
|
||||
->icon('tabler-arrow-left')
|
||||
->tooltip(trans('server/schedule.cancel')),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -2,18 +2,12 @@
|
||||
|
||||
namespace App\Filament\Server\Resources\Schedules\Pages;
|
||||
|
||||
use App\Enums\ScheduleStatus;
|
||||
use App\Enums\SubuserPermission;
|
||||
use App\Facades\Activity;
|
||||
use App\Filament\Server\Resources\Schedules\ScheduleResource;
|
||||
use App\Models\Schedule;
|
||||
use App\Services\Schedules\ProcessScheduleService;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
use Filament\Support\Enums\IconSize;
|
||||
|
||||
@ -28,21 +22,6 @@ class ViewSchedule extends ViewRecord
|
||||
protected function getDefaultHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('run_now')
|
||||
->authorize(fn () => user()?->can(SubuserPermission::ScheduleUpdate, Filament::getTenant()))
|
||||
->label(fn (Schedule $schedule) => $schedule->tasks->count() === 0 ? trans('server/schedule.no_tasks') : ($schedule->status === ScheduleStatus::Processing ? ScheduleStatus::Processing->getLabel() : trans('server/schedule.run_now')))
|
||||
->color(fn (Schedule $schedule) => $schedule->tasks->count() === 0 || $schedule->status === ScheduleStatus::Processing ? 'warning' : 'primary')
|
||||
->disabled(fn (Schedule $schedule) => $schedule->tasks->count() === 0 || $schedule->status === ScheduleStatus::Processing)
|
||||
->action(function (ProcessScheduleService $service, Schedule $schedule) {
|
||||
$service->handle($schedule, true);
|
||||
|
||||
Activity::event('server:schedule.execute')
|
||||
->subject($schedule)
|
||||
->property('name', $schedule->name)
|
||||
->log();
|
||||
|
||||
$this->fillForm();
|
||||
}),
|
||||
EditAction::make()
|
||||
->hiddenLabel()->iconButton()->iconSize(IconSize::ExtraLarge)
|
||||
->icon('tabler-calendar-code')
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\View\ActionsIconAlias;
|
||||
use Filament\Forms\Components\Field;
|
||||
use Filament\Forms\Components\Select;
|
||||
@ -84,6 +85,7 @@ class FilamentServiceProvider extends ServiceProvider
|
||||
});
|
||||
|
||||
Select::configureUsing(fn (Select $select) => $select->native(false));
|
||||
DeleteAction::configureUsing(fn (DeleteAction $action) => $action->icon('tabler-trash'));
|
||||
|
||||
FilamentIcon::register([
|
||||
ActionsIconAlias::DELETE_ACTION => 'tabler-trash',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user