fix(backup-scheduling): show next run in schedule timezone

This commit is contained in:
Ahmed Darrazi 2026-01-05 10:13:16 +01:00
parent c00b2d32ee
commit a05835f87c
3 changed files with 20 additions and 2 deletions

View File

@ -278,7 +278,21 @@ public static function table(Table $table): Table
TextColumn::make('next_run_at')
->label('Next run')
->dateTime()
->getStateUsing(function (BackupSchedule $record): ?string {
$nextRun = $record->next_run_at;
if (! $nextRun) {
return null;
}
$timezone = $record->timezone ?: 'UTC';
try {
return $nextRun->setTimezone($timezone)->format('M j, Y H:i:s');
} catch (\Throwable) {
return $nextRun->format('M j, Y H:i:s');
}
})
->sortable(),
])
->filters([

View File

@ -88,6 +88,7 @@ ### Tests (Pest)
- [X] T029 [P] [US3] Add feature test tests/Feature/BackupScheduling/ApplyRetentionJobTest.php (keeps last N backup_sets; soft-deletes older)
- [X] T038 [P] [US1] Add feature test tests/Feature/BackupScheduling/BackupScheduleBulkDeleteTest.php (bulk delete action regression)
- [X] T039 [P] [US1] Extend tests/Feature/BackupScheduling/BackupScheduleBulkDeleteTest.php (operator cannot bulk delete)
- [X] T040 [P] [US1] Update app/Filament/Resources/BackupScheduleResource.php and tests/Feature/BackupScheduling/BackupScheduleCrudTest.php (display next_run in schedule timezone)
### Implementation

View File

@ -17,13 +17,15 @@
'tenant_id' => $tenantA->id,
'name' => 'Tenant A schedule',
'is_enabled' => true,
'timezone' => 'UTC',
'timezone' => 'Europe/Berlin',
'frequency' => 'daily',
'time_of_day' => '01:00:00',
'days_of_week' => null,
'policy_types' => ['deviceConfiguration'],
'include_foundations' => true,
'retention_keep_last' => 30,
// Stored in UTC; should render as schedule-local time in list.
'next_run_at' => '2026-01-05 09:08:00',
]);
BackupSchedule::query()->create([
@ -45,6 +47,7 @@
->assertOk()
->assertSee('Tenant A schedule')
->assertSee('Device Configuration')
->assertSee('Jan 5, 2026 10:08:00')
->assertDontSee('Tenant B schedule');
});