Implements Spec 091 “BackupSchedule Retention & Lifecycle (Archive/Restore/Force Delete)”.
- BackupSchedule lifecycle:
- Archive (soft delete) with confirmation; restores via Restore action; Force delete with confirmation and strict gating.
- Force delete blocked when historical runs exist.
- Archived schedules never dispatch/execute (dispatcher + job guard).
- Audit events emitted for archive/restore/force delete.
- RBAC UX semantics preserved (non-member hidden/404; member w/o capability disabled + server-side 403).
- Filament UX contract update:
- Create CTA placement rule across create-enabled list pages:
- Empty list: only large centered empty-state Create CTA.
- Non-empty list: only header Create action.
- Tests added/updated to enforce the rule.
Verification:
- `vendor/bin/sail bin pint --dirty`
- Focused tests: BackupScheduling + RBAC enforcement + EmptyState CTAs + Create CTA placement
Notes:
- Filament v5 / Livewire v4 compliant.
- Manual quickstart verification in `specs/091-backupschedule-retention-lifecycle/quickstart.md` remains to be checked (T031).
Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #109
49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\BackupScheduleResource\Pages;
|
|
|
|
use App\Filament\Resources\BackupScheduleResource;
|
|
use Filament\Actions;
|
|
use Filament\Resources\Pages\ListRecords;
|
|
|
|
class ListBackupSchedules extends ListRecords
|
|
{
|
|
protected static string $resource = BackupScheduleResource::class;
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [$this->makeHeaderCreateAction()];
|
|
}
|
|
|
|
protected function getTableEmptyStateActions(): array
|
|
{
|
|
return [$this->makeEmptyStateCreateAction()];
|
|
}
|
|
|
|
private function tableHasRecords(): bool
|
|
{
|
|
return $this->getTableRecords()->count() > 0;
|
|
}
|
|
|
|
private function makeHeaderCreateAction(): Actions\CreateAction
|
|
{
|
|
return $this->makeCreateAction()
|
|
->visible(fn (): bool => $this->tableHasRecords());
|
|
}
|
|
|
|
private function makeEmptyStateCreateAction(): Actions\CreateAction
|
|
{
|
|
return $this->makeCreateAction();
|
|
}
|
|
|
|
private function makeCreateAction(): Actions\CreateAction
|
|
{
|
|
return Actions\CreateAction::make()
|
|
->label('New backup schedule')
|
|
->disabled(fn (): bool => ! BackupScheduleResource::canCreate())
|
|
->tooltip(fn (): ?string => BackupScheduleResource::canCreate()
|
|
? null
|
|
: 'You do not have permission to create backup schedules.');
|
|
}
|
|
}
|