From a05835f87cf820d00a7ce221a3d4b1fc41c55403 Mon Sep 17 00:00:00 2001 From: Ahmed Darrazi Date: Mon, 5 Jan 2026 10:13:16 +0100 Subject: [PATCH] fix(backup-scheduling): show next run in schedule timezone --- .../Resources/BackupScheduleResource.php | 16 +++++++++++++++- specs/032-backup-scheduling-mvp/tasks.md | 1 + .../BackupScheduling/BackupScheduleCrudTest.php | 5 ++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/Filament/Resources/BackupScheduleResource.php b/app/Filament/Resources/BackupScheduleResource.php index 8ef28ce..b880475 100644 --- a/app/Filament/Resources/BackupScheduleResource.php +++ b/app/Filament/Resources/BackupScheduleResource.php @@ -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([ diff --git a/specs/032-backup-scheduling-mvp/tasks.md b/specs/032-backup-scheduling-mvp/tasks.md index 03cca66..1eaef0b 100644 --- a/specs/032-backup-scheduling-mvp/tasks.md +++ b/specs/032-backup-scheduling-mvp/tasks.md @@ -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 diff --git a/tests/Feature/BackupScheduling/BackupScheduleCrudTest.php b/tests/Feature/BackupScheduling/BackupScheduleCrudTest.php index 90c9f73..0c30d59 100644 --- a/tests/Feature/BackupScheduling/BackupScheduleCrudTest.php +++ b/tests/Feature/BackupScheduling/BackupScheduleCrudTest.php @@ -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'); });