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

This commit is contained in:
Ahmed Darrazi 2026-01-05 10:50:31 +01:00
parent ca8b9c2e1c
commit 0fd4a042a7
2 changed files with 40 additions and 1 deletions

View File

@ -279,7 +279,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

@ -4,6 +4,7 @@
use App\Filament\Resources\BackupScheduleResource\Pages\EditBackupSchedule;
use App\Models\BackupSchedule;
use App\Models\Tenant;
use Carbon\CarbonImmutable;
use Filament\Facades\Filament;
use Livewire\Livewire;
@ -48,6 +49,30 @@
->assertDontSee('Tenant B schedule');
});
test('backup schedules listing shows next run in schedule timezone', function () {
[$user, $tenant] = createUserWithTenant(role: 'manager');
BackupSchedule::query()->create([
'tenant_id' => $tenant->id,
'name' => 'Berlin schedule',
'is_enabled' => true,
'timezone' => 'Europe/Berlin',
'frequency' => 'daily',
'time_of_day' => '10:17:00',
'days_of_week' => null,
'policy_types' => ['deviceConfiguration'],
'include_foundations' => true,
'retention_keep_last' => 30,
'next_run_at' => CarbonImmutable::create(2026, 1, 5, 9, 17, 0, 'UTC'),
]);
$this->actingAs($user);
$this->get(route('filament.admin.resources.backup-schedules.index', filamentTenantRouteParams($tenant)))
->assertOk()
->assertSee('Jan 5, 2026 10:17:00');
});
test('backup schedules pages return 404 for unauthorized tenant', function () {
[$user] = createUserWithTenant(role: 'manager');
$unauthorizedTenant = Tenant::factory()->create();